Title: [176369] trunk
Revision
176369
Author
[email protected]
Date
2014-11-19 17:02:12 -0800 (Wed, 19 Nov 2014)

Log Message

Move the 'quotes' CSS property to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=138788

Reviewed by Chris Dumez.

Source/WebCore:

Test: fast/css/content/content-quotes-07.html

* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
Fix the parser to only accept none as a valid primitive identifier. Tested in 
the newly added content-quotes-07.html.

* css/CSSPropertyNames.in:
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertQuotes):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
Move "quotes" to the new style builder.

* rendering/style/RenderStyle.h:
Add an initialQuotes() function for use in the auto-generated style builder.

LayoutTests:

Add a test for the behavior of non-valid primitive identifiers being
used with the quotes property.

* fast/css/content/content-quotes-07-expected.txt: Added.
* fast/css/content/content-quotes-07.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (176368 => 176369)


--- trunk/LayoutTests/ChangeLog	2014-11-20 00:59:09 UTC (rev 176368)
+++ trunk/LayoutTests/ChangeLog	2014-11-20 01:02:12 UTC (rev 176369)
@@ -1,3 +1,16 @@
+2014-11-16  Sam Weinig  <[email protected]>
+
+        Move the 'quotes' CSS property to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=138788
+
+        Reviewed by Chris Dumez.
+
+        Add a test for the behavior of non-valid primitive identifiers being
+        used with the quotes property.
+
+        * fast/css/content/content-quotes-07-expected.txt: Added.
+        * fast/css/content/content-quotes-07.html: Added.
+
 2014-11-19  Dean Jackson  <[email protected]>
 
         Handle unprefixed @keyframes rule

Added: trunk/LayoutTests/fast/css/content/content-quotes-07-expected.txt (0 => 176369)


--- trunk/LayoutTests/fast/css/content/content-quotes-07-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/content/content-quotes-07-expected.txt	2014-11-20 01:02:12 UTC (rev 176369)
@@ -0,0 +1,11 @@
+The texts between the markers should be identical.
+
+========Marker1========
+
+ab	1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+========Marker2========
+
+WWaWWbWWWWWWWW	1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+========Marker3========
+
+PASSED

Copied: trunk/LayoutTests/fast/css/content/content-quotes-07.html (from rev 176166, trunk/LayoutTests/fast/css/content/content-quotes-01.html) (0 => 176369)


--- trunk/LayoutTests/fast/css/content/content-quotes-07.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/content/content-quotes-07.html	2014-11-20 01:02:12 UTC (rev 176369)
@@ -0,0 +1,45 @@
+<html>
+    <head>
+        <style type="text/css">
+            body { quotes: "WW" "WWWW"; }
+            body { quotes: baseline; } /* This should be ignored, as "baseline" is not a vaild value for quotes */
+        </style>
+        <script type="text/_javascript_">
+            if (window.testRunner) {
+                testRunner.dumpAsText();
+                testRunner.waitUntilDone();
+            }
+
+            function run() {
+                testWidth = window.getComputedStyle(document.getElementById("testContainer"), null).getPropertyValue("width");
+                referenceWidth = window.getComputedStyle(document.getElementById("reference"), null).getPropertyValue("width");
+                if (testWidth == referenceWidth)
+                    document.getElementById("console").innerText = "PASSED";
+                else
+                    document.getElementById("console").innerText = "FAILED: testWidth=" + testWidth +"; expected " + referenceWidth;
+               if (window.testRunner)
+                    testRunner.notifyDone();
+           }
+        </script>
+    </head>
+
+    <body _onload_="setTimeout('run()', 0);">
+        <p id="onlyInBrowser">The texts between the markers should be identical.</p>
+        <p>========Marker1========</p>
+        <table>
+            <tr>
+                <td id="testContainer"><q>a<q>b</q></q></td>
+                <td>1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1</td>
+            </tr>
+        </table>
+        <p>========Marker2========</p>
+        <table>
+            <tr>
+                <td id="reference">WWaWWbWWWWWWWW</td>
+                <td>1 1 1 1 1 1 1 1 1 1 1  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1</td>
+            </tr>
+        </table>
+        <p>========Marker3========</p>
+        <pre id="console"/>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (176368 => 176369)


--- trunk/Source/WebCore/ChangeLog	2014-11-20 00:59:09 UTC (rev 176368)
+++ trunk/Source/WebCore/ChangeLog	2014-11-20 01:02:12 UTC (rev 176369)
@@ -1,3 +1,27 @@
+2014-11-16  Sam Weinig  <[email protected]>
+
+        Move the 'quotes' CSS property to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=138788
+
+        Reviewed by Chris Dumez.
+
+        Test: fast/css/content/content-quotes-07.html
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        Fix the parser to only accept none as a valid primitive identifier. Tested in 
+        the newly added content-quotes-07.html.
+
+        * css/CSSPropertyNames.in:
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::convertQuotes):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyProperty):
+        Move "quotes" to the new style builder.
+
+        * rendering/style/RenderStyle.h:
+        Add an initialQuotes() function for use in the auto-generated style builder.
+
 2014-11-19  Dean Jackson  <[email protected]>
 
         Handle unprefixed @keyframes rule

Modified: trunk/Source/WebCore/css/CSSParser.cpp (176368 => 176369)


--- trunk/Source/WebCore/css/CSSParser.cpp	2014-11-20 00:59:09 UTC (rev 176368)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2014-11-20 01:02:12 UTC (rev 176369)
@@ -1850,7 +1850,7 @@
         return parseSize(propId, important);
 
     case CSSPropertyQuotes:               // [<string> <string>]+ | none | inherit
-        if (id)
+        if (id == CSSValueNone)
             validPrimitive = true;
         else
             return parseQuotes(propId, important);

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (176368 => 176369)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2014-11-20 00:59:09 UTC (rev 176368)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2014-11-20 01:02:12 UTC (rev 176369)
@@ -220,7 +220,7 @@
 paint-order
 pointer-events [Inherited, NewStyleBuilder]
 position [NewStyleBuilder]
-quotes [Inherited]
+quotes [Inherited, NewStyleBuilder, Converter=Quotes]
 resize [Inherited, NewStyleBuilder, Converter=Resize]
 right [NewStyleBuilder, Initial=initialOffset, Converter=LengthOrAuto]
 size [NewStyleBuilder, Custom=All]

Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (176368 => 176369)


--- trunk/Source/WebCore/css/StyleBuilderConverter.h	2014-11-20 00:59:09 UTC (rev 176368)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h	2014-11-20 01:02:12 UTC (rev 176369)
@@ -32,6 +32,7 @@
 #include "CSSPrimitiveValue.h"
 #include "Length.h"
 #include "Pair.h"
+#include "QuotesData.h"
 #include "Settings.h"
 #include "StyleResolver.h"
 #include "TransformFunctions.h"
@@ -65,6 +66,7 @@
     static EResize convertResize(StyleResolver&, CSSValue&);
     static int convertMarqueeRepetition(StyleResolver&, CSSValue&);
     static int convertMarqueeSpeed(StyleResolver&, CSSValue&);
+    static PassRefPtr<QuotesData> convertQuotes(StyleResolver&, CSSValue&);
     static TextUnderlinePosition convertTextUnderlinePosition(StyleResolver&, CSSValue&);
 
 private:
@@ -429,6 +431,29 @@
     return speed;
 }
 
+inline PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolver&, CSSValue& value)
+{
+    if (is<CSSPrimitiveValue>(value)) {
+        ASSERT(downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueNone);
+        return QuotesData::create(Vector<std::pair<String, String>>());
+    }
+
+    CSSValueList& list = downcast<CSSValueList>(value);
+    Vector<std::pair<String, String>> quotes;
+    quotes.reserveInitialCapacity(list.length() / 2);
+    for (unsigned i = 0; i < list.length(); i += 2) {
+        CSSValue* first = list.itemWithoutBoundsCheck(i);
+        // item() returns null if out of bounds so this is safe.
+        CSSValue* second = list.item(i + 1);
+        if (!second)
+            break;
+        String startQuote = downcast<CSSPrimitiveValue>(*first).getStringValue();
+        String endQuote = downcast<CSSPrimitiveValue>(*second).getStringValue();
+        quotes.append(std::make_pair(startQuote, endQuote));
+    }
+    return QuotesData::create(quotes);
+}
+
 inline TextUnderlinePosition StyleBuilderConverter::convertTextUnderlinePosition(StyleResolver&, CSSValue& value)
 {
     // This is true if value is 'auto' or 'alphabetic'.

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (176368 => 176369)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2014-11-20 00:59:09 UTC (rev 176368)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2014-11-20 01:02:12 UTC (rev 176369)
@@ -2265,37 +2265,6 @@
                 state.style()->setContentAltText(emptyAtom);
             return;
         }
-        
-    case CSSPropertyQuotes:
-        if (isInherit) {
-            state.style()->setQuotes(state.parentStyle()->quotes());
-            return;
-        }
-        if (isInitial) {
-            state.style()->setQuotes(nullptr);
-            return;
-        }
-        if (is<CSSValueList>(*value)) {
-            CSSValueList& list = downcast<CSSValueList>(*value);
-            Vector<std::pair<String, String>> quotes;
-            for (size_t i = 0; i < list.length(); i += 2) {
-                CSSValue* first = list.itemWithoutBoundsCheck(i);
-                // item() returns null if out of bounds so this is safe.
-                CSSValue* second = list.item(i + 1);
-                if (!second)
-                    continue;
-                String startQuote = downcast<CSSPrimitiveValue>(*first).getStringValue();
-                String endQuote = downcast<CSSPrimitiveValue>(*second).getStringValue();
-                quotes.append(std::make_pair(startQuote, endQuote));
-            }
-            state.style()->setQuotes(QuotesData::create(quotes));
-            return;
-        }
-        if (primitiveValue) {
-            if (primitiveValue->getValueID() == CSSValueNone)
-                state.style()->setQuotes(QuotesData::create(Vector<std::pair<String, String>>()));
-        }
-        return;
     // Shorthand properties.
     case CSSPropertyFont:
         if (isInherit) {
@@ -3065,6 +3034,7 @@
     case CSSPropertyPageBreakInside:
     case CSSPropertyPointerEvents:
     case CSSPropertyPosition:
+    case CSSPropertyQuotes:
     case CSSPropertyResize:
     case CSSPropertyRight:
     case CSSPropertySize:

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (176368 => 176369)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2014-11-20 00:59:09 UTC (rev 176368)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2014-11-20 01:02:12 UTC (rev 176369)
@@ -1949,6 +1949,7 @@
     static StyleImage* initialBorderImageSource() { return 0; }
     static StyleImage* initialMaskBoxImageSource() { return 0; }
     static PrintColorAdjust initialPrintColorAdjust() { return PrintColorAdjustEconomy; }
+    static QuotesData* initialQuotes() { return nullptr; }
 
 #if ENABLE(CSS_SCROLL_SNAP)
     static ScrollSnapType initialScrollSnapType() { return ScrollSnapType::None; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to