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

Unified Diff: third_party/WebKit/Source/core/paint/EmbeddedObjectPainter.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/paint/EmbeddedObjectPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/EmbeddedObjectPainter.cpp b/third_party/WebKit/Source/core/paint/EmbeddedObjectPainter.cpp
index 4af07c8c9974fb77b3411b750b221e950183bf73..dadad9ff4aed8aa37bee978357062cc51262502a 100644
--- a/third_party/WebKit/Source/core/paint/EmbeddedObjectPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/EmbeddedObjectPainter.cpp
@@ -54,13 +54,14 @@ void EmbeddedObjectPainter::paintReplaced(const PaintInfo& paintInfo,
context.clip(pixelSnappedIntRect(contentRect));
Font font = replacementTextFont();
- // TODO(trchen): Speculative fix for crbug.com/481880
- // With last resort font, how could this ever be null?
- ASSERT(font.primaryFont());
- if (!font.primaryFont())
+ const SimpleFontData* fontData = font.primaryFont();
+ DCHECK(fontData);
+ if (!fontData)
return;
+
TextRun textRun(m_layoutEmbeddedObject.unavailablePluginReplacementText());
- FloatSize textGeometry(font.width(textRun), font.getFontMetrics().height());
+ FloatSize textGeometry(font.width(textRun),
+ fontData->getFontMetrics().height());
LayoutRect backgroundRect(
0, 0,
@@ -84,7 +85,7 @@ void EmbeddedObjectPainter::paintReplaced(const PaintInfo& paintInfo,
context.setFillColor(scaleAlpha(Color::black, replacementTextTextOpacity));
context.drawBidiText(
font, runInfo,
- textRect.location() + FloatSize(0, font.getFontMetrics().ascent()));
+ textRect.location() + FloatSize(0, fontData->getFontMetrics().ascent()));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698