Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(954)

Unified Diff: third_party/WebKit/Source/core/layout/TextAutosizer.cpp

Issue 2100013002: Implement the new text-size-adjust CSS property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup convertTextSizeAdjust and add a test that better covers it Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/TextAutosizer.cpp
diff --git a/third_party/WebKit/Source/core/layout/TextAutosizer.cpp b/third_party/WebKit/Source/core/layout/TextAutosizer.cpp
index 3f6ee8e3974e65d83458b685f84a00f7f0967815..81a6ef9e8343e7b3cead5c3da32d812496fe9245 100644
--- a/third_party/WebKit/Source/core/layout/TextAutosizer.cpp
+++ b/third_party/WebKit/Source/core/layout/TextAutosizer.cpp
@@ -988,6 +988,13 @@ void TextAutosizer::applyMultiplier(LayoutObject* layoutObject, float multiplier
{
ASSERT(layoutObject);
ComputedStyle& currentStyle = layoutObject->mutableStyleRef();
+ if (!currentStyle.getTextSizeAdjust().isAuto()) {
+ multiplier = currentStyle.getTextSizeAdjust().multiplier();
+ } else if (multiplier < 1) {
+ // Unlike text-size-adjust, the text autosizer should only inflate fonts.
+ multiplier = 1;
+ }
+
if (currentStyle.textAutosizingMultiplier() == multiplier)
return;
@@ -1183,6 +1190,8 @@ TextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo()
float TextAutosizer::computeAutosizedFontSize(float specifiedSize, float multiplier)
{
+ DCHECK_GE(multiplier, 0);
+
// Somewhat arbitrary "pleasant" font size.
const float pleasantSize = 16;
@@ -1199,7 +1208,8 @@ float TextAutosizer::computeAutosizedFontSize(float specifiedSize, float multipl
const float gradientAfterPleasantSize = 0.5;
float computedSize;
- if (specifiedSize <= pleasantSize) {
+ // Skip linear backoff for multipliers that shrink the size or when the font sizes are small.
+ if (multiplier <= 1 || specifiedSize <= pleasantSize) {
computedSize = multiplier * specifiedSize;
} else {
computedSize = multiplier * pleasantSize + gradientAfterPleasantSize * (specifiedSize - pleasantSize);

Powered by Google App Engine
This is Rietveld 408576698