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

Unified Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.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/svg/LayoutSVGInlineText.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
index 126a293f9ef811ae78616a0eb1e1551819ccb34a..1366c87c9cc334ef93eb94dbcfe1594dd52ae986 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp
@@ -151,8 +151,11 @@ PositionWithAffinity LayoutSVGInlineText::positionForPoint(
return createPositionWithAffinity(0);
ASSERT(m_scalingFactor);
+
+ const SimpleFontData* fontData = m_scaledFont.primaryFont();
+ DCHECK(fontData);
float baseline =
- m_scaledFont.getFontMetrics().floatAscent() / m_scalingFactor;
+ fontData ? fontData->getFontMetrics().floatAscent() / m_scalingFactor : 0;
LayoutBlock* containingBlock = this->containingBlock();
ASSERT(containingBlock);
@@ -287,8 +290,13 @@ void LayoutSVGInlineText::addMetricsFromRun(const TextRun& run,
scaledFont().individualCharacterRanges(run);
synthesizeGraphemeWidths(run, charRanges);
+ const SimpleFontData* fontData = scaledFont().primaryFont();
+ DCHECK(fontData);
+ if (!fontData)
+ return;
+
const float cachedFontHeight =
- scaledFont().getFontMetrics().floatHeight() / m_scalingFactor;
+ fontData->getFontMetrics().floatHeight() / m_scalingFactor;
const bool preserveWhiteSpace = styleRef().whiteSpace() == PRE;
const unsigned runLength = run.length();

Powered by Google App Engine
This is Rietveld 408576698