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/PaintInfo.h" | 8 #include "core/layout/PaintInfo.h" |
9 #include "core/layout/TextRunConstructor.h" | 9 #include "core/layout/TextRunConstructor.h" |
10 #include "core/paint/RenderDrawingRecorder.h" | 10 #include "core/paint/RenderDrawingRecorder.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 const Font& font = m_renderFileUploadControl.style()->font(); | 37 const Font& font = m_renderFileUploadControl.style()->font(); |
38 TextRun textRun = constructTextRun(&m_renderFileUploadControl, font, dis
playedFilename, m_renderFileUploadControl.styleRef(), RespectDirection | Respect
DirectionOverride); | 38 TextRun textRun = constructTextRun(&m_renderFileUploadControl, font, dis
playedFilename, m_renderFileUploadControl.styleRef(), RespectDirection | Respect
DirectionOverride); |
39 textRun.setExpansionBehavior(TextRun::AllowTrailingExpansion); | 39 textRun.setExpansionBehavior(TextRun::AllowTrailingExpansion); |
40 | 40 |
41 // Determine where the filename should be placed | 41 // Determine where the filename should be placed |
42 LayoutUnit contentLeft = paintOffset.x() + m_renderFileUploadControl.bor
derLeft() + m_renderFileUploadControl.paddingLeft(); | 42 LayoutUnit contentLeft = paintOffset.x() + m_renderFileUploadControl.bor
derLeft() + m_renderFileUploadControl.paddingLeft(); |
43 Node* button = m_renderFileUploadControl.uploadButton(); | 43 Node* button = m_renderFileUploadControl.uploadButton(); |
44 if (!button) | 44 if (!button) |
45 return; | 45 return; |
46 | 46 |
47 int buttonWidth = (button && button->renderBox()) ? button->renderBox()-
>pixelSnappedWidth() : 0; | 47 int buttonWidth = (button && button->layoutBox()) ? button->layoutBox()-
>pixelSnappedWidth() : 0; |
48 LayoutUnit buttonAndSpacingWidth = buttonWidth + RenderFileUploadControl
::afterButtonSpacing; | 48 LayoutUnit buttonAndSpacingWidth = buttonWidth + RenderFileUploadControl
::afterButtonSpacing; |
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 |
(...skipping 13 matching lines...) Expand all Loading... |
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.RenderBlockFlow::paintObject(paintInfo, paintOffse
t); | 77 m_renderFileUploadControl.RenderBlockFlow::paintObject(paintInfo, paintOffse
t); |
78 } | 78 } |
79 | 79 |
80 } // namespace blink | 80 } // namespace blink |
OLD | NEW |