Skip to content

Commit

Permalink
Merge r174543 - Computed style for clip is wrong with respect to auto
Browse files Browse the repository at this point in the history
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.

Canonical link: https://commits.webkit.org/154760.116@webkitgtk/2.6
git-svn-id: https://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.6@174969 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
grorg authored and carlosgcampos committed Oct 21, 2014
1 parent bc47012 commit 12bfaf1
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 4 deletions.
13 changes: 13 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
2014-10-09 Dean Jackson <dino@apple.com>

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 Bear Travis <betravis@adobe.com>

[CSS Font Loading] Decrement the font loading count before notifying callbacks
Expand Down
11 changes: 11 additions & 0 deletions LayoutTests/fast/css/computed-clip-with-auto-rect-expected.txt
@@ -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)
34 changes: 34 additions & 0 deletions LayoutTests/fast/css/computed-clip-with-auto-rect.html
@@ -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>
29 changes: 29 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,32 @@
2014-10-09 Simon Fraser <simon.fraser@apple.com>

Revert part of r174543 that broke grid layout tests.

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

2014-10-09 Dean Jackson <dino@apple.com>

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 Bear Travis <betravis@adobe.com>

[CSS Font Loading] Decrement the font loading count before notifying callbacks
Expand Down
16 changes: 12 additions & 4 deletions Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Expand Up @@ -721,6 +721,14 @@ static PassRef<CSSPrimitiveValue> percentageOrZoomAdjustedValue(Length length, c
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();
Expand Down Expand Up @@ -2744,10 +2752,10 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
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:
Expand Down

0 comments on commit 12bfaf1

Please sign in to comment.