Title: [95071] trunk
Revision
95071
Author
[email protected]
Date
2011-09-13 19:09:25 -0700 (Tue, 13 Sep 2011)

Log Message

Fix cssText property of counter-valued CSSPrimitiveValue and avoid uninitialized read
https://bugs.webkit.org/show_bug.cgi?id=68021

Reviewed by Tony Chang.

Source/WebCore:

Reported by valgrind in http://crbug.com/60653.

Besides fixing the uninitialized read, add support for outputting the
list separator for counters() calls and the list-style name.

Test: fast/css/counters/counter-cssText.html

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::cssText):

LayoutTests:

* fast/css/counters/counter-cssText-expected.txt: Added.
* fast/css/counters/counter-cssText.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (95070 => 95071)


--- trunk/LayoutTests/ChangeLog	2011-09-14 01:58:25 UTC (rev 95070)
+++ trunk/LayoutTests/ChangeLog	2011-09-14 02:09:25 UTC (rev 95071)
@@ -1,3 +1,13 @@
+2011-09-13  Adam Klein  <[email protected]>
+
+        Fix cssText property of counter-valued CSSPrimitiveValue and avoid uninitialized read
+        https://bugs.webkit.org/show_bug.cgi?id=68021
+
+        Reviewed by Tony Chang.
+
+        * fast/css/counters/counter-cssText-expected.txt: Added.
+        * fast/css/counters/counter-cssText.html: Added.
+
 2011-09-13  Kenichi Ishibashi  <[email protected]>
 
         WebFont followed tiny monospace text displays weird

Added: trunk/LayoutTests/fast/css/counters/counter-cssText-expected.txt (0 => 95071)


--- trunk/LayoutTests/fast/css/counters/counter-cssText-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/counters/counter-cssText-expected.txt	2011-09-14 02:09:25 UTC (rev 95071)
@@ -0,0 +1,13 @@
+Test the cssText output of counter-valued CSSPrimitiveValues
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rules[2].style.cssText is "content: counter(section, decimal); "
+PASS rules[3].style.cssText is "content: counters(section, ':', decimal); "
+PASS rules[4].style.cssText is "content: counter(section, lower-roman); "
+PASS rules[5].style.cssText is "content: counters(section, ',', upper-roman); "
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/css/counters/counter-cssText.html (0 => 95071)


--- trunk/LayoutTests/fast/css/counters/counter-cssText.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/counters/counter-cssText.html	2011-09-14 02:09:25 UTC (rev 95071)
@@ -0,0 +1,39 @@
+<html>
+<head>
+<link rel=stylesheet href=""
+<script src=""
+<style>
+body {
+    counter-reset: section;
+}
+h1 {
+    counter-increment: section;
+}
+h2:before {
+    content: counter(section);
+}
+h2:after {
+    content: counters(section, ":", decimal);
+}
+h3:before {
+    content: counter(section, lower-roman);
+}
+h3:after {
+    content: counters(section, ",", upper-roman);
+}
+</style>
+</head>
+<p id=description></p>
+<div id=console></div>
+<script>
+description("Test the cssText output of counter-valued CSSPrimitiveValues");
+var rules = document.styleSheets[1].cssRules;
+shouldBeEqualToString("rules[2].style.cssText", "content: counter(section, decimal); ");
+shouldBeEqualToString("rules[3].style.cssText", "content: counters(section, ':', decimal); ");
+shouldBeEqualToString("rules[4].style.cssText", "content: counter(section, lower-roman); ");
+shouldBeEqualToString("rules[5].style.cssText", "content: counters(section, ',', upper-roman); ");
+window.successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (95070 => 95071)


--- trunk/Source/WebCore/ChangeLog	2011-09-14 01:58:25 UTC (rev 95070)
+++ trunk/Source/WebCore/ChangeLog	2011-09-14 02:09:25 UTC (rev 95071)
@@ -1,3 +1,20 @@
+2011-09-13  Adam Klein  <[email protected]>
+
+        Fix cssText property of counter-valued CSSPrimitiveValue and avoid uninitialized read
+        https://bugs.webkit.org/show_bug.cgi?id=68021
+
+        Reviewed by Tony Chang.
+
+        Reported by valgrind in http://crbug.com/60653.
+
+        Besides fixing the uninitialized read, add support for outputting the
+        list separator for counters() calls and the list-style name.
+
+        Test: fast/css/counters/counter-cssText.html
+
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::cssText):
+
 2011-09-13  Kenichi Ishibashi  <[email protected]>
 
         WebFont followed tiny monospace text displays weird

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (95070 => 95071)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2011-09-14 01:58:25 UTC (rev 95070)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2011-09-14 02:09:25 UTC (rev 95071)
@@ -795,12 +795,22 @@
             text += m_value.string;
             text += ")";
             break;
-        case CSS_COUNTER:
-            text = "counter(";
-            text += String::number(m_value.num);
+        case CSS_COUNTER: {
+            String separator = m_value.counter->separator();
+            text = separator.isEmpty() ? "counter(" : "counters(";
+            text += m_value.counter->identifier();
+            if (!separator.isEmpty()) {
+                text += ", ";
+                text += quoteCSSStringIfNeeded(separator);
+            }
+            const char* listStyleName = getValueName(m_value.counter->listStyleNumber() + CSSValueDisc);
+            if (listStyleName) {
+                text += ", ";
+                text += listStyleName;
+            }
             text += ")";
-            // FIXME: Add list-style and separator
             break;
+        }
         case CSS_RECT: {
             DEFINE_STATIC_LOCAL(const String, rectParen, ("rect("));
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to