| Differences between
and this patch
- a/Source/WebCore/ChangeLog +35 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-08-08  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
2
3
        [css3-text] Add support for "text-decoration" using CSS3 spec
4
        https://bugs.webkit.org/show_bug.cgi?id=92000
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        This patch implements the "text-decoration" shorthand property specified in CSS3
9
        working draft. The specification can be found below:
10
        http://dev.w3.org/csswg/css3-text/#text-decoration
11
12
        This implementation follows the logic described below:
13
14
        1. text-decoration: none | [ underline || overline || line-through || blink ]
15
        In this case, "text-decoration" is not handled as a shorthand, and is backwards
16
        compatible with CSS2.1 implementation.
17
18
        2. text-decoration: <text-decoration-line> || <text-decoration-style> ||
19
                            <text-decoration-color> || blink
20
        Whenever a value not described in 1. is appended to the values list, then
21
        "text-decoration" is handled as a shorthand, following the rules described in
22
        CSS3 specification.
23
24
        Test: fast/css/text-decoration-css3.html
25
26
        * css/CSSParser.cpp:
27
        (WebCore::CSSParser::parseValue):
28
        (WebCore::CSSParser::addTextDecorationProperty):
29
        (WebCore::CSSParser::parseTextDecoration):
30
        (WebCore::CSSParser::parseTextDecorationShorthand):
31
        * css/CSSParser.h:
32
        * css/StylePropertyShorthand.cpp:
33
        (WebCore::webkitTextDecorationShorthand):
34
        * css/StylePropertyShorthand.h:
35
1
2012-08-07  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
36
2012-08-07  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
2
37
3
        [css3-text] Add support for -webkit-text-decoration-color
38
        [css3-text] Add support for -webkit-text-decoration-color
- a/Source/WebCore/css/CSSParser.cpp -2 / +37 lines
Lines 2100-2105 bool CSSParser::parseValue(CSSPropertyID propId, bool important) a/Source/WebCore/css/CSSParser.cpp_sec1
2100
    }
2100
    }
2101
2101
2102
    case CSSPropertyTextDecoration:
2102
    case CSSPropertyTextDecoration:
2103
        // <text-decoration-line> || <text-decoration-style> || <text-decoration-color> || blink
2104
        return parseTextDecorationShorthand(important);
2105
2103
    case CSSPropertyWebkitTextDecorationLine:
2106
    case CSSPropertyWebkitTextDecorationLine:
2104
    case CSSPropertyWebkitTextDecorationsInEffect:
2107
    case CSSPropertyWebkitTextDecorationsInEffect:
2105
        // none | [ underline || overline || line-through || blink ] | inherit
2108
        // none | [ underline || overline || line-through || blink ] | inherit
Lines 7919-7925 bool CSSParser::parsePerspectiveOrigin(CSSPropertyID propId, CSSPropertyID& prop a/Source/WebCore/css/CSSParser.cpp_sec2
7919
7922
7920
void CSSParser::addTextDecorationProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important)
7923
void CSSParser::addTextDecorationProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important)
7921
{
7924
{
7922
    if (propId == CSSPropertyTextDecoration && !inShorthand())
7925
    if (propId == CSSPropertyTextDecoration && m_currentShorthand == CSSPropertyInvalid)
7923
        // Skip if -webkit-text-decoration-line was previously set
7926
        // Skip if -webkit-text-decoration-line was previously set
7924
        for (unsigned i = 0; i < m_parsedProperties.size(); ++i)
7927
        for (unsigned i = 0; i < m_parsedProperties.size(); ++i)
7925
            if (m_parsedProperties[i].id() == CSSPropertyWebkitTextDecorationLine)
7928
            if (m_parsedProperties[i].id() == CSSPropertyWebkitTextDecorationLine)
Lines 7956-7962 bool CSSParser::parseTextDecoration(CSSPropertyID propId, bool important) a/Source/WebCore/css/CSSParser.cpp_sec3
7956
            value = m_valueList->next();
7959
            value = m_valueList->next();
7957
    }
7960
    }
7958
7961
7959
    if (list->length() && isValid) {
7962
    // Values are valid or in shorthand scope
7963
    if (list->length() && (isValid || m_currentShorthand != CSSPropertyInvalid)) {
7960
        addTextDecorationProperty(propId, list.release(), important);
7964
        addTextDecorationProperty(propId, list.release(), important);
7961
        return true;
7965
        return true;
7962
    }
7966
    }
Lines 7964-7969 bool CSSParser::parseTextDecoration(CSSPropertyID propId, bool important) a/Source/WebCore/css/CSSParser.cpp_sec4
7964
    return false;
7968
    return false;
7965
}
7969
}
7966
7970
7971
bool CSSParser::parseTextDecorationShorthand(bool important)
7972
{
7973
    bool isShorthand = false;
7974
    int blinkValueIndex = -1;
7975
    CSSParserValue* value = 0;
7976
    for (unsigned i = 0; i < m_valueList->size(); ++i) {
7977
        value = m_valueList->valueAt(i);
7978
        if (!value)
7979
            return false;
7980
        switch (value->id) {
7981
        case CSSValueNone:
7982
        case CSSValueUnderline:
7983
        case CSSValueOverline:
7984
        case CSSValueLineThrough:
7985
            continue;
7986
        case CSSValueBlink:
7987
            blinkValueIndex = i;
7988
            continue;
7989
        default:
7990
            isShorthand = true;
7991
            break;
7992
        }
7993
    }
7994
7995
    // Blink value is accepted, but not parsed
7996
    if (blinkValueIndex != -1)
7997
        m_valueList->deleteValueAt(blinkValueIndex);
7998
7999
    return isShorthand ? parseShorthand(CSSPropertyTextDecoration, webkitTextDecorationShorthand(), important) : parseTextDecoration(CSSPropertyTextDecoration, important);
8000
}
8001
7967
bool CSSParser::parseTextEmphasisStyle(bool important)
8002
bool CSSParser::parseTextEmphasisStyle(bool important)
7968
{
8003
{
7969
    unsigned valueListSize = m_valueList->size();
8004
    unsigned valueListSize = m_valueList->size();
- a/Source/WebCore/css/CSSParser.h +1 lines
Lines 233-238 public: a/Source/WebCore/css/CSSParser.h_sec1
233
233
234
    void addTextDecorationProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important);
234
    void addTextDecorationProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important);
235
    bool parseTextDecoration(CSSPropertyID propId, bool important);
235
    bool parseTextDecoration(CSSPropertyID propId, bool important);
236
    bool parseTextDecorationShorthand(bool important);
236
237
237
    bool parseLineBoxContain(bool important);
238
    bool parseLineBoxContain(bool important);
238
    bool parseCalculation(CSSParserValue*, CalculationPermittedValueRange);
239
    bool parseCalculation(CSSParserValue*, CalculationPermittedValueRange);
- a/Source/WebCore/css/StylePropertyShorthand.cpp +11 lines
Lines 383-388 const StylePropertyShorthand& webkitTextEmphasisShorthand() a/Source/WebCore/css/StylePropertyShorthand.cpp_sec1
383
    return webkitTextEmphasisLonghands;
383
    return webkitTextEmphasisLonghands;
384
}
384
}
385
385
386
const StylePropertyShorthand& webkitTextDecorationShorthand()
387
{
388
    static const CSSPropertyID textDecorationProperties[] = {
389
        CSSPropertyWebkitTextDecorationLine,
390
        CSSPropertyWebkitTextDecorationStyle,
391
        CSSPropertyWebkitTextDecorationColor
392
    };
393
    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitTextDecorationLonghands, (textDecorationProperties, WTF_ARRAY_LENGTH(textDecorationProperties)));
394
    return webkitTextDecorationLonghands;
395
}
396
386
const StylePropertyShorthand& webkitTextStrokeShorthand()
397
const StylePropertyShorthand& webkitTextStrokeShorthand()
387
{
398
{
388
    static const CSSPropertyID textStrokeProperties[] = { CSSPropertyWebkitTextStrokeWidth, CSSPropertyWebkitTextStrokeColor };
399
    static const CSSPropertyID textStrokeProperties[] = { CSSPropertyWebkitTextStrokeWidth, CSSPropertyWebkitTextStrokeColor };
- a/Source/WebCore/css/StylePropertyShorthand.h +1 lines
Lines 96-101 const StylePropertyShorthand& webkitMaskShorthand(); a/Source/WebCore/css/StylePropertyShorthand.h_sec1
96
const StylePropertyShorthand& webkitMaskPositionShorthand();
96
const StylePropertyShorthand& webkitMaskPositionShorthand();
97
const StylePropertyShorthand& webkitMaskRepeatShorthand();
97
const StylePropertyShorthand& webkitMaskRepeatShorthand();
98
const StylePropertyShorthand& webkitTextEmphasisShorthand();
98
const StylePropertyShorthand& webkitTextEmphasisShorthand();
99
const StylePropertyShorthand& webkitTextDecorationShorthand();
99
const StylePropertyShorthand& webkitTextStrokeShorthand();
100
const StylePropertyShorthand& webkitTextStrokeShorthand();
100
const StylePropertyShorthand& webkitTransitionShorthand();
101
const StylePropertyShorthand& webkitTransitionShorthand();
101
const StylePropertyShorthand& webkitTransformOriginShorthand();
102
const StylePropertyShorthand& webkitTransformOriginShorthand();
- a/LayoutTests/ChangeLog +26 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2012-08-08  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
2
3
        [css3-text] Add support for "text-decoration" using CSS3 spec
4
        https://bugs.webkit.org/show_bug.cgi?id=92000
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        This patch implements the "text-decoration" shorthand property specified in CSS3
9
        working draft. The specification can be found below:
10
        http://dev.w3.org/csswg/css3-text/#text-decoration
11
12
        This implementation follows the logic described below:
13
14
        1. text-decoration: none | [ underline || overline || line-through || blink ]
15
        In this case, "text-decoration" is not handled as a shorthand, and is backwards
16
        compatible with CSS2.1 implementation.
17
18
        2. text-decoration: <text-decoration-line> || <text-decoration-style> ||
19
                            <text-decoration-color> || blink
20
        Whenever a value not described in 1. is appended to the values list, then
21
        "text-decoration" is handled as a shorthand, following the rules described in
22
        CSS3 specification.
23
24
        * fast/css/text-decoration-css3-expected.txt: Added.
25
        * fast/css/text-decoration-css3.html: Added.
26
1
2012-08-07  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
27
2012-08-07  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
2
28
3
        [css3-text] Add support for -webkit-text-decoration-color
29
        [css3-text] Add support for -webkit-text-decoration-color
- a/LayoutTests/fast/css/text-decoration-css3-expected.txt +20 lines
Line 0 a/LayoutTests/fast/css/text-decoration-css3-expected.txt_sec1
1
2
Example 1:
3
| <span>
4
|   style="text-decoration: underline;"
5
|   "Underline text"
6
7
Example 2:
8
| <span>
9
|   style="-webkit-text-decoration-line: underline; -webkit-text-decoration-style: dashed;"
10
|   "Underline and dashed text"
11
12
Example 3:
13
| <span>
14
|   style="text-decoration: underline dashed blue;"
15
|   "Underline and dashed (blue decoration) text"
16
17
Example 4:
18
| <span>
19
|   style="text-decoration: underline; -webkit-text-decoration-style: dashed;"
20
|   "Underline and dashed text"
- a/LayoutTests/fast/css/text-decoration-css3.html +17 lines
Line 0 a/LayoutTests/fast/css/text-decoration-css3.html_sec1
1
<html>
2
<body>
3
    <script src="../../resources/dump-as-markup.js"></script>
4
    <p><b>Example 1: Text decoration handled as a non-shorthand property</b></p>
5
    <div id="example1"><span style="text-decoration: underline;">Underline text</span></div>
6
    <script>Markup.dump(document.getElementById("example1"), "Example 1");</script>
7
    <p><b>Example 2: Text decoration line + style longhand</b></p>
8
    <div id="example2"><span style="-webkit-text-decoration-line: underline; -webkit-text-decoration-style: dashed;">Underline and dashed text</span></div>
9
    <script>Markup.dump(document.getElementById("example2"), "Example 2");</script>
10
    <p><b>Example 3: Text decoration handled as a shorthand property</b></p>
11
    <div id="example3"><span style="text-decoration: underline dashed blue;">Underline and dashed (blue decoration) text</span></div>
12
    <script>Markup.dump(document.getElementById("example3"), "Example 3");</script>
13
    <p><b>Example 4: Text decoration + text decoration style</b></p>
14
    <div id="example4"><span style="text-decoration: underline; -webkit-text-decoration-style: dashed;">Underline and dashed text</span></div>
15
    <script>Markup.dump(document.getElementById("example4"), "Example 4");</script>
16
</body>
17
</html>

Return to Bug 92000