Title: [125205] trunk
Revision
125205
Author
[email protected]
Date
2012-08-09 14:49:36 -0700 (Thu, 09 Aug 2012)

Log Message

[css3-text] Add suport for -webkit-text-decoration-line
https://bugs.webkit.org/show_bug.cgi?id=90959

Patch by Bruno de Oliveira Abinader <[email protected]> on 2012-08-09
Reviewed by Kenneth Rohde Christiansen.

This patch implements the "text-decoration-line" property specified in CSS3
working draft, with "-webkit-" prefix. The specification can be found below:
http://dev.w3.org/csswg/css3-text/#text-decoration-line

Additionally, Mozilla implementation details can be found here:
https://developer-dev.allizom.org/en-US/docs/CSS/text-decoration-line

It is important to notice that "-webkit-text-decoration-line" and
"text-decoration" properties shares the same property handlers, however, the
former resets the latter if value from latter doesn't have "important" value
set (same behavior as Firefox). In a rare case where both properties have
"important" value set, the text decoration gets value from the last parsed
property.

Source/WebCore:

Test: fast/css/text-decoration-line.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::renderTextDecorationFlagsToCSSValue):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::addTextDecorationProperty):
(WebCore::CSSParser::parseTextDecoration):
* css/CSSParser.h:
* css/CSSProperty.cpp:
(WebCore::CSSProperty::isInheritedProperty):
* css/CSSPropertyNames.in:
* css/StyleBuilder.cpp:
(WebCore::StyleBuilder::StyleBuilder):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::collectMatchingRulesForList):

LayoutTests:

* fast/css/getComputedStyle/computed-style-expected.txt:
* fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
* fast/css/getComputedStyle/resources/property-names.js:
* fast/css/text-decoration-line-expected.html: Added.
* fast/css/text-decoration-line.html: Added.
* svg/css/getComputedStyle-basic-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125204 => 125205)


--- trunk/LayoutTests/ChangeLog	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/LayoutTests/ChangeLog	2012-08-09 21:49:36 UTC (rev 125205)
@@ -1,3 +1,31 @@
+2012-08-09  Bruno de Oliveira Abinader  <[email protected]>
+
+        [css3-text] Add suport for -webkit-text-decoration-line
+        https://bugs.webkit.org/show_bug.cgi?id=90959
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch implements the "text-decoration-line" property specified in CSS3
+        working draft, with "-webkit-" prefix. The specification can be found below:
+        http://dev.w3.org/csswg/css3-text/#text-decoration-line
+
+        Additionally, Mozilla implementation details can be found here:
+        https://developer-dev.allizom.org/en-US/docs/CSS/text-decoration-line
+
+        It is important to notice that "-webkit-text-decoration-line" and
+        "text-decoration" properties shares the same property handlers, however, the
+        former resets the latter if value from latter doesn't have "important" value
+        set (same behavior as Firefox). In a rare case where both properties have
+        "important" value set, the text decoration gets value from the last parsed
+        property.
+
+        * fast/css/getComputedStyle/computed-style-expected.txt:
+        * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+        * fast/css/getComputedStyle/resources/property-names.js:
+        * fast/css/text-decoration-line-expected.html: Added.
+        * fast/css/text-decoration-line.html: Added.
+        * svg/css/getComputedStyle-basic-expected.txt:
+
 2012-08-09  Robert Hogan  <[email protected]>
 
         CSS 2.1 failure: 'Text-indent' only affects a line if it is the first formatted line of an element

Modified: trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt (125204 => 125205)


--- trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt	2012-08-09 21:49:36 UTC (rev 125205)
@@ -85,6 +85,7 @@
 tab-size: 8;
 text-align: start;
 text-decoration: none;
+-webkit-text-decoration-line: none;
 text-indent: 0px;
 text-rendering: auto;
 text-shadow: none;

Modified: trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt (125204 => 125205)


--- trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt	2012-08-09 21:49:36 UTC (rev 125205)
@@ -84,6 +84,7 @@
 tab-size: 8
 text-align: start
 text-decoration: none
+-webkit-text-decoration-line: none
 text-indent: 0px
 text-rendering: auto
 text-shadow: none

Modified: trunk/LayoutTests/fast/css/getComputedStyle/resources/property-names.js (125204 => 125205)


--- trunk/LayoutTests/fast/css/getComputedStyle/resources/property-names.js	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/LayoutTests/fast/css/getComputedStyle/resources/property-names.js	2012-08-09 21:49:36 UTC (rev 125205)
@@ -232,6 +232,7 @@
     "text-align": true,
     "text-anchor": true,
     "text-decoration": true,
+    "-webkit-text-decoration-line": true,
     "text-indent": true,
     "text-overflow": true,
     "text-rendering": true,

Added: trunk/LayoutTests/fast/css/text-decoration-line-expected.html (0 => 125205)


--- trunk/LayoutTests/fast/css/text-decoration-line-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/text-decoration-line-expected.html	2012-08-09 21:49:36 UTC (rev 125205)
@@ -0,0 +1,29 @@
+<html>
+<head>
+    <style>
+            .none { text-decoration: none; }
+            .underline { text-decoration: underline; }
+            .overline { text-decoration: overline; }
+            .line-through { text-decoration: line-through; }
+            .all-decorations { text-decoration: underline overline line-through; }
+    </style>
+</head>
+<body>
+    <div>Each line of this test should match its style description (<i>-webkit-text-decoration-line</i> resets <i>text-decoration</i>, except when the latter is set as <i>important</i>):</div><br/>
+    <div class="underline">This text is underlined <span>(also inside span).</span></div><br/>
+    <div class="overline">This text is overlined <span>(also inside span).</span></div><br/>
+    <div class="line-through">This text has a line-through <span>(also inside span).</span></div><br/>
+    <div class=none">This text contains no decorations.</div><br/>
+    <div class="underline">This text is underlined.</div><br/>
+    <div class=none">This text contains no decorations.</div><br/>
+    <div class="overline">This text is overlined.</div><br/>
+    <div class=none">This text contains no decorations.</div><br/>
+    <div class="line-through">This text has a line-through.</div><br/>
+    <div class=none">This text contains no decorations.</div><br/>
+    <div class="all-decorations">This text is underlined, overlined and has a line-through.</div><br/>
+    <div class=none">This text contains no decorations.</div><br/>
+    <div class="overline">This text is overlined.</div><br/>
+    <div class="overline">This text is overlined.</div><br/>
+    <div class="underline">This text is underlined.</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/text-decoration-line.html (0 => 125205)


--- trunk/LayoutTests/fast/css/text-decoration-line.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/text-decoration-line.html	2012-08-09 21:49:36 UTC (rev 125205)
@@ -0,0 +1,29 @@
+<html>
+<head>
+    <style>
+            .none { text-decoration: none; }
+            .underline { text-decoration: underline; }
+            .overline { text-decoration: overline; }
+            .line-through { text-decoration: line-through; }
+            .all-decorations { text-decoration: underline overline line-through; }
+    </style>
+</head>
+<body>
+    <div>Each line of this test should match its style description (<i>-webkit-text-decoration-line</i> resets <i>text-decoration</i>, except when the latter is set as <i>important</i>):</div><br/>
+    <div style="-webkit-text-decoration-line: underline;">This text is underlined <span class="none">(also inside span).</span></div><br/>
+    <div style="-webkit-text-decoration-line: overline;">This text is overlined <span class="none">(also inside span).</span></div><br/>
+    <div style="-webkit-text-decoration-line: line-through;">This text has a line-through <span class="none">(also inside span).</span></div><br/>
+    <div class="underline" style="-webkit-text-decoration-line: none;">This text contains no decorations.</div><br/>
+    <div class="underline" style="-webkit-text-decoration-line: underline;">This text is underlined.</div><br/>
+    <div class="overline" style="-webkit-text-decoration-line: none;">This text contains no decorations.</div><br/>
+    <div class="overline" style="-webkit-text-decoration-line: overline;">This text is overlined.</div><br/>
+    <div class="line-through" style="-webkit-text-decoration-line: none;">This text contains no decorations.</div><br/>
+    <div class="line-through" style="-webkit-text-decoration-line: line-through;">This text has a line-through.</div><br/>
+    <div class="all-decorations" style="-webkit-text-decoration-line: none;">This text contains no decorations.</div><br/>
+    <div class="all-decorations" style="-webkit-text-decoration-line: underline overline line-through;">This text is underlined, overlined and has a line-through.</div><br/>
+    <div style="-webkit-text-decoration-line: underline; text-decoration: none !important;">This text contains no decorations.</div><br/>
+    <div style="-webkit-text-decoration-line: underline; text-decoration: overline !important;">This text is overlined.</div><br/>
+    <div style="-webkit-text-decoration-line: underline !important; text-decoration: overline !important;">This text is overlined.</div><br/>
+    <div style="text-decoration: overline !important; -webkit-text-decoration-line: underline !important;">This text is underlined.</div>
+</body>
+</html>

Modified: trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt (125204 => 125205)


--- trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt	2012-08-09 21:49:36 UTC (rev 125205)
@@ -168,6 +168,8 @@
 rect: style.getPropertyCSSValue(text-align) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(text-decoration) : none
 rect: style.getPropertyCSSValue(text-decoration) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(-webkit-text-decoration-line) : none
+rect: style.getPropertyCSSValue(-webkit-text-decoration-line) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(text-indent) : 0px
 rect: style.getPropertyCSSValue(text-indent) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(text-rendering) : auto
@@ -670,6 +672,8 @@
 g: style.getPropertyCSSValue(text-align) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(text-decoration) : none
 g: style.getPropertyCSSValue(text-decoration) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(-webkit-text-decoration-line) : none
+g: style.getPropertyCSSValue(-webkit-text-decoration-line) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(text-indent) : 0px
 g: style.getPropertyCSSValue(text-indent) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(text-rendering) : auto

Modified: trunk/Source/WebCore/ChangeLog (125204 => 125205)


--- trunk/Source/WebCore/ChangeLog	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/Source/WebCore/ChangeLog	2012-08-09 21:49:36 UTC (rev 125205)
@@ -1,3 +1,42 @@
+2012-08-09  Bruno de Oliveira Abinader  <[email protected]>
+
+        [css3-text] Add suport for -webkit-text-decoration-line
+        https://bugs.webkit.org/show_bug.cgi?id=90959
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch implements the "text-decoration-line" property specified in CSS3
+        working draft, with "-webkit-" prefix. The specification can be found below:
+        http://dev.w3.org/csswg/css3-text/#text-decoration-line
+
+        Additionally, Mozilla implementation details can be found here:
+        https://developer-dev.allizom.org/en-US/docs/CSS/text-decoration-line
+
+        It is important to notice that "-webkit-text-decoration-line" and
+        "text-decoration" properties shares the same property handlers, however, the
+        former resets the latter if value from latter doesn't have "important" value
+        set (same behavior as Firefox). In a rare case where both properties have
+        "important" value set, the text decoration gets value from the last parsed
+        property.
+
+        Test: fast/css/text-decoration-line.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::renderTextDecorationFlagsToCSSValue):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::addTextDecorationProperty):
+        (WebCore::CSSParser::parseTextDecoration):
+        * css/CSSParser.h:
+        * css/CSSProperty.cpp:
+        (WebCore::CSSProperty::isInheritedProperty):
+        * css/CSSPropertyNames.in:
+        * css/StyleBuilder.cpp:
+        (WebCore::StyleBuilder::StyleBuilder):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::collectMatchingRulesForList):
+
 2012-08-09  Huang Dongsung  <[email protected]>
 
         Extract the definition of NativeImagePtr from ImageSource.h into NativeImagePtr.h.

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (125204 => 125205)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-08-09 21:49:36 UTC (rev 125205)
@@ -176,6 +176,7 @@
     CSSPropertyTabSize,
     CSSPropertyTextAlign,
     CSSPropertyTextDecoration,
+    CSSPropertyWebkitTextDecorationLine,
     CSSPropertyTextIndent,
     CSSPropertyTextRendering,
     CSSPropertyTextShadow,
@@ -1190,6 +1191,7 @@
 
 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
 {
+    // Blink value is ignored.
     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     if (textDecoration & UNDERLINE)
         list->append(cssValuePool().createIdentifierValue(CSSValueUnderline));
@@ -1197,8 +1199,6 @@
         list->append(cssValuePool().createIdentifierValue(CSSValueOverline));
     if (textDecoration & LINE_THROUGH)
         list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough));
-    if (textDecoration & BLINK)
-        list->append(cssValuePool().createIdentifierValue(CSSValueBlink));
 
     if (!list->length())
         return cssValuePool().createIdentifierValue(CSSValueNone);
@@ -1948,6 +1948,7 @@
         case CSSPropertyTextAlign:
             return cssValuePool().createValue(style->textAlign());
         case CSSPropertyTextDecoration:
+        case CSSPropertyWebkitTextDecorationLine:
             return renderTextDecorationFlagsToCSSValue(style->textDecoration());
         case CSSPropertyWebkitTextDecorationsInEffect:
             return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());

Modified: trunk/Source/WebCore/css/CSSParser.cpp (125204 => 125205)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-08-09 21:49:36 UTC (rev 125205)
@@ -2100,32 +2100,12 @@
     case CSSPropertyTextDecoration:
     case CSSPropertyWebkitTextDecorationsInEffect:
         // none | [ underline || overline || line-through || blink ] | inherit
-        if (id == CSSValueNone) {
-            validPrimitive = true;
-        } else {
-            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
-            bool isValid = true;
-            while (isValid && value) {
-                switch (value->id) {
-                case CSSValueBlink:
-                    break;
-                case CSSValueUnderline:
-                case CSSValueOverline:
-                case CSSValueLineThrough:
-                    list->append(cssValuePool().createIdentifierValue(value->id));
-                    break;
-                default:
-                    isValid = false;
-                }
-                value = m_valueList->next();
-            }
-            if (list->length() && isValid) {
-                parsedValue = list.release();
-                m_valueList->next();
-            }
-        }
-        break;
+        return parseTextDecoration(propId, important);
 
+    case CSSPropertyWebkitTextDecorationLine:
+        // none | [ underline || overline || line-through ] | inherit
+        return parseTextDecoration(propId, important);
+
     case CSSPropertyZoom:          // normal | reset | document | <number> | <percentage> | inherit
         if (id == CSSValueNormal || id == CSSValueReset || id == CSSValueDocument)
             validPrimitive = true;
@@ -7932,6 +7912,56 @@
     return value;
 }
 
+void CSSParser::addTextDecorationProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important)
+{
+    // The text-decoration-line property takes priority over text-decoration, unless the latter has important priority set.
+    if (propId == CSSPropertyTextDecoration && !important && m_currentShorthand == CSSPropertyInvalid) {
+        for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
+            if (m_parsedProperties[i].id() == CSSPropertyWebkitTextDecorationLine)
+                return;
+        }
+    }
+    addProperty(propId, value, important);
+}
+
+bool CSSParser::parseTextDecoration(CSSPropertyID propId, bool important)
+{
+    CSSParserValue* value = m_valueList->current();
+    if (value->id == CSSValueNone) {
+        addTextDecorationProperty(propId, cssValuePool().createExplicitInitialValue(), important);
+        m_valueList->next();
+        return true;
+    }
+
+    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+    bool isValid = true;
+    while (isValid && value) {
+        switch (value->id) {
+        case CSSValueBlink:
+            // Blink value is not accepted by -webkit-text-decoration-line.
+            isValid = propId != CSSPropertyWebkitTextDecorationLine;
+            break;
+        case CSSValueUnderline:
+        case CSSValueOverline:
+        case CSSValueLineThrough:
+            list->append(cssValuePool().createIdentifierValue(value->id));
+            break;
+        default:
+            isValid = false;
+            break;
+        }
+        if (isValid)
+            value = m_valueList->next();
+    }
+
+    if (list->length() && isValid) {
+        addTextDecorationProperty(propId, list.release(), important);
+        return true;
+    }
+
+    return false;
+}
+
 bool CSSParser::parseTextEmphasisStyle(bool important)
 {
     unsigned valueListSize = m_valueList->size();

Modified: trunk/Source/WebCore/css/CSSParser.h (125204 => 125205)


--- trunk/Source/WebCore/css/CSSParser.h	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/Source/WebCore/css/CSSParser.h	2012-08-09 21:49:36 UTC (rev 125205)
@@ -231,6 +231,9 @@
 
     bool parseTextEmphasisStyle(bool important);
 
+    void addTextDecorationProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important);
+    bool parseTextDecoration(CSSPropertyID propId, bool important);
+
     bool parseLineBoxContain(bool important);
     bool parseCalculation(CSSParserValue*, CalculationPermittedValueRange);
 

Modified: trunk/Source/WebCore/css/CSSProperty.cpp (125204 => 125205)


--- trunk/Source/WebCore/css/CSSProperty.cpp	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/Source/WebCore/css/CSSProperty.cpp	2012-08-09 21:49:36 UTC (rev 125205)
@@ -340,6 +340,7 @@
     case CSSPropertyWebkitPrintColorAdjust:
     case CSSPropertyWebkitRtlOrdering:
     case CSSPropertyWebkitTextCombine:
+    case CSSPropertyWebkitTextDecorationLine:
     case CSSPropertyWebkitTextDecorationsInEffect:
     case CSSPropertyWebkitTextEmphasis:
     case CSSPropertyWebkitTextEmphasisColor:

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (125204 => 125205)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2012-08-09 21:49:36 UTC (rev 125205)
@@ -351,6 +351,7 @@
 -webkit-rtl-ordering
 -webkit-text-combine
 -epub-text-combine = -webkit-text-combine
+-webkit-text-decoration-line
 -webkit-text-decorations-in-effect
 -webkit-text-emphasis
 -epub-text-emphasis = -webkit-text-emphasis

Modified: trunk/Source/WebCore/css/StyleBuilder.cpp (125204 => 125205)


--- trunk/Source/WebCore/css/StyleBuilder.cpp	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/Source/WebCore/css/StyleBuilder.cpp	2012-08-09 21:49:36 UTC (rev 125205)
@@ -1933,6 +1933,7 @@
     setPropertyHandler(CSSPropertyTabSize, ApplyPropertyDefault<unsigned, &RenderStyle::tabSize, unsigned, &RenderStyle::setTabSize, unsigned, &RenderStyle::initialTabSize>::createHandler());
     setPropertyHandler(CSSPropertyTextAlign, ApplyPropertyTextAlign::createHandler());
     setPropertyHandler(CSSPropertyTextDecoration, ApplyPropertyTextDecoration::createHandler());
+    setPropertyHandler(CSSPropertyWebkitTextDecorationLine, ApplyPropertyTextDecoration::createHandler());
     setPropertyHandler(CSSPropertyTextIndent, ApplyPropertyLength<&RenderStyle::textIndent, &RenderStyle::setTextIndent, &RenderStyle::initialTextIndent>::createHandler());
     setPropertyHandler(CSSPropertyTextOverflow, ApplyPropertyDefault<TextOverflow, &RenderStyle::textOverflow, TextOverflow, &RenderStyle::setTextOverflow, TextOverflow, &RenderStyle::initialTextOverflow>::createHandler());
     setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont<TextRenderingMode, &FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering>::createHandler());

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (125204 => 125205)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-08-09 21:35:55 UTC (rev 125204)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-08-09 21:49:36 UTC (rev 125205)
@@ -4399,6 +4399,7 @@
 #endif
     case CSSPropertyWebkitRtlOrdering:
     case CSSPropertyWebkitTextCombine:
+    case CSSPropertyWebkitTextDecorationLine:
     case CSSPropertyWebkitTextEmphasisColor:
     case CSSPropertyWebkitTextEmphasisPosition:
     case CSSPropertyWebkitTextEmphasisStyle:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to