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

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.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/SVGTextLayoutEngine.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp
index 0a91c0cddf3f7cc5a6336bfeef8534b4656d6acc..c5d87328b6ec5d431b1d6980f9102d62a27138b6 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp
@@ -125,9 +125,14 @@ void SVGTextLayoutEngine::computeCurrentFragmentMetrics(
const Font& scaledFont = textLineLayout.scaledFont();
FloatRect glyphOverflowBounds;
+ const SimpleFontData* fontData = scaledFont.primaryFont();
+ DCHECK(fontData);
+ if (!fontData)
+ return;
+
float width = scaledFont.width(run, nullptr, &glyphOverflowBounds);
- float ascent = scaledFont.getFontMetrics().floatAscent();
- float descent = scaledFont.getFontMetrics().floatDescent();
+ float ascent = fontData->getFontMetrics().floatAscent();
+ float descent = fontData->getFontMetrics().floatDescent();
m_currentTextFragment.glyphOverflow.setFromBounds(glyphOverflowBounds, ascent,
descent, width);
m_currentTextFragment.glyphOverflow.top /= scalingFactor;
@@ -135,7 +140,7 @@ void SVGTextLayoutEngine::computeCurrentFragmentMetrics(
m_currentTextFragment.glyphOverflow.right /= scalingFactor;
m_currentTextFragment.glyphOverflow.bottom /= scalingFactor;
- float height = scaledFont.getFontMetrics().floatHeight();
+ float height = fontData->getFontMetrics().floatHeight();
m_currentTextFragment.height = height / scalingFactor;
m_currentTextFragment.width = width / scalingFactor;
}

Powered by Google App Engine
This is Rietveld 408576698