WebCore: Display the correct summary in the web inspector for the shorthands
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Nov 2009 20:20:45 +0000 (20:20 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Nov 2009 20:20:45 +0000 (20:20 +0000)
border-color, border-width, border-style, margin, and padding.
https://bugs.webkit.org/show_bug.cgi?id=7987

Reviewed by Timothy Hatcher.

Test: fast/css/shorthands-four-values.html

* css/CSSMutableStyleDeclaration.cpp:
(WebCore::CSSMutableStyleDeclaration::get4Values):
Display the summary information in the same way the shorthand would be
specified in a css rule.

LayoutTests:

* fast/css/shorthands-four-values-expected.txt: Added.
* fast/css/shorthands-four-values.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@50834 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/css/shorthands-four-values-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/shorthands-four-values.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSMutableStyleDeclaration.cpp

index f584cb6..a358440 100644 (file)
@@ -1,3 +1,16 @@
+2009-11-11  Jessie Berlin  <jberlin@webkit.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Display the correct summary in the web inspector for the padding
+        shorthand. Also corrects the summaries for the border-color,
+        border-width, border-style, and margin shorthands.
+
+        https://bugs.webkit.org/show_bug.cgi?id=7987
+
+        * fast/css/shorthands-four-values-expected.txt: Added.
+        * fast/css/shorthands-four-values.html: Added.
+
 2009-11-11  Eric Z. Ayers  <zundel@google.com>
 
         Reviewed by Pavel Feldman.
diff --git a/LayoutTests/fast/css/shorthands-four-values-expected.txt b/LayoutTests/fast/css/shorthands-four-values-expected.txt
new file mode 100644 (file)
index 0000000..8cfabf1
--- /dev/null
@@ -0,0 +1,26 @@
+Test for WebKit bug 7987: Inspector displays incorrect summary for padding information
+
+PASS test0.style.padding is "20px"
+PASS test1.style.padding is "20px 30px"
+PASS test2.style.padding is "20px 30px 10px 15px"
+PASS test3.style.padding is "20px 30px"
+PASS test4.style.borderColor is "yellow red red"
+PASS test5.style.borderColor is "green blue red"
+PASS test6.style.borderColor is "blue yellow red green"
+PASS test7.style.borderColor is "red blue green yellow"
+PASS test8.style.borderWidth is "2px 5px 2px 2px"
+PASS test9.style.borderWidth is "2px 4px 2px 3px"
+PASS test10.style.borderWidth is "2px 3px 5px"
+PASS test11.style.borderWidth is "20px 30px 55px 60px"
+PASS test12.style.borderStyle is "solid solid dashed"
+PASS test13.style.borderStyle is "solid dashed dotted"
+PASS test14.style.borderStyle is "dotted dashed"
+PASS test15.style.borderStyle is ""
+PASS test16.style.margin is "20px 20px 20px 25px"
+PASS test17.style.margin is "20px 30px 20px 50px"
+PASS test18.style.margin is "20px 30px 55px"
+PASS test19.style.margin is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/shorthands-four-values.html b/LayoutTests/fast/css/shorthands-four-values.html
new file mode 100644 (file)
index 0000000..39b04ff
--- /dev/null
@@ -0,0 +1,96 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test for WebKit bug 7987: Inspector displays incorrect summary for padding information</title>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description">Test for WebKit bug <a href="https://bugs.webkit.org/show_bug.cgi?id=7987">7987</a>: Inspector displays incorrect summary for padding information</p>
+<div id="console"></div>
+
+<div id="tests_container">
+
+<div id="test0" style="padding: 20px;"></div>
+<div id="test1" style="padding: 20px 30px;"></div>
+<div id="test2" style="padding: 20px 30px; padding-left: 15px; padding-bottom: 10px;"></div>
+<div id="test3" style="padding: 20px 30px 55px; padding-bottom: 20px;"></div>
+
+<div id="test4" style="border-color: red; border-top-color: yellow"></div>
+<div id="test5" style="border-color: red blue; border-top-color: green"></div>
+<div id="test6" style="border-color: red green; border-top-color: blue; border-right-color: yellow;"></div>
+<div id="test7" style="border-color: red yellow green; border-right-color: blue;"></div>
+
+<div id="test8" style="border-width: 2px; border-right-width: 5px"></div>
+<div id="test9" style="border-width: 2px 3px; border-right-width: 4px"></div>
+<div id="test10" style="border-width: 2px 3px 5px;"></div>
+<div id="test11" style="border-width: 20px 30px 55px 60px;"></div>
+
+<div id="test12" style="border-style: solid; border-bottom-style: dashed"></div>
+<div id="test13" style="border-style: solid dashed; border-bottom-style: dotted;"></div>
+<div id="test14" style="border-style: solid dashed dotted; border-top-style: dotted;"></div>
+<div id="test15" style="border-top-style: dotted; border-right-style: dashed; border-bottom-style: solid;"></div>
+
+<div id="test16" style="margin: 20px; margin-left: 25px"></div>
+<div id="test17" style="margin: 20px 30px; margin-left: 50px;"></div>
+<div id="test18" style="margin: 20px 30px 55px; margin-left: 30px;"></div>
+<div id="test19" style=""></div>
+
+</div>
+
+<script>
+    var test0 = document.getElementById("test0");
+    var test1 = document.getElementById("test1");
+    var test2 = document.getElementById("test2");
+    var test3 = document.getElementById("test3");
+    var test4 = document.getElementById("test4");
+    var test5 = document.getElementById("test5");
+    var test6 = document.getElementById("test6");
+    var test7 = document.getElementById("test7");
+    var test8 = document.getElementById("test8");
+    var test9 = document.getElementById("test9");
+    var test10 = document.getElementById("test10");
+    var test11 = document.getElementById("test11");
+    var test12 = document.getElementById("test12");
+    var test13 = document.getElementById("test13");
+    var test14 = document.getElementById("test14");
+    var test15 = document.getElementById("test15");
+    var test16 = document.getElementById("test16");
+    var test17 = document.getElementById("test17");
+    var test18 = document.getElementById("test18");
+    var test19 = document.getElementById("test19");
+
+    shouldBeEqualToString("test0.style.padding", "20px");
+    shouldBeEqualToString("test1.style.padding", "20px 30px");
+    shouldBeEqualToString("test2.style.padding", "20px 30px 10px 15px");
+    shouldBeEqualToString("test3.style.padding", "20px 30px");
+
+    shouldBeEqualToString("test4.style.borderColor", "yellow red red");
+    shouldBeEqualToString("test5.style.borderColor", "green blue red");
+    shouldBeEqualToString("test6.style.borderColor", "blue yellow red green");
+    shouldBeEqualToString("test7.style.borderColor", "red blue green yellow");
+
+    shouldBeEqualToString("test8.style.borderWidth", "2px 5px 2px 2px");
+    shouldBeEqualToString("test9.style.borderWidth", "2px 4px 2px 3px");
+    shouldBeEqualToString("test10.style.borderWidth", "2px 3px 5px");
+    shouldBeEqualToString("test11.style.borderWidth", "20px 30px 55px 60px");
+
+    shouldBeEqualToString("test12.style.borderStyle", "solid solid dashed");
+    shouldBeEqualToString("test13.style.borderStyle", "solid dashed dotted");
+    shouldBeEqualToString("test14.style.borderStyle", "dotted dashed");
+    shouldBeEqualToString("test15.style.borderStyle", "");
+
+    shouldBeEqualToString("test16.style.margin", "20px 20px 20px 25px");
+    shouldBeEqualToString("test17.style.margin", "20px 30px 20px 50px");
+    shouldBeEqualToString("test18.style.margin", "20px 30px 55px");
+    shouldBeEqualToString("test19.style.margin", "");
+
+    // clean up after ourselves
+    var tests_container = document.getElementById("tests_container");
+    tests_container.parentNode.removeChild(tests_container);
+
+    var successfullyParsed = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index eac02bb..0e0e75d 100644 (file)
@@ -1,3 +1,18 @@
+2009-11-11  Jessie Berlin  <jberlin@webkit.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Display the correct summary in the web inspector for the shorthands
+        border-color, border-width, border-style, margin, and padding.
+        https://bugs.webkit.org/show_bug.cgi?id=7987
+
+        Test: fast/css/shorthands-four-values.html
+
+        * css/CSSMutableStyleDeclaration.cpp:
+        (WebCore::CSSMutableStyleDeclaration::get4Values):
+        Display the summary information in the same way the shorthand would be
+        specified in a css rule.
+
 2009-11-11  Jens Alfke  <snej@chromium.org>
 
         Reviewed by Dimitri Glazkov.
index 2dd2f5d..aa8e028 100644 (file)
@@ -259,20 +259,28 @@ String CSSMutableStyleDeclaration::getPropertyValue(int propertyID) const
 
 String CSSMutableStyleDeclaration::get4Values(const int* properties) const
 {
-    String res;
-    for (int i = 0; i < 4; ++i) {
-        if (!isPropertyImplicit(properties[i])) {
-            RefPtr<CSSValue> value = getPropertyCSSValue(properties[i]);
+    // Assume the properties are in the usual order top, right, bottom, left.
+    RefPtr<CSSValue> topValue = getPropertyCSSValue(properties[0]);
+    RefPtr<CSSValue> rightValue = getPropertyCSSValue(properties[1]);
+    RefPtr<CSSValue> bottomValue = getPropertyCSSValue(properties[2]);
+    RefPtr<CSSValue> leftValue = getPropertyCSSValue(properties[3]);
+
+    // All 4 properties must be specified.
+    if (!topValue || !rightValue || !bottomValue || !leftValue)
+        return String();
 
-            // apparently all 4 properties must be specified.
-            if (!value)
-                return String();
+    bool showLeft = rightValue->cssText() != leftValue->cssText();
+    bool showBottom = (topValue->cssText() != bottomValue->cssText()) || showLeft;
+    bool showRight = (topValue->cssText() != rightValue->cssText()) || showBottom;
+
+    String res = topValue->cssText();
+    if (showRight)
+        res += " " + rightValue->cssText();
+    if (showBottom)
+        res += " " + bottomValue->cssText();
+    if (showLeft)
+        res += " " + leftValue->cssText();
 
-            if (!res.isNull())
-                res += " ";
-            res += value->cssText();
-        }
-    }
     return res;
 }