Title: [174543] trunk
Revision
174543
Author
[email protected]
Date
2014-10-09 17:19:03 -0700 (Thu, 09 Oct 2014)

Log Message

Computed style for clip is wrong with respect to auto
https://bugs.webkit.org/show_bug.cgi?id=137567

Reviewed by Simon Fraser.

Source/WebCore:

Make sure that the computed style of clip returns the
correct value when the input is "auto", or in this
case "rect(auto, auto, auto, auto)". Before this
patch it returned "rect(0px, 0px, 0px, 0px)" which
was completely wrong.

Test: fast/css/computed-clip-with-auto-rect.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::autoOrZoomAdjustedValue): Helper function to make the correct keyword or length.
(WebCore::specifiedValueForGridTrackBreadth): It can use the helper too.
(WebCore::ComputedStyleExtractor::propertyValue): If the
top/right/bottom/left is "auto", add that identifier
to the output rectangle.

LayoutTests:

Test that an input of clip: rect(auto, auto, auto, auto)
is the same on the way out.

* fast/css/computed-clip-with-auto-rect-expected.txt: Added.
* fast/css/computed-clip-with-auto-rect.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (174542 => 174543)


--- trunk/LayoutTests/ChangeLog	2014-10-09 23:55:40 UTC (rev 174542)
+++ trunk/LayoutTests/ChangeLog	2014-10-10 00:19:03 UTC (rev 174543)
@@ -1,3 +1,16 @@
+2014-10-09  Dean Jackson  <[email protected]>
+
+        Computed style for clip is wrong with respect to auto
+        https://bugs.webkit.org/show_bug.cgi?id=137567
+
+        Reviewed by Simon Fraser.
+
+        Test that an input of clip: rect(auto, auto, auto, auto)
+        is the same on the way out.
+
+        * fast/css/computed-clip-with-auto-rect-expected.txt: Added.
+        * fast/css/computed-clip-with-auto-rect.html: Added.
+
 2014-10-09  Said Abou-Hallawa  <[email protected]>
 
         RenderMathMLUnderOver adds spacing to the child operator indefinitely when zooming or resizing the window.

Added: trunk/LayoutTests/fast/css/computed-clip-with-auto-rect-expected.txt (0 => 174543)


--- trunk/LayoutTests/fast/css/computed-clip-with-auto-rect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/computed-clip-with-auto-rect-expected.txt	2014-10-10 00:19:03 UTC (rev 174543)
@@ -0,0 +1,11 @@
+rect(auto, auto, auto, auto)
+
+rect(5px, auto, auto, auto)
+
+rect(auto, 5px, auto, auto)
+
+rect(auto, auto, 5px, auto)
+
+rect(auto, auto, auto, 5px)
+
+rect(5px, auto, 5px, auto)
Property changes on: trunk/LayoutTests/fast/css/computed-clip-with-auto-rect-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/css/computed-clip-with-auto-rect.html (0 => 174543)


--- trunk/LayoutTests/fast/css/computed-clip-with-auto-rect.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/computed-clip-with-auto-rect.html	2014-10-10 00:19:03 UTC (rev 174543)
@@ -0,0 +1,34 @@
+<style>
+div {
+    width: 10px;
+    height: 10px;
+    background-color: green;
+}
+</style>
+<div id="test1" style="clip: rect(auto, auto, auto, auto);">
+<div id="test2" style="clip: rect(5px, auto, auto, auto);">
+<div id="test3" style="clip: rect(auto, 5px, auto, auto);">
+<div id="test4" style="clip: rect(auto, auto, 5px, auto);">
+<div id="test5" style="clip: rect(auto, auto, auto, 5px);">
+<div id="test6" style="clip: rect(5px, auto, 5px, auto);">
+
+<script>
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function outputStyleForElement(id) {
+    var element = document.getElementById(id);
+    var clipStyle = getComputedStyle(element).clip;
+    var p = document.createElement("p");
+    p.innerText = clipStyle;
+    document.body.appendChild(p);
+}
+
+outputStyleForElement("test1");
+outputStyleForElement("test2");
+outputStyleForElement("test3");
+outputStyleForElement("test4");
+outputStyleForElement("test5");
+outputStyleForElement("test6");
+</script>
Property changes on: trunk/LayoutTests/fast/css/computed-clip-with-auto-rect.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (174542 => 174543)


--- trunk/Source/WebCore/ChangeLog	2014-10-09 23:55:40 UTC (rev 174542)
+++ trunk/Source/WebCore/ChangeLog	2014-10-10 00:19:03 UTC (rev 174543)
@@ -1,3 +1,25 @@
+2014-10-09  Dean Jackson  <[email protected]>
+
+        Computed style for clip is wrong with respect to auto
+        https://bugs.webkit.org/show_bug.cgi?id=137567
+
+        Reviewed by Simon Fraser.
+
+        Make sure that the computed style of clip returns the
+        correct value when the input is "auto", or in this
+        case "rect(auto, auto, auto, auto)". Before this
+        patch it returned "rect(0px, 0px, 0px, 0px)" which
+        was completely wrong.
+
+        Test: fast/css/computed-clip-with-auto-rect.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::autoOrZoomAdjustedValue): Helper function to make the correct keyword or length.
+        (WebCore::specifiedValueForGridTrackBreadth): It can use the helper too.
+        (WebCore::ComputedStyleExtractor::propertyValue): If the
+        top/right/bottom/left is "auto", add that identifier
+        to the output rectangle.
+
 2014-10-09  Chris Dumez  <[email protected]>
 
         Use RenderObject::firstChildSlow() / lastChildSlow() less

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (174542 => 174543)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2014-10-09 23:55:40 UTC (rev 174542)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2014-10-10 00:19:03 UTC (rev 174543)
@@ -721,6 +721,14 @@
     return zoomAdjustedPixelValue(valueForLength(length, 0), style);
 }
 
+static PassRef<CSSPrimitiveValue> autoOrZoomAdjustedValue(Length length, const RenderStyle* style)
+{
+    if (length.isAuto())
+        return cssValuePool().createIdentifierValue(CSSValueAuto);
+
+    return zoomAdjustedPixelValue(valueForLength(length, 0), style);
+}
+
 static PassRef<CSSValueList> getBorderRadiusCornerValues(const LengthSize& radius, const RenderStyle* style)
 {
     auto list = CSSValueList::createSpaceSeparated();
@@ -972,9 +980,7 @@
         return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue::CSS_FR);
 
     const Length& trackBreadthLength = trackBreadth.length();
-    if (trackBreadthLength.isAuto())
-        return cssValuePool().createIdentifierValue(CSSValueAuto);
-    return zoomAdjustedPixelValueForLength(trackBreadthLength, style);
+    return autoOrZoomAdjustedValue(trackBreadthLength, style);
 }
 
 static PassRef<CSSValue> specifiedValueForGridTrackSize(const GridTrackSize& trackSize, const RenderStyle* style)
@@ -2744,10 +2750,10 @@
             if (!style->hasClip())
                 return cssValuePool().createIdentifierValue(CSSValueAuto);
             RefPtr<Rect> rect = Rect::create();
-            rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
-            rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
-            rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
-            rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
+            rect->setTop(autoOrZoomAdjustedValue(style->clip().top(), style.get()));
+            rect->setRight(autoOrZoomAdjustedValue(style->clip().right(), style.get()));
+            rect->setBottom(autoOrZoomAdjustedValue(style->clip().bottom(), style.get()));
+            rect->setLeft(autoOrZoomAdjustedValue(style->clip().left(), style.get()));
             return cssValuePool().createValue(rect.release());
         }
         case CSSPropertySpeak:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to