Title: [112321] trunk
Revision
112321
Author
[email protected]
Date
2012-03-27 15:01:03 -0700 (Tue, 27 Mar 2012)

Log Message

cssText should not generate literal 'initial' in shorthand properties
https://bugs.webkit.org/show_bug.cgi?id=82364

Reviewed by Antti Koivisto.

Source/WebCore: 

Fixed the bug by treating initial value as if the value is not set.
While this is incorrect for properties that inherits by default,
it's strictly better than generating unparsable value as we do today.

The proper fix is for CSSInitialValue::cssText to fetch the respective
default value from what's currently in CSSStyleSelector code but that requires
a considerable amount of refactoring and work.

* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::getShorthandValue):
(WebCore::StylePropertySet::getCommonValue):

LayoutTests: 

* fast/css/cssText-shorthand-expected.txt: Rebaselined.
* fast/css/cssText-shorthand.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (112320 => 112321)


--- trunk/LayoutTests/ChangeLog	2012-03-27 21:54:40 UTC (rev 112320)
+++ trunk/LayoutTests/ChangeLog	2012-03-27 22:01:03 UTC (rev 112321)
@@ -1,3 +1,13 @@
+2012-03-27  Ryosuke Niwa  <[email protected]>
+
+        cssText should not generate literal 'initial' in shorthand properties
+        https://bugs.webkit.org/show_bug.cgi?id=82364
+
+        Reviewed by Antti Koivisto.
+
+        * fast/css/cssText-shorthand-expected.txt: Rebaselined.
+        * fast/css/cssText-shorthand.html:
+
 2012-03-27  Dirk Pranke  <[email protected]>
 
         Change media/track/track-delete-during-startup bug #

Modified: trunk/LayoutTests/fast/css/cssText-shorthand-expected.txt (112320 => 112321)


--- trunk/LayoutTests/fast/css/cssText-shorthand-expected.txt	2012-03-27 21:54:40 UTC (rev 112320)
+++ trunk/LayoutTests/fast/css/cssText-shorthand-expected.txt	2012-03-27 22:01:03 UTC (rev 112321)
@@ -3,16 +3,16 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS normalizeCssText(element.style.cssText) is "border: 1px initial initial"
+PASS normalizeCssText(element.style.cssText) is "border: 1px"
 PASS normalizeCssText(element.style.cssText) is "border: 1px solid red"
-PASS normalizeCssText(element.style.cssText) is "border: 1px initial red"
-PASS normalizeCssText(element.style.cssText) is "border: initial initial red"
-PASS normalizeCssText(element.style.cssText) is "border: 1px initial initial"
+PASS normalizeCssText(element.style.cssText) is "border: 1px red"
+PASS normalizeCssText(element.style.cssText) is "border: red"
+PASS normalizeCssText(element.style.cssText) is "border: 1px"
 PASS normalizeCssText(element.style.cssText) is "border-bottom-width: 3px; border-left-width: 4px; border-right-width: 2px; border-top-width: 1px"
 PASS normalizeCssText(element.style.cssText) is "border-bottom-width: 1px; border-left-width: 1px; border-right-width: 1px; border-top-width: 2px"
 PASS normalizeCssText(element.style.cssText) is "border-bottom-width: 1px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px !important"
 PASS normalizeCssText(element.style.cssText) is "border-bottom-width: 1px; border-left-width: 1px; border-right-width: 1px; border-top-color: red; border-top-width: 1px"
-PASS normalizeCssText(element.style.cssText) is "border: initial dotted initial"
+PASS normalizeCssText(element.style.cssText) is "border: dotted"
 PASS normalizeCssText(element.style.cssText) is "border-spacing: 1px 2px"
 PASS normalizeCssText(element.style.cssText) is "font-family: sans-serif; font-size: 3em; font-style: italic; font-weight: bold; line-height: 2em"
 PASS normalizeCssText(element.style.cssText) is "list-style: circle inside"

Modified: trunk/LayoutTests/fast/css/cssText-shorthand.html (112320 => 112321)


--- trunk/LayoutTests/fast/css/cssText-shorthand.html	2012-03-27 21:54:40 UTC (rev 112320)
+++ trunk/LayoutTests/fast/css/cssText-shorthand.html	2012-03-27 22:01:03 UTC (rev 112321)
@@ -8,11 +8,11 @@
 
 var tests = [
     // FIXME: This exhibits a bug. We shouldn't be outputing border-image here.
-    ['border: 1px; border-top: 1px;', 'border: 1px initial initial;'],
+    ['border: 1px; border-top: 1px;', 'border: 1px;'],
     ['border: 1px solid red;', 'border: 1px solid red;'],
-    ['border: 1px red;', 'border: 1px initial red;'],
-    ['border: red;', 'border: initial initial red;'],
-    ['border-top: 1px; border-right: 1px; border-bottom: 1px; border-left: 1px;', 'border: 1px initial initial;'],
+    ['border: 1px red;', 'border: 1px red;'],
+    ['border: red;', 'border: red;'],
+    ['border-top: 1px; border-right: 1px; border-bottom: 1px; border-left: 1px;', 'border: 1px;'],
     ['border-top: 1px; border-right: 2px; border-bottom: 3px; border-left: 4px;',
     'border-top-width: 1px; border-right-width: 2px; border-bottom-width: 3px; border-left-width: 4px;'],
     ['border: 1px; border-top: 2px;',
@@ -21,7 +21,7 @@
     'border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-width: 1px !important;'],
     ['border: 1px; border-top-color: red;',
     'border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-width: 1px; border-top-color: red;'],
-    ['border: solid; border-style: dotted', 'border: initial dotted initial;'],
+    ['border: solid; border-style: dotted', 'border: dotted;'],
 
     ['-webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 2px;', 'border-spacing: 1px 2px;'],
 

Modified: trunk/Source/WebCore/ChangeLog (112320 => 112321)


--- trunk/Source/WebCore/ChangeLog	2012-03-27 21:54:40 UTC (rev 112320)
+++ trunk/Source/WebCore/ChangeLog	2012-03-27 22:01:03 UTC (rev 112321)
@@ -1,3 +1,22 @@
+2012-03-27  Ryosuke Niwa  <[email protected]>
+
+        cssText should not generate literal 'initial' in shorthand properties
+        https://bugs.webkit.org/show_bug.cgi?id=82364
+
+        Reviewed by Antti Koivisto.
+
+        Fixed the bug by treating initial value as if the value is not set.
+        While this is incorrect for properties that inherits by default,
+        it's strictly better than generating unparsable value as we do today.
+
+        The proper fix is for CSSInitialValue::cssText to fetch the respective
+        default value from what's currently in CSSStyleSelector code but that requires
+        a considerable amount of refactoring and work.
+
+        * css/StylePropertySet.cpp:
+        (WebCore::StylePropertySet::getShorthandValue):
+        (WebCore::StylePropertySet::getCommonValue):
+
 2012-03-26  Adam Klein  <[email protected]>
 
         Always set V8 wrappers via V8DOMWrapper::setJSWrapperFor* instead of WeakReferenceMap::set()

Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (112320 => 112321)


--- trunk/Source/WebCore/css/StylePropertySet.cpp	2012-03-27 21:54:40 UTC (rev 112320)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp	2012-03-27 22:01:03 UTC (rev 112321)
@@ -382,8 +382,8 @@
     for (unsigned i = 0; i < longhand.length(); ++i) {
         if (!isPropertyImplicit(longhand.properties()[i])) {
             RefPtr<CSSValue> value = getPropertyCSSValue(longhand.properties()[i]);
-            // FIXME: provide default value if !value
-            if (value) {
+            // FIXME: provide default value if !value or value is initial value
+            if (value && !value->isInitialValue()) {
                 if (!res.isNull())
                     res += " ";
                 res += value->cssText();
@@ -399,7 +399,8 @@
     String res;
     for (unsigned i = 0; i < longhand.length(); ++i) {
         RefPtr<CSSValue> value = getPropertyCSSValue(longhand.properties()[i]);
-        if (!value)
+        // FIXME: CSSInitialValue::cssText should generate the right value.
+        if (!value || value->isInitialValue())
             return String();
         String text = value->cssText();
         if (text.isNull())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to