CSS3 calc: expressions with 'em' units do not zoom correctly.

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

Reviewed by Ojan Vafai.

Source/WebCore:

Each primitive value in a CSS calc expression now has (zoom) multiplier and scale factor applied
independently. Previously the multiplier and a single scale factor was applied to the expression
as a whole, but this failed to account for expressions involving font relative units. This is
because the multiplier should not be applied to font relative units.

Test: css3/calc/zoom-with-em.html

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::computeLengthDouble):

LayoutTests:

* css3/calc/zoom-with-em-expected.txt: Added.
* css3/calc/zoom-with-em.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127557 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 588248aa
2012-09-04 Mike Lawther <mikelawther@chromium.org>
CSS3 calc: expressions with 'em' units do not zoom correctly.
https://bugs.webkit.org/show_bug.cgi?id=95705
Reviewed by Ojan Vafai.
* css3/calc/zoom-with-em-expected.txt: Added.
* css3/calc/zoom-with-em.html: Added.
2012-09-04 Keishi Hattori <keishi@webkit.org>
REGRESSION(r126132): MediaSlider and MediaVolumeSlider thumbs don't match mouse when dragged
Tests that zooming a calc expression containing 'em' units works correctly
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS 310 is 310
PASS 310 is 310
PASS 310 is 310
PASS 310 is 310
PASS 310 is 310
PASS 311 is 311
PASS 310 is 310
PASS 310 is 310
PASS 310 is 310
PASS 310 is 310
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../fast/js/resources/js-test-pre.js"></script>
<style>
.test { display: height: 10px; background: #ddf; font: 20px/1 Ahem; }
#nocalc { width: 310px; }
#calc { width: -webkit-calc(15em + 10px); width: -moz-calc(15em + 10px); width: calc(15em + 10px); }
</style>
<div id="nocalc" class="test"></div>
<div id="calc" class="test"></div>
<script>
description("Tests that zooming a calc expression containing 'em' units works correctly");
zoomLevels = [0.67, 0.75, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2, 1];
calc = document.getElementById("calc");
nocalc = document.getElementById("nocalc");
for (var z = 0; z < zoomLevels.length; z++) {
var zoom = zoomLevels[z];
document.body.style.zoom = zoom;
shouldEvaluateTo(calc.offsetWidth + "", nocalc.offsetWidth + "");
}
</script>
<script src="../../fast/js/resources/js-test-post.js"></script>
2012-09-04 Mike Lawther <mikelawther@chromium.org>
CSS3 calc: expressions with 'em' units do not zoom correctly.
https://bugs.webkit.org/show_bug.cgi?id=95705
Reviewed by Ojan Vafai.
Each primitive value in a CSS calc expression now has (zoom) multiplier and scale factor applied
independently. Previously the multiplier and a single scale factor was applied to the expression
as a whole, but this failed to account for expressions involving font relative units. This is
because the multiplier should not be applied to font relative units.
Test: css3/calc/zoom-with-em.html
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::computeLengthDouble):
2012-09-04 Brian Anderson <brianderson@chromium.org>
[chromium] Prevent compositor ticking if it can't draw
......@@ -494,6 +494,10 @@ template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderSty
double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
{
if (m_primitiveUnitType == CSS_CALC)
// The multiplier and factor is applied to each value in the calc expression individually
return m_value.calc->computeLengthPx(style, rootStyle, multiplier, computingFontSize);
double factor;
switch (primitiveType()) {
......@@ -540,18 +544,11 @@ double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* r
return -1.0;
}
double computedValue;
if (m_primitiveUnitType == CSS_CALC)
// The multiplier is passed in as 1.0 here to ensure it is only applied once
computedValue = m_value.calc->computeLengthPx(style, rootStyle, 1.0, computingFontSize);
else
computedValue = getDoubleValue();
// We do not apply the zoom factor when we are computing the value of the font-size property. The zooming
// for font sizes is much more complicated, since we have to worry about enforcing the minimum font size preference
// as well as enforcing the implicit "smart minimum." In addition the CSS property text-size-adjust is used to
// prevent text from zooming at all. Therefore we will not apply the zoom here if we are computing font-size.
double result = computedValue * factor;
double result = getDoubleValue() * factor;
if (computingFontSize || isFontRelativeLength())
return result;
......
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