Diff
Modified: trunk/LayoutTests/ChangeLog (107300 => 107301)
--- trunk/LayoutTests/ChangeLog 2012-02-09 23:59:58 UTC (rev 107300)
+++ trunk/LayoutTests/ChangeLog 2012-02-10 00:05:10 UTC (rev 107301)
@@ -1,3 +1,13 @@
+2012-02-09 Matthew Delaney <[email protected]>
+
+ getComputedStyle() returns different values for different zoom levels
+ https://bugs.webkit.org/show_bug.cgi?id=32230
+
+ Reviewed by Beth Dakin.
+
+ * fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size-expected.txt: Added.
+ * fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size.html: Added.
+
2012-02-09 Julien Chaffraix <[email protected]>
Unreviewed gardening.
Added: trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size-expected.txt (0 => 107301)
--- trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size-expected.txt 2012-02-10 00:05:10 UTC (rev 107301)
@@ -0,0 +1,112 @@
+Checks that getComputedStyle() on a zoomed element returns the right thing.
+Results while display:block
+
+Property Pass? Set Value Computed Value
+background-position PASS 10px 10px 10px 10px
+background-size PASS 400px 300px 400px 300px
+-webkit-border-horizontal-spacing PASS 10px 10px
+-webkit-border-vertical-spacing PASS 10px 10px
+border-top-style PASS solid solid
+border-top-width PASS 2px 2px
+border-right-style PASS solid solid
+border-right-width PASS 2px 2px
+border-bottom-style PASS solid solid
+border-bottom-width PASS 2px 2px
+border-left-style PASS solid solid
+border-left-width PASS 2px 2px
+border-top-left-radius PASS 5px 5px
+border-top-right-radius PASS 5px 5px
+border-bottom-left-radius PASS 5px 5px
+border-bottom-right-radius PASS 5px 5px
+outline-style PASS solid solid
+outline-width PASS 2px 2px
+-webkit-column-rule-width PASS 10px 10px
+-webkit-column-rule-style PASS solid solid
+-webkit-column-width PASS 80px 80px
+-webkit-column-gap PASS 20px 20px
+-webkit-marquee-increment PASS 10px 10px
+-webkit-mask-position PASS 10px 10px 10px 10px
+-webkit-mask-size PASS 10px 10px 10px 10px
+-webkit-perspective PASS 400px 400px
+-webkit-perspective-origin PASS 20px 20px 20px 20px
+-webkit-text-stroke-width PASS 2px 2px
+-webkit-transform-origin PASS 10px 10px 10px 10px
+position PASS absolute absolute
+left PASS 20px 20px
+top PASS 20px 20px
+right PASS 50px 50px
+bottom PASS 50px 50px
+font-size PASS 20px 20px
+width PASS 400px 400px
+max-width PASS 900px 900px
+min-width PASS 200px 200px
+height PASS 250px 250px
+max-height PASS 600px 600px
+min-height PASS 200px 200px
+letter-spacing PASS 2px 2px
+word-spacing PASS 10px 10px
+margin-top PASS 10px 10px
+margin-right PASS 10px 10px
+margin-bottom PASS 10px 10px
+margin-left PASS 10px 10px
+padding-top PASS 10px 10px
+padding-right PASS 10px 10px
+padding-bottom PASS 10px 10px
+padding-left PASS 10px 10px
+text-indent PASS 10px 10px
+Results while display:none
+
+Hidden Property Pass? Set Value Computed Value
+background-position PASS 10px 10px 10px 10px
+background-size PASS 400px 300px 400px 300px
+-webkit-border-horizontal-spacing PASS 10px 10px
+-webkit-border-vertical-spacing PASS 10px 10px
+border-top-style PASS solid solid
+border-top-width PASS 2px 2px
+border-right-style PASS solid solid
+border-right-width PASS 2px 2px
+border-bottom-style PASS solid solid
+border-bottom-width PASS 2px 2px
+border-left-style PASS solid solid
+border-left-width PASS 2px 2px
+border-top-left-radius PASS 5px 5px
+border-top-right-radius PASS 5px 5px
+border-bottom-left-radius PASS 5px 5px
+border-bottom-right-radius PASS 5px 5px
+outline-style PASS solid solid
+outline-width PASS 2px 2px
+-webkit-column-rule-width PASS 10px 10px
+-webkit-column-rule-style PASS solid solid
+-webkit-column-width PASS 80px 80px
+-webkit-column-gap PASS 20px 20px
+-webkit-marquee-increment PASS 10px 10px
+-webkit-mask-position PASS 10px 10px 10px 10px
+-webkit-mask-size PASS 10px 10px 10px 10px
+-webkit-perspective PASS 400px 400px
+-webkit-perspective-origin PASS 20px 20px 20px 20px
+-webkit-text-stroke-width PASS 2px 2px
+-webkit-transform-origin PASS 10px 10px 10px 10px
+position PASS absolute absolute
+left PASS 20px 20px
+top PASS 20px 20px
+right PASS 50px 50px
+bottom PASS 50px 50px
+font-size PASS 20px 20px
+width PASS 400px 400px
+max-width PASS 900px 900px
+min-width PASS 200px 200px
+height PASS 250px 250px
+max-height PASS 600px 600px
+min-height PASS 200px 200px
+letter-spacing PASS 2px 2px
+word-spacing PASS 10px 10px
+margin-top PASS 10px 10px
+margin-right PASS 10px 10px
+margin-bottom PASS 10px 10px
+margin-left PASS 10px 10px
+padding-top PASS 10px 10px
+padding-right PASS 10px 10px
+padding-bottom PASS 10px 10px
+padding-left PASS 10px 10px
+text-indent PASS 10px 10px
+This div has a zoom value of "2." It has a width of 300px. Its background size is: 400px by 300px.
Added: trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size.html (0 => 107301)
--- trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size.html (rev 0)
+++ trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size.html 2012-02-10 00:05:10 UTC (rev 107301)
@@ -0,0 +1,215 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<title>getComputedStyle() Zoom and Background Size</title>
+<style>
+ #test_area {
+ position: relative;
+ }
+ .test_div {
+ zoom: 2;
+ width: 300px;
+ }
+
+ #zoomed_and_displayed {
+ display: block;
+ }
+ #zoomed_and_hidden {
+ display: none;
+ }
+
+ #results {
+ overflow: hidden;
+ }
+ .results {
+ float: left;
+ margin-right: 2em;
+ }
+ .results table {
+ border-collapse: collapse;
+ line-height: 1.4em;
+ }
+ .results th {
+ text-align: left;
+ }
+ .results th,
+ .results td {
+ padding: 0 1em 0 0;
+ border-bottom: 1px solid #ddd;
+ }
+ .results .test-pass {
+ color: green;
+ }
+ .results .test-fail {
+ color: red;
+ }
+</style>
+</head>
+<body>
+ Checks that getComputedStyle() on a zoomed element returns the right thing.
+ <section id="results">
+ <section class="results">
+ <h2>Results while display:block</h2>
+ <table>
+ <thead>
+ <tr>
+ <th>Property</th>
+ <th>Pass?</th>
+ <th>Set Value</th>
+ <th>Computed Value</th>
+ <tbody id="results_body">
+ </tbody>
+ </table>
+ </section>
+
+ <section class="results">
+ <h2>Results while display:none</h2>
+ <table>
+ <thead>
+ <tr>
+ <th>Hidden Property</th>
+ <th>Pass?</th>
+ <th>Set Value</th>
+ <th>Computed Value</th>
+ <tbody id="results_hidden_body">
+ </tbody>
+ </table>
+ </section>
+ </section>
+
+ <div id="test_area">
+ <div id="zoomed_and_displayed" class="test_div">
+ This div has a zoom value of "2." It has a width of 300px.
+ Its background size is: 400px by 300px.
+ </div>
+ <div id="zoomed_and_hidden" class="test_div">
+ This div is has a zoom value of "2" and is hidden. It has a width of 300px.
+ Its background size is: 400px by 300px.
+ </div>
+ </div>
+
+ <script type="text/_javascript_" charset="utf-8">
+ if (window.layoutTestController)
+ window.layoutTestController.dumpAsText();
+
+ var propertiesToCheck = {
+ "background-position": "10px 10px",
+ "background-size": "400px 300px",
+ "-webkit-border-horizontal-spacing": "10px",
+ "-webkit-border-vertical-spacing": "10px",
+
+ // Need style or width won't be applied
+ "border-top-style": "solid",
+ "border-top-width": "2px",
+ "border-right-style": "solid",
+ "border-right-width": "2px",
+ "border-bottom-style": "solid",
+ "border-bottom-width": "2px",
+ "border-left-style": "solid",
+ "border-left-width": "2px",
+
+ "border-top-left-radius": "5px",
+ "border-top-right-radius": "5px",
+ "border-bottom-left-radius": "5px",
+ "border-bottom-right-radius": "5px",
+
+ // Need style or width won't be applied
+ "outline-style": "solid",
+ "outline-width": "2px",
+
+ // Need style or width won't be applied
+ "-webkit-column-rule-width": "10px",
+ "-webkit-column-rule-style": "solid",
+
+ "-webkit-column-width": "80px",
+ "-webkit-column-gap": "20px",
+
+ "-webkit-marquee-increment": "10px",
+ "-webkit-mask-position": "10px 10px",
+ "-webkit-mask-size": "10px 10px",
+ "-webkit-perspective": "400px",
+ "-webkit-perspective-origin": "20px 20px",
+ "-webkit-text-stroke-width": "2px",
+ "-webkit-transform-origin": "10px 10px",
+
+ "position":"absolute",
+
+ "left": "20px",
+ "top": "20px",
+ "right": "50px",
+ "bottom": "50px",
+
+ "font-size": "20px",
+ "width": "400px",
+ "max-width": "900px",
+ "min-width": "200px",
+ "height": "250px",
+ "max-height": "600px",
+ "min-height": "200px",
+ "letter-spacing": "2px",
+ "word-spacing": "10px",
+
+ "margin-top": "10px",
+ "margin-right": "10px",
+ "margin-bottom": "10px",
+ "margin-left": "10px",
+
+ "padding-top": "10px",
+ "padding-right": "10px",
+ "padding-bottom": "10px",
+ "padding-left": "10px",
+
+ "text-indent": "10px"
+ };
+
+
+ var zoomedAndDisplayed = document.getElementById("zoomed_and_displayed"),
+ zoomedAndHidden = document.getElementById("zoomed_and_hidden"),
+ tbody = document.getElementById("results_body"),
+ tbodyHidden = document.getElementById("results_hidden_body"),
+ overallPass = true,
+ computed;
+
+ var testProperties = function(testElement, resultBody) {
+ // Apply properties
+ for (var property in propertiesToCheck) {
+ testElement.style[property] = propertiesToCheck[property];
+ }
+
+ // Check properties
+ var computed = document.defaultView.getComputedStyle(testElement)
+ for (var property in propertiesToCheck) {
+ var originalValue = propertiesToCheck[property],
+ computedValue = computed[property],
+ pass = computedValue == originalValue;
+
+ var row = document.createElement("tr"),
+ propertyCell = document.createElement("td"),
+ passCell = document.createElement("td"),
+ originalCell = document.createElement("td"),
+ computedCell = document.createElement("td");
+
+ propertyCell.appendChild(document.createTextNode(property));
+ passCell.appendChild(document.createTextNode(pass ? "PASS" : "FAIL"));
+ originalCell.appendChild(document.createTextNode(originalValue));
+ computedCell.appendChild(document.createTextNode(computedValue));
+ row.appendChild(propertyCell);
+ row.appendChild(passCell);
+ row.appendChild(originalCell);
+ row.appendChild(computedCell);
+ row.className = "test-" + (pass ? "pass" : "fail");
+ resultBody.appendChild(row);
+
+ overallPass = overallPass && pass;
+ }
+ };
+
+ testProperties(zoomedAndDisplayed, tbody);
+ testProperties(zoomedAndHidden, tbodyHidden);
+ </script>
+
+
+
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (107300 => 107301)
--- trunk/Source/WebCore/ChangeLog 2012-02-09 23:59:58 UTC (rev 107300)
+++ trunk/Source/WebCore/ChangeLog 2012-02-10 00:05:10 UTC (rev 107301)
@@ -1,3 +1,18 @@
+2012-02-09 Matthew Delaney <[email protected]>
+
+ getComputedStyle() returns different values for different zoom levels
+ https://bugs.webkit.org/show_bug.cgi?id=32230
+
+ Reviewed by Beth Dakin.
+
+ Test: fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::fillSizeToCSSValue): Pass down the RenderStyle for use in adjusting
+ values to account for zoom.
+ (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Adjust additional
+ properties that are affected by zoom.
+
2012-02-09 Kentaro Hara <[email protected]>
Rename [Return] to [CustomReturn]
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (107300 => 107301)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2012-02-09 23:59:58 UTC (rev 107300)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2012-02-10 00:05:10 UTC (rev 107301)
@@ -1133,7 +1133,7 @@
return list.release();
}
-static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, CSSValuePool* cssValuePool)
+static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, const RenderStyle* style, CSSValuePool* cssValuePool)
{
if (fillSize.type == Contain)
return cssValuePool->createIdentifierValue(CSSValueContain);
@@ -1142,11 +1142,11 @@
return cssValuePool->createIdentifierValue(CSSValueCover);
if (fillSize.size.height().isAuto())
- return cssValuePool->createValue(fillSize.size.width());
+ return zoomAdjustedPixelValueForLength(fillSize.size.width(), style, cssValuePool);
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- list->append(cssValuePool->createValue(fillSize.size.width()));
- list->append(cssValuePool->createValue(fillSize.size.height()));
+ list->append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style, cssValuePool));
+ list->append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style, cssValuePool));
return list.release();
}
@@ -1324,11 +1324,11 @@
case CSSPropertyWebkitMaskSize: {
const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
if (!layers->next())
- return fillSizeToCSSValue(layers->size(), cssValuePool);
+ return fillSizeToCSSValue(layers->size(), style.get(), cssValuePool);
RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
- list->append(fillSizeToCSSValue(currLayer->size(), cssValuePool));
+ list->append(fillSizeToCSSValue(currLayer->size(), style.get(), cssValuePool));
return list.release();
}
@@ -1394,16 +1394,16 @@
const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPosition ? style->maskLayers() : style->backgroundLayers();
if (!layers->next()) {
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- list->append(cssValuePool->createValue(layers->xPosition()));
- list->append(cssValuePool->createValue(layers->yPosition()));
+ list->append(zoomAdjustedPixelValueForLength(layers->xPosition(), style.get(), cssValuePool));
+ list->append(zoomAdjustedPixelValueForLength(layers->yPosition(), style.get(), cssValuePool));
return list.release();
}
RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
RefPtr<CSSValueList> positionList = CSSValueList::createSpaceSeparated();
- positionList->append(cssValuePool->createValue(currLayer->xPosition()));
- positionList->append(cssValuePool->createValue(currLayer->yPosition()));
+ positionList->append(zoomAdjustedPixelValueForLength(currLayer->xPosition(), style.get(), cssValuePool));
+ positionList->append(zoomAdjustedPixelValueForLength(currLayer->xPosition(), style.get(), cssValuePool));
list->append(positionList);
}
@@ -1741,18 +1741,18 @@
const Length& maxHeight = style->maxHeight();
if (maxHeight.isUndefined())
return cssValuePool->createIdentifierValue(CSSValueNone);
- return cssValuePool->createValue(maxHeight);
+ return zoomAdjustedPixelValueForLength(maxHeight, style.get(), cssValuePool);
}
case CSSPropertyMaxWidth: {
const Length& maxWidth = style->maxWidth();
if (maxWidth.isUndefined())
return cssValuePool->createIdentifierValue(CSSValueNone);
- return cssValuePool->createValue(maxWidth);
+ return zoomAdjustedPixelValueForLength(maxWidth, style.get(), cssValuePool);
}
case CSSPropertyMinHeight:
- return cssValuePool->createValue(style->minHeight());
+ return zoomAdjustedPixelValueForLength(style->minHeight(), style.get(), cssValuePool);
case CSSPropertyMinWidth:
- return cssValuePool->createValue(style->minWidth());
+ return zoomAdjustedPixelValueForLength(style->minWidth(), style.get(), cssValuePool);
case CSSPropertyOpacity:
return cssValuePool->createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
case CSSPropertyOrphans:
@@ -1776,19 +1776,19 @@
case CSSPropertyPaddingTop:
if (renderer && renderer->isBox())
return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingTop(false), style.get(), cssValuePool);
- return cssValuePool->createValue(style->paddingTop());
+ return zoomAdjustedPixelValueForLength(style->paddingTop(), style.get(), cssValuePool);
case CSSPropertyPaddingRight:
if (renderer && renderer->isBox())
return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingRight(false), style.get(), cssValuePool);
- return cssValuePool->createValue(style->paddingRight());
+ return zoomAdjustedPixelValueForLength(style->paddingRight(), style.get(), cssValuePool);
case CSSPropertyPaddingBottom:
if (renderer && renderer->isBox())
return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingBottom(false), style.get(), cssValuePool);
- return cssValuePool->createValue(style->paddingBottom());
+ return zoomAdjustedPixelValueForLength(style->paddingBottom(), style.get(), cssValuePool);
case CSSPropertyPaddingLeft:
if (renderer && renderer->isBox())
return zoomAdjustedPixelValue(toRenderBox(renderer)->paddingLeft(false), style.get(), cssValuePool);
- return cssValuePool->createValue(style->paddingLeft());
+ return zoomAdjustedPixelValueForLength(style->paddingLeft(), style.get(), cssValuePool);
case CSSPropertyPageBreakAfter:
return cssValuePool->createValue(style->pageBreakAfter());
case CSSPropertyPageBreakBefore:
@@ -1839,7 +1839,7 @@
}
}
case CSSPropertyTextIndent:
- return cssValuePool->createValue(style->textIndent());
+ return zoomAdjustedPixelValueForLength(style->textIndent(), style.get(), cssValuePool);
case CSSPropertyTextShadow:
return valueForShadow(style->textShadow(), propertyID, style.get());
case CSSPropertyTextRendering: