Title: [103811] trunk
Revision
103811
Author
alexis.men...@openbossa.org
Date
2011-12-29 10:52:25 -0800 (Thu, 29 Dec 2011)

Log Message

getComputedStyle for margin is not implemented.
https://bugs.webkit.org/show_bug.cgi?id=75358

Reviewed by Andreas Kling.

Source/WebCore:

Implement getComputedStyle for margin.

Test: fast/css/getComputedStyle/getComputedStyle-margin-shorthand.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

LayoutTests:

Add test to cover that we return correct values.

* fast/css/getComputedStyle/getComputedStyle-margin-shorthand-expected.txt: Added.
* fast/css/getComputedStyle/getComputedStyle-margin-shorthand.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (103810 => 103811)


--- trunk/LayoutTests/ChangeLog	2011-12-29 18:44:45 UTC (rev 103810)
+++ trunk/LayoutTests/ChangeLog	2011-12-29 18:52:25 UTC (rev 103811)
@@ -1,5 +1,17 @@
 2011-12-29  Alexis Menard  <alexis.men...@openbossa.org>
 
+        getComputedStyle for margin is not implemented.
+        https://bugs.webkit.org/show_bug.cgi?id=75358
+
+        Reviewed by Andreas Kling.
+
+        Add test to cover that we return correct values.
+
+        * fast/css/getComputedStyle/getComputedStyle-margin-shorthand-expected.txt: Added.
+        * fast/css/getComputedStyle/getComputedStyle-margin-shorthand.html: Added.
+
+2011-12-29  Alexis Menard  <alexis.men...@openbossa.org>
+
         getComputedStyle for padding is not implemented.
         https://bugs.webkit.org/show_bug.cgi?id=75352
 

Added: trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-margin-shorthand-expected.txt (0 => 103811)


--- trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-margin-shorthand-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-margin-shorthand-expected.txt	2011-12-29 18:52:25 UTC (rev 103811)
@@ -0,0 +1,33 @@
+Test to make sure margin shorthand property returns CSSValueList properly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS computedStyle.getPropertyValue('margin') is '10px 5px 4px 3px'
+PASS computedStyle.getPropertyCSSValue('margin').toString() is '[object CSSValueList]'
+PASS computedStyle.getPropertyCSSValue('margin').length is 4
+PASS computedStyle.getPropertyCSSValue('margin').cssText is '10px 5px 4px 3px'
+PASS computedStyle.getPropertyCSSValue('margin').item(0).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 10
+PASS computedStyle.getPropertyCSSValue('margin').item(1).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 5
+PASS computedStyle.getPropertyCSSValue('margin').item(2).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 4
+PASS computedStyle.getPropertyCSSValue('margin').item(3).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 3
+PASS computedStyle.getPropertyValue('margin') is '64px 80px 96px 112px'
+PASS computedStyle.getPropertyCSSValue('margin').toString() is '[object CSSValueList]'
+PASS computedStyle.getPropertyCSSValue('margin').length is 4
+PASS computedStyle.getPropertyCSSValue('margin').cssText is '64px 80px 96px 112px'
+PASS computedStyle.getPropertyCSSValue('margin').item(0).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 64
+PASS computedStyle.getPropertyCSSValue('margin').item(1).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 80
+PASS computedStyle.getPropertyCSSValue('margin').item(2).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 96
+PASS computedStyle.getPropertyCSSValue('margin').item(3).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 112
+PASS computedStyle.getPropertyValue('margin') is '5px 6px 7px 8px'
+PASS computedStyle.getPropertyCSSValue('margin').toString() is '[object CSSValueList]'
+PASS computedStyle.getPropertyCSSValue('margin').length is 4
+PASS computedStyle.getPropertyCSSValue('margin').cssText is '5px 6px 7px 8px'
+PASS computedStyle.getPropertyCSSValue('margin').item(0).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 5
+PASS computedStyle.getPropertyCSSValue('margin').item(1).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 6
+PASS computedStyle.getPropertyCSSValue('margin').item(2).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 7
+PASS computedStyle.getPropertyCSSValue('margin').item(3).getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 8
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-margin-shorthand.html (0 => 103811)


--- trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-margin-shorthand.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-margin-shorthand.html	2011-12-29 18:52:25 UTC (rev 103811)
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<script>
+
+description("Test to make sure margin shorthand property returns CSSValueList properly.")
+
+var testContainer = document.createElement("div");
+testContainer.contentEditable = true;
+document.body.appendChild(testContainer);
+
+testContainer.innerHTML = '<div style="width:100px;height:100px"><div id="test">hello</div></div>';
+
+e = document.getElementById('test');
+computedStyle = window.getComputedStyle(e, null);
+
+e.style.margin = "10px 5px 4px 3px";
+shouldBe("computedStyle.getPropertyValue('margin')", "'10px 5px 4px 3px'");
+shouldBe("computedStyle.getPropertyCSSValue('margin').toString()", "'[object CSSValueList]'");
+shouldBe("computedStyle.getPropertyCSSValue('margin').length", "4");
+shouldBe("computedStyle.getPropertyCSSValue('margin').cssText", "'10px 5px 4px 3px'");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(0).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "10");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(1).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "5");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(2).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "4");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(3).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "3");
+
+e.style.margin = "4em 5em 6em 7em";
+shouldBe("computedStyle.getPropertyValue('margin')", "'64px 80px 96px 112px'");
+shouldBe("computedStyle.getPropertyCSSValue('margin').toString()", "'[object CSSValueList]'");
+shouldBe("computedStyle.getPropertyCSSValue('margin').length", "4");
+shouldBe("computedStyle.getPropertyCSSValue('margin').cssText", "'64px 80px 96px 112px'");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(0).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "64");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(1).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "80");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(2).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "96");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(3).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "112");
+
+e.style.margin = "5% 6% 7% 8%";
+shouldBe("computedStyle.getPropertyValue('margin')", "'5px 6px 7px 8px'");
+shouldBe("computedStyle.getPropertyCSSValue('margin').toString()", "'[object CSSValueList]'");
+shouldBe("computedStyle.getPropertyCSSValue('margin').length", "4");
+shouldBe("computedStyle.getPropertyCSSValue('margin').cssText", "'5px 6px 7px 8px'");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(0).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "5");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(1).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "6");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(2).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "7");
+shouldBe("computedStyle.getPropertyCSSValue('margin').item(3).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "8");
+
+document.body.removeChild(testContainer);
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (103810 => 103811)


--- trunk/Source/WebCore/ChangeLog	2011-12-29 18:44:45 UTC (rev 103810)
+++ trunk/Source/WebCore/ChangeLog	2011-12-29 18:52:25 UTC (rev 103811)
@@ -1,3 +1,17 @@
+2011-12-29  Alexis Menard  <alexis.men...@openbossa.org>
+
+        getComputedStyle for margin is not implemented.
+        https://bugs.webkit.org/show_bug.cgi?id=75358
+
+        Reviewed by Andreas Kling.
+
+        Implement getComputedStyle for margin.
+
+        Test: fast/css/getComputedStyle/getComputedStyle-margin-shorthand.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+
 2011-12-29  Caio Marcelo de Oliveira Filho  <caio.olive...@openbossa.org>
 
         Use HashMap<OwnPtr> in RenderSVGResourcePattern

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (103810 => 103811)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-12-29 18:44:45 UTC (rev 103810)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-12-29 18:52:25 UTC (rev 103811)
@@ -2178,7 +2178,12 @@
             return getCSSPropertyValuesForShorthandProperties(properties, WTF_ARRAY_LENGTH(properties));
         }
         case CSSPropertyListStyle:
-        case CSSPropertyMargin:
+            break;
+        case CSSPropertyMargin: {
+            const int properties[4] = { CSSPropertyMarginTop, CSSPropertyMarginRight,
+                                        CSSPropertyMarginBottom, CSSPropertyMarginLeft };
+            return getCSSPropertyValuesForShorthandProperties(properties, WTF_ARRAY_LENGTH(properties));
+        }
         case CSSPropertyOutline:
             break;
         case CSSPropertyPadding: {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to