Title: [112177] trunk
Revision
112177
Author
[email protected]
Date
2012-03-26 16:59:27 -0700 (Mon, 26 Mar 2012)

Log Message

cssText should use shorthand notations
https://bugs.webkit.org/show_bug.cgi?id=81737

Reviewed by Enrica Casucci.

Source/_javascript_Core: 

Export symbols of BitVector on Windows.

* _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:

Source/WebCore: 

Use shorthand properties to serialize style properties for cssText.

The overall algorithm is to look for any property that has a shorthand, and then check if
the shorthand value could be obtained (the condition is quite complicated for border properties).
If it could, then append that value to the string builder, and set the corresponding entries in
shorthandPropertyAppeared and shorthandPropertyUsed. If not, only turn on the bit in
shorthandPropertyAppeared on to avoid calling getPropertyValue again for longhand properties
that use the same shorthand property when we cannot use the shorthand.

Test: fast/css/cssText-shorthand.html

* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::asText):

Source/WTF: 

* wtf/BitVector.h:
(BitVector):
(WTF::BitVector::ensureSizeAndSet): Added.

LayoutTests: 

Rebaseline existing tests and add a regression test for unprefixed CSS properties with
the exception of -webkit-border-horizontal/vertical-spacing (the shorthand version of
these properties (border-spacing) is unprefixed.

* editing/pasteboard/paste-and-sanitize-expected.txt: Uses border instead of longhand
properties as desired.
* editing/pasteboard/paste-and-sanitize.html:
* editing/style/non-inheritable-styles-expected.txt: Ditto.
* fast/css/background-position-serialize-expected.txt: No longer emits "background-*:
initial" as desired.
* fast/css/cssText-shorthand-expected.txt: Added.
* fast/css/cssText-shorthand.html: Added.
* fast/css/remove-shorthand-expected.txt:
* fast/css/remove-shorthand.html: Modified to do elaborative comparison of the lists of
properties before and after removing a shorthand since now removing a shorthand property
may end up adding new longhand property.
* fast/css/uri-token-parsing-expected.txt:
* fast/css/uri-token-parsing.html: Uses shorthand properties instead of longhand equivalents.
* inspector/styles/styles-update-from-js-expected.txt: Ditto.
* printing/page-rule-css-text-expected.txt: Ditto.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (112176 => 112177)


--- trunk/LayoutTests/ChangeLog	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/ChangeLog	2012-03-26 23:59:27 UTC (rev 112177)
@@ -1,3 +1,31 @@
+2012-03-23  Ryosuke Niwa  <[email protected]>
+
+        cssText should use shorthand notations
+        https://bugs.webkit.org/show_bug.cgi?id=81737
+
+        Reviewed by Enrica Casucci.
+
+        Rebaseline existing tests and add a regression test for unprefixed CSS properties with
+        the exception of -webkit-border-horizontal/vertical-spacing (the shorthand version of
+        these properties (border-spacing) is unprefixed.
+
+        * editing/pasteboard/paste-and-sanitize-expected.txt: Uses border instead of longhand
+        properties as desired.
+        * editing/pasteboard/paste-and-sanitize.html:
+        * editing/style/non-inheritable-styles-expected.txt: Ditto.
+        * fast/css/background-position-serialize-expected.txt: No longer emits "background-*:
+        initial" as desired.
+        * fast/css/cssText-shorthand-expected.txt: Added.
+        * fast/css/cssText-shorthand.html: Added.
+        * fast/css/remove-shorthand-expected.txt:
+        * fast/css/remove-shorthand.html: Modified to do elaborative comparison of the lists of
+        properties before and after removing a shorthand since now removing a shorthand property
+        may end up adding new longhand property.
+        * fast/css/uri-token-parsing-expected.txt:
+        * fast/css/uri-token-parsing.html: Uses shorthand properties instead of longhand equivalents.
+        * inspector/styles/styles-update-from-js-expected.txt: Ditto.
+        * printing/page-rule-css-text-expected.txt: Ditto.
+
 2012-03-26  Emil A Eklund  <[email protected]>
 
         Unreviewed test_expectations update for chromium.

Modified: trunk/LayoutTests/editing/pasteboard/paste-and-sanitize-expected.txt (112176 => 112177)


--- trunk/LayoutTests/editing/pasteboard/paste-and-sanitize-expected.txt	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/editing/pasteboard/paste-and-sanitize-expected.txt	2012-03-26 23:59:27 UTC (rev 112177)
@@ -8,7 +8,7 @@
 PASS confirmedMarkup is '<div style="text-align: center;"><b>Hello</b></div>'
 PASS confirmedMarkup is '<div><b><i>hello</i></b></div><div><b><i>world</i></b></div>'
 PASS confirmedMarkup is '<b><i><span style="font-weight: normal; "><b><i>hello1</i></b><b><i>&nbsp;hello2</i></b></span></i></b>'
-PASS confirmedMarkup is '<i style="margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; "><b><i style="margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; ">hello</i></b></i>'
+FAIL confirmedMarkup should be <i style="margin: 10px; ">hello</i></b></i>. Was <i style="margin: 10px; "><b><i style="margin: 10px; ">hello</i></b></i>.
 PASS confirmedMarkup is '<b><i>Hello&nbsp;world</i></b>'
 PASS confirmedMarkup is '<b><i><span style="font-weight: normal; ">plain text<b><i>bold italic text</i></b></span></i></b>'
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/editing/pasteboard/paste-and-sanitize.html (112176 => 112177)


--- trunk/LayoutTests/editing/pasteboard/paste-and-sanitize.html	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/editing/pasteboard/paste-and-sanitize.html	2012-03-26 23:59:27 UTC (rev 112177)
@@ -44,7 +44,7 @@
           "<div><b><i>hello</i></b></div><div><b><i>world</i></b></div>");
 testPaste("div", "<div><b><i><span style=\"font-weight: normal; \"><b><i>hello1</i></b><b><i> hello2</i></b></span></i></b></div>", "<b><i><span style=\"font-weight: normal; \"><b><i>hello1</i></b><b><i>&nbsp;hello2</i></b></span></i></b>");
 testPaste("div", "<i style=\"margin: 10px;\"><b><i style=\"margin: 10px;\">hello</i></b></i>",
-          "<i style=\"margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; \"><b><i style=\"margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; \">hello</i></b></i>");
+          "<i style=\"margin: 10px; \">hello</i></b></i>");
 testPaste("div", "<div><b><i><span style=\"font-weight: normal\"><b><i>Hello <!-- comment -->world</i></b></span></i></b></div>", "<b><i>Hello&nbsp;world</i></b>");
 testPaste("div", "<div><b><i><span style=\"font-weight: normal\">plain text<b><i>bold italic text</i></b></span></i></b></div>", "<b><i><span style=\"font-weight: normal; \">plain text<b><i>bold italic text</i></b></span></i></b>");
 

Modified: trunk/LayoutTests/editing/style/non-inheritable-styles-expected.txt (112176 => 112177)


--- trunk/LayoutTests/editing/style/non-inheritable-styles-expected.txt	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/editing/style/non-inheritable-styles-expected.txt	2012-03-26 23:59:27 UTC (rev 112177)
@@ -3,6 +3,6 @@
 | <div>
 |   class="class"
 |   id="id"
-|   style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: blue; border-right-color: blue; border-bottom-color: blue; border-left-color: blue; border-image: initial; "
+|   style="border: 1px solid blue; "
 |   "This should have blue border when its pasted."
 | "This shouldn't have a border.<#selection-caret>"

Modified: trunk/LayoutTests/fast/css/background-position-serialize-expected.txt (112176 => 112177)


--- trunk/LayoutTests/fast/css/background-position-serialize-expected.txt	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/fast/css/background-position-serialize-expected.txt	2012-03-26 23:59:27 UTC (rev 112177)
@@ -59,4 +59,4 @@
 t.setAttribute('style', 'background: url(about:blank) 80% 80%;');
 t.style.backgroundPositionY = '50px'
 style.cssText =
-background-image: url(about:blank); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 80% 50px; background-repeat: initial initial;
+background-image: url(about:blank); background-position: 80% 50px; background-repeat: initial initial;

Added: trunk/LayoutTests/fast/css/cssText-shorthand-expected.txt (0 => 112177)


--- trunk/LayoutTests/fast/css/cssText-shorthand-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/cssText-shorthand-expected.txt	2012-03-26 23:59:27 UTC (rev 112177)
@@ -0,0 +1,26 @@
+This test ensures WebKit uses shorthand notations for cssText
+
+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 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-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-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"
+PASS normalizeCssText(element.style.cssText) is "margin: 1px 2px 3px 4px"
+PASS normalizeCssText(element.style.cssText) is "outline: 2px dotted blue"
+FAIL normalizeCssText(element.style.cssText) should be overflow: scroll hidden. Was overflow-x: scroll; overflow-y: hidden.
+PASS normalizeCssText(element.style.cssText) is "padding: 1px 2px 3px 4px"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/css/cssText-shorthand.html (0 => 112177)


--- trunk/LayoutTests/fast/css/cssText-shorthand.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/cssText-shorthand.html	2012-03-26 23:59:27 UTC (rev 112177)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+
+description("This test ensures WebKit uses shorthand notations for cssText");
+
+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 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-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;',
+    'border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-width: 2px;'],
+    ['border: 1px; border-top: 1px !important;',
+    '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;'],
+
+    ['-webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 2px;', 'border-spacing: 1px 2px;'],
+
+    // We don't use shorthand for font-family, etc... for compatibility reasons
+    ['font-family: sans-serif; line-height: 2em; font-size: 3em; font-style: italic; font-weight: bold;',
+        'font-family: sans-serif; line-height: 2em; font-size: 3em; font-style: italic; font-weight: bold;'],
+
+    ['list-style-type: circle; list-style-position: inside;', 'list-style: circle inside;'],
+    ['margin-top: 1px; margin-right: 2px; margin-bottom: 3px; margin-left: 4px;', 'margin: 1px 2px 3px 4px;'],
+    ['outline-width: 2px; outline-style: dotted; outline-color: blue;', 'outline: 2px dotted blue;'],
+    ['overflow-x: scroll; overflow-y: hidden;', 'overflow: scroll hidden;'],
+    ['padding-top: 1px; padding-right: 2px; padding-bottom: 3px; padding-left: 4px;', 'padding: 1px 2px 3px 4px;'],
+];
+
+function normalizeCssText(text) { return text.trim().split(/;\s*/).sort().slice(1).join("; "); }
+
+var element;
+tests.forEach(function (test) {
+    var styleAttribute = test[0];
+    var expectedCssText = test[1];
+
+    element = document.createElement('div');
+    element.setAttribute('style', styleAttribute);
+
+    shouldBe('normalizeCssText(element.style.cssText)', '"' + normalizeCssText(expectedCssText) + '"');
+});
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/fast/css/remove-shorthand-expected.txt (112176 => 112177)


--- trunk/LayoutTests/fast/css/remove-shorthand-expected.txt	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/fast/css/remove-shorthand-expected.txt	2012-03-26 23:59:27 UTC (rev 112177)
@@ -2,27 +2,75 @@
 
 Starting with a declaration containing all properties that are constituents of shortcuts, see what is removed when a shortcut property is removed. The shortcut’s constituents and only them should be removed.
 
-Removing background removes background-image, background-attachment, background-origin, background-clip, background-color, background-position, background-repeat.
-Removing background-position removes background-position.
-Removing border removes border-top-width, border-right-width, border-bottom-width, border-left-width, border-top-style, border-right-style, border-bottom-style, border-left-style, border-top-color, border-right-color, border-bottom-color, border-left-color.
-Removing border-top removes border-top-width, border-top-style, border-top-color.
-Removing border-right removes border-right-width, border-right-style, border-right-color.
-Removing border-bottom removes border-bottom-width, border-bottom-style, border-bottom-color.
-Removing border-left removes border-left-width, border-left-style, border-left-color.
-Removing border-color removes border-top-color, border-right-color, border-bottom-color, border-left-color.
-Removing border-style removes border-top-style, border-right-style, border-bottom-style, border-left-style.
-Removing border-width removes border-top-width, border-right-width, border-bottom-width, border-left-width.
-Removing border-radius removes border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius.
-Removing -webkit-border-radius removes border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius.
-Removing border-spacing removes -webkit-border-horizontal-spacing, -webkit-border-vertical-spacing.
-Removing -webkit-columns removes -webkit-column-width, -webkit-column-count.
-Removing -webkit-column-rule removes -webkit-column-rule-width, -webkit-column-rule-style, -webkit-column-rule-color.
-Removing list-style removes list-style-type, list-style-position, list-style-image.
-Removing margin removes margin-top, margin-right, margin-bottom, margin-left.
-Removing -webkit-margin-collapse removes -webkit-margin-before-collapse, -webkit-margin-after-collapse.
-Removing -webkit-marquee removes -webkit-marquee-direction, -webkit-marquee-increment, -webkit-marquee-repetition, -webkit-marquee-style, -webkit-marquee-speed.
-Removing -webkit-mask removes -webkit-mask-image, -webkit-mask-repeat-x, -webkit-mask-repeat-y, -webkit-mask-attachment, -webkit-mask-position-x, -webkit-mask-position-y, -webkit-mask-origin, -webkit-mask-clip.
-Removing -webkit-mask-position removes -webkit-mask-position-x, -webkit-mask-position-y.
-Removing overflow removes overflow-x, overflow-y.
-Removing padding removes padding-top, padding-right, padding-bottom, padding-left.
-Removing -webkit-text-stroke removes -webkit-text-stroke-color, -webkit-text-stroke-width.
+Removing background
+removes "background-image, background-attachment, background-color, background-position, background-repeat"
+and adds "".
+Removing background-position
+removes "background-position"
+and adds "".
+Removing border
+removes "border"
+and adds "".
+Removing border-top
+removes "border"
+and adds "border-right-width, border-bottom-width, border-left-width, border-right-style, border-bottom-style, border-left-style, border-right-color, border-bottom-color, border-left-color".
+Removing border-right
+removes "border"
+and adds "border-top-width, border-bottom-width, border-left-width, border-top-style, border-bottom-style, border-left-style, border-top-color, border-bottom-color, border-left-color".
+Removing border-bottom
+removes "border"
+and adds "border-top-width, border-right-width, border-left-width, border-top-style, border-right-style, border-left-style, border-top-color, border-right-color, border-left-color".
+Removing border-left
+removes "border"
+and adds "border-top-width, border-right-width, border-bottom-width, border-top-style, border-right-style, border-bottom-style, border-top-color, border-right-color, border-bottom-color".
+Removing border-color
+removes "border"
+and adds "border".
+Removing border-style
+removes "border"
+and adds "border".
+Removing border-width
+removes "border"
+and adds "border".
+Removing border-radius
+removes "border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius"
+and adds "".
+Removing -webkit-border-radius
+removes "border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius"
+and adds "".
+Removing border-spacing
+removes "border-spacing"
+and adds "".
+Removing -webkit-columns
+removes "-webkit-column-width, -webkit-column-count"
+and adds "".
+Removing -webkit-column-rule
+removes "-webkit-column-rule-width, -webkit-column-rule-style, -webkit-column-rule-color"
+and adds "".
+Removing list-style
+removes "list-style-type, list-style-position, list-style-image"
+and adds "".
+Removing margin
+removes "margin"
+and adds "".
+Removing -webkit-margin-collapse
+removes "-webkit-margin-before-collapse, -webkit-margin-after-collapse"
+and adds "".
+Removing -webkit-marquee
+removes "-webkit-marquee-direction, -webkit-marquee-increment, -webkit-marquee-repetition, -webkit-marquee-style, -webkit-marquee-speed"
+and adds "".
+Removing -webkit-mask
+removes "-webkit-mask"
+and adds "".
+Removing -webkit-mask-position
+removes "-webkit-mask"
+and adds "-webkit-mask".
+Removing overflow
+removes "overflow"
+and adds "".
+Removing padding
+removes "padding"
+and adds "".
+Removing -webkit-text-stroke
+removes "-webkit-text-stroke-color, -webkit-text-stroke-width"
+and adds "".

Modified: trunk/LayoutTests/fast/css/remove-shorthand.html (112176 => 112177)


--- trunk/LayoutTests/fast/css/remove-shorthand.html	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/fast/css/remove-shorthand.html	2012-03-26 23:59:27 UTC (rev 112177)
@@ -30,14 +30,19 @@
             element.style.removeProperty(shorthand);
             var remainingProperties = element.style.cssText.split("; ");
             var removedProperties = [];
-            var p;
-            while (p = allProperties.shift()) {
-                if (remainingProperties[0] == p)
-                    remainingProperties.shift();
-                else
-                    removedProperties.push("<tt>" + p.replace(/\:.*/,"") + "</tt>");
+            var addedProperties = [];
+
+            for (var i = 0; i < allProperties.length; i++) {
+                if (remainingProperties.indexOf(allProperties[i]) < 0)
+                    removedProperties.push("<tt>" + allProperties[i].replace(/\:.*/,"") + "</tt>");
             }
-            log("Removing <tt>" + shorthand + "</tt> removes " + removedProperties.join(", ") +".");
+            for (var i = 0; i < remainingProperties.length; i++) {
+                if (allProperties.indexOf(remainingProperties[i]) < 0)
+                    addedProperties.push("<tt>" + remainingProperties[i].replace(/\:.*/,"") + "</tt>");
+            }
+
+            log("Removing <tt>" + shorthand + '</tt><br>removes "' + removedProperties.join(", ")
+                + '"<br>and adds "' + addedProperties.join(", ") + '".');
         }
         
         function test()

Modified: trunk/LayoutTests/fast/css/uri-token-parsing-expected.txt (112176 => 112177)


--- trunk/LayoutTests/fast/css/uri-token-parsing-expected.txt	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/fast/css/uri-token-parsing-expected.txt	2012-03-26 23:59:27 UTC (rev 112177)
@@ -19,9 +19,9 @@
 #o { content: url(f); }
 #p { content: url('url(g)'); }
 #q { cursor: url('url(q)'); }
-#r { list-style-image: url('url(r)'); }
+#r { list-style: url('url(r)'); }
 #s { background-image: url('url(s)'); }
-#t { -webkit-mask-image: url('url(t)'); }
+#t { -webkit-mask: url('url(t)'); }
 #u { -webkit-border-image: url('url(u)') 1 2 3 4 fill stretch round; }
 #v { -webkit-mask-box-image: url('url(v)') 1 2 3 4 fill stretch round; }
 #w { content: url(ww); }
@@ -44,9 +44,9 @@
 #o { content: url(f); }
 #p { content: url('url(g)'); }
 #q { cursor: url('url(q)'); }
-#r { list-style-image: url('url(r)'); }
+#r { list-style: url('url(r)'); }
 #s { background-image: url('url(s)'); }
-#t { -webkit-mask-image: url('url(t)'); }
+#t { -webkit-mask: url('url(t)'); }
 #u { -webkit-border-image: url('url(u)') 1 2 3 4 fill stretch round; }
 #v { -webkit-mask-box-image: url('url(v)') 1 2 3 4 fill stretch round; }
 #w { content: url(ww); }

Modified: trunk/LayoutTests/fast/css/uri-token-parsing.html (112176 => 112177)


--- trunk/LayoutTests/fast/css/uri-token-parsing.html	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/fast/css/uri-token-parsing.html	2012-03-26 23:59:27 UTC (rev 112177)
@@ -93,9 +93,9 @@
 #o { content: url(f); }
 #p { content: url('url(g)'); }
 #q { cursor: url('url(q)'); }
-#r { list-style-image: url('url(r)'); }
+#r { list-style: url('url(r)'); }
 #s { background-image: url('url(s)'); }
-#t { -webkit-mask-image: url('url(t)'); }
+#t { -webkit-mask: url('url(t)'); }
 #u { -webkit-border-image: url('url(u)') 1 2 3 4 fill stretch round; }
 #v { -webkit-mask-box-image: url('url(v)') 1 2 3 4 fill stretch round; }
 #w { content: url(ww); }

Modified: trunk/LayoutTests/inspector/styles/styles-update-from-js-expected.txt (112176 => 112177)


--- trunk/LayoutTests/inspector/styles/styles-update-from-js-expected.txt	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/inspector/styles/styles-update-from-js-expected.txt	2012-03-26 23:59:27 UTC (rev 112177)
@@ -33,7 +33,7 @@
 
 
 Running: testSetViaParsedAttributes
-<div id="container" style="color: rgb(192, 255, 238); border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: green; border-right-color: green; border-bottom-color: green; border-left-color: green; border-image: initial; border-top-width: 3px; border-right-width: 3px; border-bottom-width: 3px; border-left-width: 3px; "></div>
+<div id="container" style="color: rgb(192, 255, 238); border: 3px dashed green; "></div>
 [expanded] 
 element.style  { ()
 color: #C0FFEE;
@@ -46,7 +46,6 @@
     border-right-color: green;
     border-bottom-color: green;
     border-left-color: green;
-border-image: initial;
 border-width: 3px;
     border-top-width: 3px;
     border-right-width: 3px;

Modified: trunk/LayoutTests/printing/page-rule-css-text-expected.txt (112176 => 112177)


--- trunk/LayoutTests/printing/page-rule-css-text-expected.txt	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/LayoutTests/printing/page-rule-css-text-expected.txt	2012-03-26 23:59:27 UTC (rev 112177)
@@ -1,10 +1,10 @@
 @page { margin-top: 5cm; margin-bottom: 10cm; }
 @page :left { margin-right: 3cm; }
 @page :right { margin-left: 3cm; }
-@page :first { border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; }
+@page :first { border: 1px; }
 @page hello { color: green; }
 @page world:right { background-color: green; }
-@media print { @page somepage:first { margin-top: 3cm; margin-right: 3cm; margin-bottom: 3cm; margin-left: 3cm; } }
+@media print { @page somepage:first { margin: 3cm; } }
 @page auto_page { size: auto; }
 @page square_page { size: 4in; }
 @page letter_page { size: letter; }

Modified: trunk/Source/_javascript_Core/ChangeLog (112176 => 112177)


--- trunk/Source/_javascript_Core/ChangeLog	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-03-26 23:59:27 UTC (rev 112177)
@@ -1,3 +1,14 @@
+2012-03-26  Ryosuke Niwa  <[email protected]>
+
+        cssText should use shorthand notations
+        https://bugs.webkit.org/show_bug.cgi?id=81737
+
+        Reviewed by Enrica Casucci.
+
+        Export symbols of BitVector on Windows.
+
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+
 2012-03-26  Filip Pizlo  <[email protected]>
 
         DFG should assert that argument value recoveries can only be

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (112176 => 112177)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2012-03-26 23:59:27 UTC (rev 112177)
@@ -157,6 +157,7 @@
     ?destroy@JSByteArray@JSC@@SAXPAVJSCell@2@@Z
     ?destroy@JSCell@JSC@@KAXPAV12@@Z
     ?destroy@JSGlobalObject@JSC@@SAXPAVJSCell@2@@Z
+    ?destroy@OutOfLineBits@BitVector@WTF@@SAXPAV123@@Z
     ?detach@Debugger@JSC@@UAEXPAVJSGlobalObject@2@@Z
     ?detachThread@WTF@@YAXI@Z
     ?didTimeOut@TimeoutChecker@JSC@@QAE_NPAVExecState@2@@Z
@@ -295,6 +296,7 @@
     ?reset@TimeoutChecker@JSC@@QAEXXZ
     ?resetDateCache@JSGlobalData@JSC@@QAEXXZ
     ?resize@StringBuilder@WTF@@QAEXI@Z
+    ?resizeOutOfLine@BitVector@WTF@@AAEXI@Z
     ?resolveRope@JSString@JSC@@ABEXPAVExecState@2@@Z
     ?restoreAll@Profile@JSC@@QAEXXZ
     ?retrieveCallerFromVMCode@Interpreter@JSC@@QBE?AVJSValue@2@PAVExecState@2@PAVJSFunction@2@@Z

Modified: trunk/Source/WTF/ChangeLog (112176 => 112177)


--- trunk/Source/WTF/ChangeLog	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/Source/WTF/ChangeLog	2012-03-26 23:59:27 UTC (rev 112177)
@@ -1,3 +1,14 @@
+2012-03-23  Ryosuke Niwa  <[email protected]>
+
+        cssText should use shorthand notations
+        https://bugs.webkit.org/show_bug.cgi?id=81737
+
+        Reviewed by Enrica Casucci.
+
+        * wtf/BitVector.h:
+        (BitVector):
+        (WTF::BitVector::ensureSizeAndSet): Added.
+
 2012-03-26  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix make distcheck.

Modified: trunk/Source/WTF/wtf/BitVector.h (112176 => 112177)


--- trunk/Source/WTF/wtf/BitVector.h	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/Source/WTF/wtf/BitVector.h	2012-03-26 23:59:27 UTC (rev 112177)
@@ -146,7 +146,13 @@
         ensureSize(bit + 1);
         quickSet(bit);
     }
-    
+
+    void ensureSizeAndSet(size_t bit, size_t size)
+    {
+        ensureSize(size);
+        quickSet(bit);
+    }
+
     void clear(size_t bit)
     {
         if (bit >= size())

Modified: trunk/Source/WebCore/ChangeLog (112176 => 112177)


--- trunk/Source/WebCore/ChangeLog	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/Source/WebCore/ChangeLog	2012-03-26 23:59:27 UTC (rev 112177)
@@ -1,3 +1,24 @@
+2012-03-23  Ryosuke Niwa  <[email protected]>
+
+        cssText should use shorthand notations
+        https://bugs.webkit.org/show_bug.cgi?id=81737
+
+        Reviewed by Enrica Casucci.
+
+        Use shorthand properties to serialize style properties for cssText.
+
+        The overall algorithm is to look for any property that has a shorthand, and then check if
+        the shorthand value could be obtained (the condition is quite complicated for border properties).
+        If it could, then append that value to the string builder, and set the corresponding entries in
+        shorthandPropertyAppeared and shorthandPropertyUsed. If not, only turn on the bit in
+        shorthandPropertyAppeared on to avoid calling getPropertyValue again for longhand properties
+        that use the same shorthand property when we cannot use the shorthand.
+
+        Test: fast/css/cssText-shorthand.html
+
+        * css/StylePropertySet.cpp:
+        (WebCore::StylePropertySet::asText):
+
 2012-03-26  Bolin Hsu  <[email protected]>
 
         [Chromium] Add Android keycodes

Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (112176 => 112177)


--- trunk/Source/WebCore/css/StylePropertySet.cpp	2012-03-26 23:53:59 UTC (rev 112176)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp	2012-03-26 23:59:27 UTC (rev 112177)
@@ -30,6 +30,7 @@
 #include "CSSValuePool.h"
 #include "Document.h"
 #include "PropertySetCSSStyleDeclaration.h"
+#include <wtf/BitVector.h>
 #include <wtf/text/StringBuilder.h>
 
 using namespace std;
@@ -565,25 +566,173 @@
     const CSSProperty* repeatXProp = 0;
     const CSSProperty* repeatYProp = 0;
 
+    // FIXME: Stack-allocate the buffer for these BitVectors.
+    BitVector shorthandPropertyUsed;
+    BitVector shorthandPropertyAppeared;
+
     unsigned size = m_properties.size();
     for (unsigned n = 0; n < size; ++n) {
         const CSSProperty& prop = m_properties[n];
-        switch (prop.id()) {
+        int propertyID = prop.id();
+        int shorthandPropertyID = 0;
+
+        switch (propertyID) {
         case CSSPropertyBackgroundPositionX:
             positionXProp = &prop;
-            break;
+            continue;
         case CSSPropertyBackgroundPositionY:
             positionYProp = &prop;
-            break;
+            continue;
         case CSSPropertyBackgroundRepeatX:
             repeatXProp = &prop;
-            break;
+            continue;
         case CSSPropertyBackgroundRepeatY:
             repeatYProp = &prop;
+            continue;
+        case CSSPropertyBorderWidth:
+        case CSSPropertyBorderTopWidth:
+        case CSSPropertyBorderRightWidth:
+        case CSSPropertyBorderBottomWidth:
+        case CSSPropertyBorderLeftWidth:
+        case CSSPropertyBorderStyle:
+        case CSSPropertyBorderTopStyle:
+        case CSSPropertyBorderRightStyle:
+        case CSSPropertyBorderBottomStyle:
+        case CSSPropertyBorderLeftStyle:
+        case CSSPropertyBorderColor:
+        case CSSPropertyBorderTopColor:
+        case CSSPropertyBorderRightColor:
+        case CSSPropertyBorderBottomColor:
+        case CSSPropertyBorderLeftColor:
+            // FIXME: Deal with cases where only some of border-(top|right|bottom|left) are specified.
+            shorthandPropertyID = CSSPropertyBorder;
+            if (shorthandPropertyAppeared.get(CSSPropertyBorder - firstCSSProperty))
+                break;
+            for (unsigned i = 0; i < borderAbridgedLonghand().length() && shorthandPropertyID; i++) {
+                const CSSPropertyLonghand& longhand = *(borderAbridgedLonghand().longhandsForInitialization()[i]);
+                String commonValue;
+                bool commonImportance = false;
+                for (size_t j = 0; j < longhand.length(); ++j) {
+                    int id = longhand.properties()[j];
+                    RefPtr<CSSValue> value = getPropertyCSSValue(id);
+                    String currentValue = value ? value->cssText() : String();
+                    bool isImportant = propertyIsImportant(id);
+                    if (j && (currentValue != commonValue || commonImportance != isImportant)) {
+                        shorthandPropertyID = 0;
+                        break;
+                    }
+                    if (!j) {
+                        commonValue = currentValue;
+                        commonImportance = isImportant;
+                    }
+                }
+            }
             break;
-        default:
-            result.append(prop.cssText());
+        case CSSPropertyWebkitBorderHorizontalSpacing:
+        case CSSPropertyWebkitBorderVerticalSpacing:
+            shorthandPropertyID = CSSPropertyBorderSpacing;
+            break;
+        case CSSPropertyFontFamily:
+        case CSSPropertyLineHeight:
+        case CSSPropertyFontSize:
+        case CSSPropertyFontStyle:
+        case CSSPropertyFontVariant:
+        case CSSPropertyFontWeight:
+            // Don't use CSSPropertyFont because old UAs can't recognize them but are important for editing.
+            break;
+        case CSSPropertyListStyleType:
+        case CSSPropertyListStylePosition:
+        case CSSPropertyListStyleImage:
+            shorthandPropertyID = CSSPropertyListStyle;
+            break;
+        case CSSPropertyMarginTop:
+        case CSSPropertyMarginRight:
+        case CSSPropertyMarginBottom:
+        case CSSPropertyMarginLeft:
+            shorthandPropertyID = CSSPropertyMargin;
+            break;
+        case CSSPropertyOutlineWidth:
+        case CSSPropertyOutlineStyle:
+        case CSSPropertyOutlineColor:
+            shorthandPropertyID = CSSPropertyOutline;
+            break;
+        case CSSPropertyOverflowX:
+        case CSSPropertyOverflowY:
+            shorthandPropertyID = CSSPropertyOverflow;
+            break;
+        case CSSPropertyPaddingTop:
+        case CSSPropertyPaddingRight:
+        case CSSPropertyPaddingBottom:
+        case CSSPropertyPaddingLeft:
+            shorthandPropertyID = CSSPropertyPadding;
+            break;
+        case CSSPropertyWebkitAnimationName:
+        case CSSPropertyWebkitAnimationDuration:
+        case CSSPropertyWebkitAnimationTimingFunction:
+        case CSSPropertyWebkitAnimationDelay:
+        case CSSPropertyWebkitAnimationIterationCount:
+        case CSSPropertyWebkitAnimationDirection:
+        case CSSPropertyWebkitAnimationFillMode:
+            shorthandPropertyID = CSSPropertyWebkitAnimation;
+            break;
+        case CSSPropertyWebkitFlexDirection:
+        case CSSPropertyWebkitFlexWrap:
+            shorthandPropertyID = CSSPropertyWebkitFlexFlow;
+            break;
+        case CSSPropertyWebkitMaskPositionX:
+        case CSSPropertyWebkitMaskPositionY:
+        case CSSPropertyWebkitMaskRepeatX:
+        case CSSPropertyWebkitMaskRepeatY:
+        case CSSPropertyWebkitMaskImage:
+        case CSSPropertyWebkitMaskRepeat:
+        case CSSPropertyWebkitMaskAttachment:
+        case CSSPropertyWebkitMaskPosition:
+        case CSSPropertyWebkitMaskClip:
+        case CSSPropertyWebkitMaskOrigin:
+            shorthandPropertyID = CSSPropertyWebkitMask;
+            break;
+        case CSSPropertyWebkitTransformOriginX:
+        case CSSPropertyWebkitTransformOriginY:
+        case CSSPropertyWebkitTransformOriginZ:
+            shorthandPropertyID = CSSPropertyWebkitTransformOrigin;
+            break;
+        case CSSPropertyWebkitTransitionProperty:
+        case CSSPropertyWebkitTransitionDuration:
+        case CSSPropertyWebkitTransitionTimingFunction:
+        case CSSPropertyWebkitTransitionDelay:
+            shorthandPropertyID = CSSPropertyWebkitTransition;
+            break;
+        case CSSPropertyWebkitWrapFlow:
+        case CSSPropertyWebkitWrapMargin:
+        case CSSPropertyWebkitWrapPadding:
+            shorthandPropertyID = CSSPropertyWebkitWrap;
+            break;
         }
+
+        String value;
+        unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty;
+        if (shorthandPropertyID) {
+            if (shorthandPropertyUsed.get(shortPropertyIndex))
+                continue;
+            if (!shorthandPropertyAppeared.get(shortPropertyIndex))
+                value = getPropertyValue(shorthandPropertyID);
+            shorthandPropertyAppeared.ensureSizeAndSet(shortPropertyIndex, numCSSProperties);
+        }
+
+        if (!value.isNull()) {
+            propertyID = shorthandPropertyID;
+            shorthandPropertyUsed.ensureSizeAndSet(shortPropertyIndex, numCSSProperties);
+        } else
+            value = prop.value()->cssText();
+
+        if (value == "initial" && !CSSProperty::isInheritedProperty(propertyID))
+            continue;
+
+        result.append(getPropertyName(static_cast<CSSPropertyID>(propertyID)));
+        result.append(": ");
+        result.append(value);
+        result.append(prop.isImportant() ? " !important" : "");
+        result.append("; ");
     }
 
     // FIXME: This is a not-so-nice way to turn x/y positions into single background-position in output.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to