Commit bcf2b820 authored by skobes@chromium.org's avatar skobes@chromium.org

Apply the text autosizing multiplier in FontBuilder::updateComputedSize.

When we resolve style for an element with an explicit font size, we build a new
FontDescription but we inherit the text autosizing multiplier from the parent's
RenderStyle (see http://crbug.com/380903).

We need to respect this multiplier when we initialize the computed size in the
FontDescription, or else they are out of sync with each other.  They remain out
of sync even after we layout the element, because TextAutosizer sees that the
element already has the correct multiplier and doesn't touch it.

BUG=403132

Review URL: https://codereview.chromium.org/472893004

git-svn-id: svn://svn.chromium.org/blink/trunk@180322 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 59fe2ab0
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=800">
<style>
body {
font-size: 16px;
margin: 0;
overflow: hidden;
width: 800px;
}
</style>
</head>
<body>
<div id="outer" style="font-size: 2.5rem">
This test verifies that a text autosizing multiplier that is inherited from a
parent element's RenderStyle is reflected in the computed font size, even if the
specified font size is different and the next text autosizing pass doesn't alter
the multiplier.
<div style="font-size: 30px">
This test verifies that a text autosizing multiplier that is inherited from a
parent element's RenderStyle is reflected in the computed font size, even if the
specified font size is different and the next text autosizing pass doesn't alter
the multiplier.
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=800">
<style>
body {
font-size: 16px;
margin: 0;
overflow: hidden;
width: 800px;
}
</style>
<script src="resources/autosizingTest.js"></script>
</head>
<body>
<div id="outer">
This test verifies that a text autosizing multiplier that is inherited from a
parent element's RenderStyle is reflected in the computed font size, even if the
specified font size is different and the next text autosizing pass doesn't alter
the multiplier.
</div>
<script>
var outer = document.querySelector('#outer');
var inner = document.createElement('div');
inner.innerText = outer.innerText;
inner.style.fontSize = '12px';
outer.appendChild(inner);
</script>
</body>
</html>
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "core/frame/Settings.h" #include "core/frame/Settings.h"
#include "core/rendering/RenderTheme.h" #include "core/rendering/RenderTheme.h"
#include "core/rendering/RenderView.h" #include "core/rendering/RenderView.h"
#include "core/rendering/TextAutosizer.h"
#include "platform/fonts/FontDescription.h" #include "platform/fonts/FontDescription.h"
#include "platform/text/LocaleToScriptMapping.h" #include "platform/text/LocaleToScriptMapping.h"
...@@ -533,7 +534,12 @@ void FontBuilder::updateComputedSize(RenderStyle* style, const RenderStyle* pare ...@@ -533,7 +534,12 @@ void FontBuilder::updateComputedSize(RenderStyle* style, const RenderStyle* pare
{ {
FontDescriptionChangeScope scope(this); FontDescriptionChangeScope scope(this);
scope.fontDescription().setComputedSize(getComputedSizeFromSpecifiedSize(scope.fontDescription(), style->effectiveZoom(), scope.fontDescription().specifiedSize())); float computedSize = getComputedSizeFromSpecifiedSize(scope.fontDescription(), style->effectiveZoom(), scope.fontDescription().specifiedSize());
float multiplier = style->textAutosizingMultiplier();
if (multiplier > 1)
computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, multiplier);
scope.fontDescription().setComputedSize(computedSize);
} }
// FIXME: style param should come first // FIXME: style param should come first
......
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