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

Unified Diff: third_party/WebKit/Source/core/css/CSSToLengthConversionData.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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/CSSToLengthConversionData.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSToLengthConversionData.cpp b/third_party/WebKit/Source/core/css/CSSToLengthConversionData.cpp
index 0874a35243ff5cccb3d434e3ae3d0cf6992bb036..e1f3d7f441db8e6986aa7b2873fd1f8e8ace53a1 100644
--- a/third_party/WebKit/Source/core/css/CSSToLengthConversionData.cpp
+++ b/third_party/WebKit/Source/core/css/CSSToLengthConversionData.cpp
@@ -52,17 +52,22 @@ CSSToLengthConversionData::FontSizes::FontSizes(const ComputedStyle* style,
float CSSToLengthConversionData::FontSizes::ex() const {
ASSERT(m_font);
+ const SimpleFontData* fontData = m_font->primaryFont();
+ DCHECK(fontData);
+
// FIXME: We have a bug right now where the zoom will be applied twice to EX
// units. We really need to compute EX using fontMetrics for the original
// specifiedSize and not use our actual constructed layoutObject font.
- if (!m_font->getFontMetrics().hasXHeight())
+ if (!fontData || !fontData->getFontMetrics().hasXHeight())
return m_em / 2.0f;
- return m_font->getFontMetrics().xHeight();
+ return fontData->getFontMetrics().xHeight();
}
float CSSToLengthConversionData::FontSizes::ch() const {
- ASSERT(m_font);
- return m_font->getFontMetrics().zeroWidth();
+ DCHECK(m_font);
+ const SimpleFontData* fontData = m_font->primaryFont();
+ DCHECK(fontData);
+ return fontData ? fontData->getFontMetrics().zeroWidth() : 0;
}
CSSToLengthConversionData::ViewportSize::ViewportSize(
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698