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

Unified Diff: third_party/WebKit/Source/core/css/resolver/FontBuilder.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/css/resolver/FontBuilder.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp b/third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp
index 958592ff0f51f64b83773dd5293ce516018f72e3..79ce1e42e1a9487c6bf9e351aa61ee157ea576ae 100644
--- a/third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp
@@ -319,11 +319,14 @@ void FontBuilder::updateAdjustedSize(FontDescription& fontDescription,
Font font(fontDescription);
font.update(fontSelector);
- if (!font.getFontMetrics().hasXHeight())
+
+ const SimpleFontData* fontData = font.primaryFont();
+
+ if (!fontData || !fontData->getFontMetrics().hasXHeight())
return;
const float sizeAdjust = fontDescription.sizeAdjust();
- float aspectValue = font.getFontMetrics().xHeight() / specifiedSize;
+ float aspectValue = fontData->getFontMetrics().xHeight() / specifiedSize;
float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize;
adjustedSize = getComputedSizeFromSpecifiedSize(
fontDescription, style.effectiveZoom(), adjustedSize);

Powered by Google App Engine
This is Rietveld 408576698