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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/FileUploadControlPainter.h" 5 #include "core/paint/FileUploadControlPainter.h"
6 6
7 #include "core/layout/LayoutButton.h" 7 #include "core/layout/LayoutButton.h"
8 #include "core/layout/LayoutFileUploadControl.h" 8 #include "core/layout/LayoutFileUploadControl.h"
9 #include "core/layout/TextRunConstructor.h" 9 #include "core/layout/TextRunConstructor.h"
10 #include "core/paint/LayoutObjectDrawingRecorder.h" 10 #include "core/paint/LayoutObjectDrawingRecorder.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 toLayoutButton(button->layoutObject())) 76 toLayoutButton(button->layoutObject()))
77 textY = paintOffset.y() + m_layoutFileUploadControl.borderTop() + 77 textY = paintOffset.y() + m_layoutFileUploadControl.borderTop() +
78 m_layoutFileUploadControl.paddingTop() + 78 m_layoutFileUploadControl.paddingTop() +
79 buttonLayoutObject->baselinePosition(AlphabeticBaseline, true, 79 buttonLayoutObject->baselinePosition(AlphabeticBaseline, true,
80 HorizontalLine, 80 HorizontalLine,
81 PositionOnContainingLine); 81 PositionOnContainingLine);
82 else 82 else
83 textY = LayoutUnit(m_layoutFileUploadControl.baselinePosition( 83 textY = LayoutUnit(m_layoutFileUploadControl.baselinePosition(
84 AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine)); 84 AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine));
85 TextRunPaintInfo textRunPaintInfo(textRun); 85 TextRunPaintInfo textRunPaintInfo(textRun);
86
87 const SimpleFontData* fontData =
88 m_layoutFileUploadControl.style()->font().primaryFont();
89 if (!fontData)
90 return;
86 // FIXME: Shouldn't these offsets be rounded? crbug.com/350474 91 // FIXME: Shouldn't these offsets be rounded? crbug.com/350474
87 textRunPaintInfo.bounds = FloatRect( 92 textRunPaintInfo.bounds = FloatRect(
88 textX.toFloat(), 93 textX.toFloat(), textY.toFloat() - fontData->getFontMetrics().ascent(),
89 textY.toFloat() - 94 textWidth, fontData->getFontMetrics().height());
90 m_layoutFileUploadControl.style()->getFontMetrics().ascent(),
91 textWidth,
92 m_layoutFileUploadControl.style()->getFontMetrics().height());
93 95
94 // Draw the filename. 96 // Draw the filename.
95 LayoutObjectDrawingRecorder recorder( 97 LayoutObjectDrawingRecorder recorder(
96 paintInfo.context, m_layoutFileUploadControl, paintInfo.phase, 98 paintInfo.context, m_layoutFileUploadControl, paintInfo.phase,
97 textRunPaintInfo.bounds); 99 textRunPaintInfo.bounds);
98 paintInfo.context.setFillColor( 100 paintInfo.context.setFillColor(
99 m_layoutFileUploadControl.resolveColor(CSSPropertyColor)); 101 m_layoutFileUploadControl.resolveColor(CSSPropertyColor));
100 paintInfo.context.drawBidiText( 102 paintInfo.context.drawBidiText(
101 font, textRunPaintInfo, 103 font, textRunPaintInfo,
102 FloatPoint(roundToInt(textX), roundToInt(textY))); 104 FloatPoint(roundToInt(textX), roundToInt(textY)));
103 } 105 }
104 106
105 // Paint the children. 107 // Paint the children.
106 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, 108 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo,
107 paintOffset); 109 paintOffset);
108 } 110 }
109 111
110 } // namespace blink 112 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698