Commit 5088c1d5 authored by rniwa@webkit.org's avatar rniwa@webkit.org

The computed values of fix length padding should be subpixel precision like margin

https://bugs.webkit.org/show_bug.cgi?id=118936

Reviewed by Simon Fraser.

Source/WebCore: 

The bug was caused by ComputedStyleExtractor::propertyValue always returning the used value
for padding. Fixed the bug by returning the computed value when they're of fixed length.

This aligns the behaviors of getComputedStyle(~).padding~ with getComputedStyle(~).margin~,
which had been fixed in r102149. While the current CSSOM specification says getComputedStyle
should return the used values for margins when display property is set to anything but none,
new behavior matches that of Chrome, Firefox, and Internet Explorer.

Also extracted zoomAdjustedPaddingOrMarginPixelValue to reduce the code duplication.

Test: fast/css/getComputedStyle/getComputedStyle-padding-margin-subpixel-length.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::zoomAdjustedPaddingOrMarginPixelValue): Extracted.
(WebCore::ComputedStyleExtractor::propertyValue):

LayoutTests: 

Add a regression test for obtaining the computed values of floating point padding and margin.
They shouldn't be rounded to whole pixels.

* fast/css/getComputedStyle/getComputedStyle-padding-margin-subpixel-length-expected.txt: Added.
* fast/css/getComputedStyle/getComputedStyle-padding-margin-subpixel-length.html: Added.
* fast/shapes/shape-inside/shape-inside-shape-logical-top-expected.html: Use a different technique to detect
the subpixel layout since paddings


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153067 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3326c96b
2013-07-22 Ryosuke Niwa <rniwa@webkit.org>
The computed values of fix length padding should be subpixel precision like margin
https://bugs.webkit.org/show_bug.cgi?id=118936
Reviewed by Simon Fraser.
Add a regression test for obtaining the computed values of floating point padding and margin.
They shouldn't be rounded to whole pixels.
* fast/css/getComputedStyle/getComputedStyle-padding-margin-subpixel-length-expected.txt: Added.
* fast/css/getComputedStyle/getComputedStyle-padding-margin-subpixel-length.html: Added.
* fast/shapes/shape-inside/shape-inside-shape-logical-top-expected.html: Use a different technique to detect
the subpixel layout since paddings
2013-07-23 Bem Jones-Bey <bjonesbe@adobe.com>
[CSS Shapes] New positioning model: support for rounded rectangle shape-outside
Test calling getPropertyValue on computed margin styles.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS getComputedStyle(testElement).marginTop is "1.5px"
PASS getComputedStyle(testElement).marginRight is "2.5px"
PASS getComputedStyle(testElement).marginBottom is "3.5px"
PASS getComputedStyle(testElement).marginLeft is "4.5px"
PASS getComputedStyle(testElement).margin is "1.5px 2.5px 3.5px 4.5px"
PASS getComputedStyle(testElement).paddingTop is "5.5px"
PASS getComputedStyle(testElement).paddingRight is "6.5px"
PASS getComputedStyle(testElement).paddingBottom is "7.5px"
PASS getComputedStyle(testElement).paddingLeft is "8.5px"
PASS getComputedStyle(testElement).padding is "5.5px 6.5px 7.5px 8.5px"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<style>
#testElement {
margin-top: 1.5px;
margin-right: 2.5px;
margin-bottom: 3.5px;
margin-left: 4.5px;
padding-top: 5.5px;
padding-right: 6.5px;
padding-bottom: 7.5px;
padding-left: 8.5px;
}
</style>
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<div id="testElement"></div>
<script>
description('Test calling getPropertyValue on computed margin styles.');
var testElement = document.getElementById('testElement');
shouldBe('getComputedStyle(testElement).marginTop', '"1.5px"');
shouldBe('getComputedStyle(testElement).marginRight', '"2.5px"');
shouldBe('getComputedStyle(testElement).marginBottom', '"3.5px"');
shouldBe('getComputedStyle(testElement).marginLeft', '"4.5px"');
shouldBe('getComputedStyle(testElement).margin', '"1.5px 2.5px 3.5px 4.5px"');
shouldBe('getComputedStyle(testElement).paddingTop', '"5.5px"');
shouldBe('getComputedStyle(testElement).paddingRight', '"6.5px"');
shouldBe('getComputedStyle(testElement).paddingBottom', '"7.5px"');
shouldBe('getComputedStyle(testElement).paddingLeft', '"8.5px"');
shouldBe('getComputedStyle(testElement).padding', '"5.5px 6.5px 7.5px 8.5px"');
var successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
......@@ -16,18 +16,25 @@
height: 186px;
border: 2px solid blue;
}
#elementWith105pxHeight {
position: absolute;
left: 0;
top: 0;
height: 10.5px;
}
</style>
<script>
function init() {
// If subpixel layout is not enabled, fix shape-inside's padding-top value.
var shapeInsideElt = document.getElementById("shape-inside");
if (window.getComputedStyle(shapeInsideElt).paddingTop == "20px")
if (getComputedStyle(document.getElementById('elementWith105pxHeight')).height == "10px")
shapeInsideElt.style.paddingTop = "21px"
}
</script>
</head>
<body onload="init()">
<div id="shape-inside">
<span id="elementWith105pxHeight"></span>
<div id="border"></div>
This text should be contained by the blue square.
</div>
......
2013-07-19 Ryosuke Niwa <rniwa@webkit.org>
The computed values of fix length padding should be subpixel precision like margin
https://bugs.webkit.org/show_bug.cgi?id=118936
Reviewed by Simon Fraser.
The bug was caused by ComputedStyleExtractor::propertyValue always returning the used value
for padding. Fixed the bug by returning the computed value when they're of fixed length.
This aligns the behaviors of getComputedStyle(~).padding~ with getComputedStyle(~).margin~,
which had been fixed in r102149. While the current CSSOM specification says getComputedStyle
should return the used values for margins when display property is set to anything but none,
new behavior matches that of Chrome, Firefox, and Internet Explorer.
Also extracted zoomAdjustedPaddingOrMarginPixelValue to reduce the code duplication.
Test: fast/css/getComputedStyle/getComputedStyle-padding-margin-subpixel-length.html
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::zoomAdjustedPaddingOrMarginPixelValue): Extracted.
(WebCore::ComputedStyleExtractor::propertyValue):
2013-07-23 Alex Christensen <achristensen@apple.com>
Updated ANGLE to latest git commit (047373aa3eb408be62be52ade840fa5f11e72337).
......@@ -1596,6 +1596,18 @@ static inline PassRefPtr<RenderStyle> computeRenderStyleForProperty(Node* styled
return styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier);
}
typedef Length (RenderStyle::*RenderStyleLengthGetter)() const;
typedef LayoutUnit (RenderBoxModelObject::*RenderBoxComputedCSSValueGetter)() const;
template<RenderStyleLengthGetter lengthGetter, RenderBoxComputedCSSValueGetter computedCSSValueGetter>
inline PassRefPtr<CSSValue> zoomAdjustedPaddingOrMarginPixelValue(RenderStyle* style, RenderObject* renderer)
{
Length unzoomedLength = (style->*lengthGetter)();
if (unzoomedLength.isFixed() || !renderer || !renderer->isBox())
return zoomAdjustedPixelValueForLength(unzoomedLength, style);
return zoomAdjustedPixelValue((toRenderBox(renderer)->*computedCSSValueGetter)(), style);
}
PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
{
Node* styledNode = this->styledNode();
......@@ -2072,12 +2084,8 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
if (style->locale().isNull())
return cssValuePool().createIdentifierValue(CSSValueAuto);
return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
case CSSPropertyMarginTop: {
Length marginTop = style->marginTop();
if (marginTop.isFixed() || !renderer || !renderer->isBox())
return zoomAdjustedPixelValueForLength(marginTop, style.get());
return zoomAdjustedPixelValue(toRenderBox(renderer)->marginTop(), style.get());
}
case CSSPropertyMarginTop:
return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginTop, &RenderBoxModelObject::marginTop>(style.get(), renderer);
case CSSPropertyMarginRight: {
Length marginRight = style->marginRight();
if (marginRight.isFixed() || !renderer || !renderer->isBox())
......@@ -2092,18 +2100,10 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
value = toRenderBox(renderer)->marginRight();
return zoomAdjustedPixelValue(value, style.get());
}
case CSSPropertyMarginBottom: {
Length marginBottom = style->marginBottom();
if (marginBottom.isFixed() || !renderer || !renderer->isBox())
return zoomAdjustedPixelValueForLength(marginBottom, style.get());
return zoomAdjustedPixelValue(toRenderBox(renderer)->marginBottom(), style.get());
}
case CSSPropertyMarginLeft: {
Length marginLeft = style->marginLeft();
if (marginLeft.isFixed() || !renderer || !renderer->isBox())
return zoomAdjustedPixelValueForLength(marginLeft, style.get());
return zoomAdjustedPixelValue(toRenderBox(renderer)->marginLeft(), style.get());
}
case CSSPropertyMarginBottom:
return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginBottom, &RenderBoxModelObject::marginBottom>(style.get(), renderer);
case CSSPropertyMarginLeft:
return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginLeft, &RenderBoxModelObject::marginLeft>(style.get(), renderer);
case CSSPropertyWebkitMarqueeDirection:
return cssValuePool().createValue(style->marqueeDirection());
case CSSPropertyWebkitMarqueeIncrement:
......@@ -2163,21 +2163,13 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
case CSSPropertyOverflowY:
return cssValuePool().createValue(style->overflowY());
case CSSPropertyPaddingTop:
if (renderer && renderer->isBox())
return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingTop(), style.get());
return zoomAdjustedPixelValueForLength(style->paddingTop(), style.get());
return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingTop, &RenderBoxModelObject::computedCSSPaddingTop>(style.get(), renderer);
case CSSPropertyPaddingRight:
if (renderer && renderer->isBox())
return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingRight(), style.get());
return zoomAdjustedPixelValueForLength(style->paddingRight(), style.get());
return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingRight, &RenderBoxModelObject::computedCSSPaddingRight>(style.get(), renderer);
case CSSPropertyPaddingBottom:
if (renderer && renderer->isBox())
return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingBottom(), style.get());
return zoomAdjustedPixelValueForLength(style->paddingBottom(), style.get());
return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingBottom, &RenderBoxModelObject::computedCSSPaddingBottom>(style.get(), renderer);
case CSSPropertyPaddingLeft:
if (renderer && renderer->isBox())
return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingLeft(), style.get());
return zoomAdjustedPixelValueForLength(style->paddingLeft(), style.get());
return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::paddingLeft, &RenderBoxModelObject::computedCSSPaddingLeft>(style.get(), renderer);
case CSSPropertyPageBreakAfter:
return cssValuePool().createValue(style->pageBreakAfter());
case CSSPropertyPageBreakBefore:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment