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

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

Issue 2145903002: Add heuristic to LayoutTextControl::hasValidAvgCharWidth() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/LayoutTextControlSingleLine.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp b/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp
index 47e6e63e040e414729a7a7b6f0f30b4184bfa28d..138efd024b1388d9d43a83fbb76c1594ed67a420 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp
@@ -231,15 +231,16 @@ LayoutUnit LayoutTextControlSingleLine::preferredContentLogicalWidth(float charW
LayoutUnit result = LayoutUnit::fromFloatCeil(charWidth * factor);
float maxCharWidth = 0.f;
- AtomicString family = styleRef().font().getFontDescription().family().family();
+ const Font& font = style()->font();
+ AtomicString family = font.getFontDescription().family().family();
// Match the default system font to the width of MS Shell Dlg, the default
// font for textareas in Firefox, Safari Win and IE for some encodings (in
// IE, the default font is encoding specific). 4027 is the (xMax - xMin)
// value in the "head" font table for MS Shell Dlg.
if (LayoutTheme::theme().needsHackForTextControlWithFontFamily(family))
maxCharWidth = scaleEmToUnits(4027);
- else if (hasValidAvgCharWidth(family))
- maxCharWidth = roundf(styleRef().font().primaryFont()->maxCharWidth());
+ else if (hasValidAvgCharWidth(font.primaryFont(), family))
+ maxCharWidth = roundf(font.primaryFont()->maxCharWidth());
// For text inputs, IE adds some extra width.
if (maxCharWidth > 0.f)

Powered by Google App Engine
This is Rietveld 408576698