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

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

Issue 2416033003: Remove unsafe getFontMetrics methods (Closed)
Patch Set: Address wkroman suggestions Created 4 years, 2 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/LayoutTextControl.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp b/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp
index 122547ed762af3ce1a90d3ab1a509b7b24fc0abb..f7f18e7ba944280f8057afd9192708d07f05bd5c 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp
@@ -202,15 +202,17 @@ static const char* const fontFamiliesWithInvalidCharWidth[] = {
// avgCharWidth from the width of a '0'. This only seems to apply to a fixed
// number of Mac fonts, but, in order to get similar rendering across platforms,
// we do this check for all platforms.
-bool LayoutTextControl::hasValidAvgCharWidth(const SimpleFontData* font,
+bool LayoutTextControl::hasValidAvgCharWidth(const SimpleFontData* fontData,
const AtomicString& family) {
// Some fonts match avgCharWidth to CJK full-width characters.
// Heuristic check to avoid such fonts.
- DCHECK(font);
- const FontMetrics& metrics = font->getFontMetrics();
- if (metrics.hasZeroWidth() &&
- font->avgCharWidth() > metrics.zeroWidth() * 1.7)
- return false;
+ DCHECK(fontData);
+ if (fontData) {
+ const FontMetrics& metrics = fontData->getFontMetrics();
+ if (metrics.hasZeroWidth() &&
+ fontData->avgCharWidth() > metrics.zeroWidth() * 1.7)
+ return false;
+ }
static HashSet<AtomicString>* fontFamiliesWithInvalidCharWidthMap = nullptr;

Powered by Google App Engine
This is Rietveld 408576698