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

Unified Diff: third_party/WebKit/Source/core/paint/FileUploadControlPainter.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/FileUploadControlPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/FileUploadControlPainter.cpp b/third_party/WebKit/Source/core/paint/FileUploadControlPainter.cpp
index 8a48617b394da08b4b5996185b99331bc6cdfc5c..0dab0a98e6e9b13c5b7ef5ea3e4f39431f219dbb 100644
--- a/third_party/WebKit/Source/core/paint/FileUploadControlPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/FileUploadControlPainter.cpp
@@ -83,13 +83,15 @@ void FileUploadControlPainter::paintObject(const PaintInfo& paintInfo,
textY = LayoutUnit(m_layoutFileUploadControl.baselinePosition(
AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine));
TextRunPaintInfo textRunPaintInfo(textRun);
+
+ const SimpleFontData* fontData =
+ m_layoutFileUploadControl.style()->font().primaryFont();
+ if (!fontData)
+ return;
// FIXME: Shouldn't these offsets be rounded? crbug.com/350474
textRunPaintInfo.bounds = FloatRect(
- textX.toFloat(),
- textY.toFloat() -
- m_layoutFileUploadControl.style()->getFontMetrics().ascent(),
- textWidth,
- m_layoutFileUploadControl.style()->getFontMetrics().height());
+ textX.toFloat(), textY.toFloat() - fontData->getFontMetrics().ascent(),
+ textWidth, fontData->getFontMetrics().height());
// Draw the filename.
LayoutObjectDrawingRecorder recorder(

Powered by Google App Engine
This is Rietveld 408576698