OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/FileUploadControlPainter.h" | 6 #include "core/paint/FileUploadControlPainter.h" |
7 | 7 |
8 #include "core/layout/LayoutButton.h" | 8 #include "core/layout/LayoutButton.h" |
9 #include "core/layout/LayoutFileUploadControl.h" | 9 #include "core/layout/LayoutFileUploadControl.h" |
10 #include "core/layout/PaintInfo.h" | 10 #include "core/layout/PaintInfo.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 float textWidth = font.width(textRun); | 49 float textWidth = font.width(textRun); |
50 LayoutUnit textX; | 50 LayoutUnit textX; |
51 if (m_renderFileUploadControl.style()->isLeftToRightDirection()) | 51 if (m_renderFileUploadControl.style()->isLeftToRightDirection()) |
52 textX = contentLeft + buttonAndSpacingWidth; | 52 textX = contentLeft + buttonAndSpacingWidth; |
53 else | 53 else |
54 textX = contentLeft + m_renderFileUploadControl.contentWidth() - but
tonAndSpacingWidth - textWidth; | 54 textX = contentLeft + m_renderFileUploadControl.contentWidth() - but
tonAndSpacingWidth - textWidth; |
55 | 55 |
56 LayoutUnit textY = 0; | 56 LayoutUnit textY = 0; |
57 // We want to match the button's baseline | 57 // We want to match the button's baseline |
58 // FIXME: Make this work with transforms. | 58 // FIXME: Make this work with transforms. |
59 if (LayoutButton* buttonRenderer = toLayoutButton(button->renderer())) | 59 if (LayoutButton* buttonRenderer = toLayoutButton(button->layoutObject()
)) |
60 textY = paintOffset.y() + m_renderFileUploadControl.borderTop() + m_
renderFileUploadControl.paddingTop() + buttonRenderer->baselinePosition(Alphabet
icBaseline, true, HorizontalLine, PositionOnContainingLine); | 60 textY = paintOffset.y() + m_renderFileUploadControl.borderTop() + m_
renderFileUploadControl.paddingTop() + buttonRenderer->baselinePosition(Alphabet
icBaseline, true, HorizontalLine, PositionOnContainingLine); |
61 else | 61 else |
62 textY = m_renderFileUploadControl.baselinePosition(AlphabeticBaselin
e, true, HorizontalLine, PositionOnContainingLine); | 62 textY = m_renderFileUploadControl.baselinePosition(AlphabeticBaselin
e, true, HorizontalLine, PositionOnContainingLine); |
63 TextRunPaintInfo textRunPaintInfo(textRun); | 63 TextRunPaintInfo textRunPaintInfo(textRun); |
64 // FIXME: Shouldn't these offsets be rounded? crbug.com/350474 | 64 // FIXME: Shouldn't these offsets be rounded? crbug.com/350474 |
65 textRunPaintInfo.bounds = FloatRect(textX.toFloat(), textY.toFloat() - m
_renderFileUploadControl.style()->fontMetrics().ascent(), | 65 textRunPaintInfo.bounds = FloatRect(textX.toFloat(), textY.toFloat() - m
_renderFileUploadControl.style()->fontMetrics().ascent(), |
66 textWidth, m_renderFileUploadControl.style()->fontMetrics().height()
); | 66 textWidth, m_renderFileUploadControl.style()->fontMetrics().height()
); |
67 | 67 |
68 // Draw the filename. | 68 // Draw the filename. |
69 RenderDrawingRecorder recorder(paintInfo.context, m_renderFileUploadCont
rol, paintInfo.phase, textRunPaintInfo.bounds); | 69 RenderDrawingRecorder recorder(paintInfo.context, m_renderFileUploadCont
rol, paintInfo.phase, textRunPaintInfo.bounds); |
70 if (!recorder.canUseCachedDrawing()) { | 70 if (!recorder.canUseCachedDrawing()) { |
71 paintInfo.context->setFillColor(m_renderFileUploadControl.resolveCol
or(CSSPropertyColor)); | 71 paintInfo.context->setFillColor(m_renderFileUploadControl.resolveCol
or(CSSPropertyColor)); |
72 paintInfo.context->drawBidiText(font, textRunPaintInfo, FloatPoint(r
oundToInt(textX), roundToInt(textY))); | 72 paintInfo.context->drawBidiText(font, textRunPaintInfo, FloatPoint(r
oundToInt(textX), roundToInt(textY))); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 // Paint the children. | 76 // Paint the children. |
77 m_renderFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse
t); | 77 m_renderFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse
t); |
78 } | 78 } |
79 | 79 |
80 } // namespace blink | 80 } // namespace blink |
OLD | NEW |