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

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGTextQuery.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/SVGTextQuery.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGTextQuery.cpp b/third_party/WebKit/Source/core/layout/svg/SVGTextQuery.cpp
index 9669d3e554caeb9dfe5ff7619b34d6fbf4fc8fbf..55015417645ca0c5fb0bf2c1985215efb1cc7182 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGTextQuery.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/SVGTextQuery.cpp
@@ -466,10 +466,14 @@ static inline FloatRect calculateGlyphBoundaries(
int startPosition) {
const float scalingFactor = queryData->textLineLayout.scalingFactor();
ASSERT(scalingFactor);
- const float baseline =
- queryData->textLineLayout.scaledFont().getFontMetrics().floatAscent() /
- scalingFactor;
+ const SimpleFontData* fontData =
+ queryData->textLineLayout.scaledFont().primaryFont();
+ DCHECK(fontData);
+ if (!fontData)
+ return FloatRect();
+ const float baseline =
+ fontData->getFontMetrics().floatAscent() / scalingFactor;
float glyphOffsetInDirection =
calculateGlyphRange(queryData, fragment, 0, startPosition);
FloatPoint glyphPosition = logicalGlyphPositionToPhysical(
@@ -566,9 +570,15 @@ static bool characterNumberAtPositionCallback(QueryData* queryData,
const float scalingFactor = data->textLineLayout.scalingFactor();
ASSERT(scalingFactor);
+
+ const SimpleFontData* fontData =
+ data->textLineLayout.scaledFont().primaryFont();
+ DCHECK(fontData);
+ if (!fontData)
+ return false;
+
const float baseline =
- data->textLineLayout.scaledFont().getFontMetrics().floatAscent() /
- scalingFactor;
+ fontData->getFontMetrics().floatAscent() / scalingFactor;
// Test the query point against the bounds of the entire fragment first.
if (!fragment.boundingBox(baseline).contains(data->position))

Powered by Google App Engine
This is Rietveld 408576698