| 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 "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 14 matching lines...) Expand all Loading... |
| 25 Optional<ClipRecorder> clipRecorder; | 25 Optional<ClipRecorder> clipRecorder; |
| 26 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhase
DescendantBlockBackgroundsOnly) { | 26 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhase
DescendantBlockBackgroundsOnly) { |
| 27 IntRect clipRect = enclosingIntRect(LayoutRect( | 27 IntRect clipRect = enclosingIntRect(LayoutRect( |
| 28 LayoutPoint(paintOffset.x() + m_layoutFileUploadControl.borderLeft()
, paintOffset.y() + m_layoutFileUploadControl.borderTop()), | 28 LayoutPoint(paintOffset.x() + m_layoutFileUploadControl.borderLeft()
, paintOffset.y() + m_layoutFileUploadControl.borderTop()), |
| 29 m_layoutFileUploadControl.size() + LayoutSize(0, -m_layoutFileUpload
Control.borderWidth() + buttonShadowHeight))); | 29 m_layoutFileUploadControl.size() + LayoutSize(0, -m_layoutFileUpload
Control.borderWidth() + buttonShadowHeight))); |
| 30 if (clipRect.isEmpty()) | 30 if (clipRect.isEmpty()) |
| 31 return; | 31 return; |
| 32 clipRecorder.emplace(paintInfo.context, m_layoutFileUploadControl, Displ
ayItem::ClipFileUploadControlRect, LayoutRect(clipRect)); | 32 clipRecorder.emplace(paintInfo.context, m_layoutFileUploadControl, Displ
ayItem::ClipFileUploadControlRect, LayoutRect(clipRect)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 if (paintInfo.phase == PaintPhaseForeground && !LayoutObjectDrawingRecorder:
:useCachedDrawingIfPossible(paintInfo.context, m_layoutFileUploadControl, paintI
nfo.phase, paintOffset)) { | 35 if (paintInfo.phase == PaintPhaseForeground && !LayoutObjectDrawingRecorder:
:useCachedDrawingIfPossible(paintInfo.context, m_layoutFileUploadControl, paintI
nfo.phase)) { |
| 36 const String& displayedFilename = m_layoutFileUploadControl.fileTextValu
e(); | 36 const String& displayedFilename = m_layoutFileUploadControl.fileTextValu
e(); |
| 37 const Font& font = m_layoutFileUploadControl.style()->font(); | 37 const Font& font = m_layoutFileUploadControl.style()->font(); |
| 38 TextRun textRun = constructTextRun(font, displayedFilename, m_layoutFile
UploadControl.styleRef(), RespectDirection | RespectDirectionOverride); | 38 TextRun textRun = constructTextRun(font, displayedFilename, m_layoutFile
UploadControl.styleRef(), RespectDirection | RespectDirectionOverride); |
| 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_layoutFileUploadControl.bor
derLeft() + m_layoutFileUploadControl.paddingLeft(); | 42 LayoutUnit contentLeft = paintOffset.x() + m_layoutFileUploadControl.bor
derLeft() + m_layoutFileUploadControl.paddingLeft(); |
| 43 Node* button = m_layoutFileUploadControl.uploadButton(); | 43 Node* button = m_layoutFileUploadControl.uploadButton(); |
| 44 if (!button) | 44 if (!button) |
| 45 return; | 45 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 59 if (LayoutButton* buttonLayoutObject = toLayoutButton(button->layoutObje
ct())) | 59 if (LayoutButton* buttonLayoutObject = toLayoutButton(button->layoutObje
ct())) |
| 60 textY = paintOffset.y() + m_layoutFileUploadControl.borderTop() + m_
layoutFileUploadControl.paddingTop() + buttonLayoutObject->baselinePosition(Alph
abeticBaseline, true, HorizontalLine, PositionOnContainingLine); | 60 textY = paintOffset.y() + m_layoutFileUploadControl.borderTop() + m_
layoutFileUploadControl.paddingTop() + buttonLayoutObject->baselinePosition(Alph
abeticBaseline, true, HorizontalLine, PositionOnContainingLine); |
| 61 else | 61 else |
| 62 textY = LayoutUnit(m_layoutFileUploadControl.baselinePosition(Alphab
eticBaseline, true, HorizontalLine, PositionOnContainingLine)); | 62 textY = LayoutUnit(m_layoutFileUploadControl.baselinePosition(Alphab
eticBaseline, 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
_layoutFileUploadControl.style()->fontMetrics().ascent(), | 65 textRunPaintInfo.bounds = FloatRect(textX.toFloat(), textY.toFloat() - m
_layoutFileUploadControl.style()->fontMetrics().ascent(), |
| 66 textWidth, m_layoutFileUploadControl.style()->fontMetrics().height()
); | 66 textWidth, m_layoutFileUploadControl.style()->fontMetrics().height()
); |
| 67 | 67 |
| 68 // Draw the filename. | 68 // Draw the filename. |
| 69 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutFileUplo
adControl, paintInfo.phase, textRunPaintInfo.bounds, paintOffset); | 69 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutFileUplo
adControl, paintInfo.phase, textRunPaintInfo.bounds); |
| 70 paintInfo.context.setFillColor(m_layoutFileUploadControl.resolveColor(CS
SPropertyColor)); | 70 paintInfo.context.setFillColor(m_layoutFileUploadControl.resolveColor(CS
SPropertyColor)); |
| 71 paintInfo.context.drawBidiText(font, textRunPaintInfo, FloatPoint(roundT
oInt(textX), roundToInt(textY))); | 71 paintInfo.context.drawBidiText(font, textRunPaintInfo, FloatPoint(roundT
oInt(textX), roundToInt(textY))); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Paint the children. | 74 // Paint the children. |
| 75 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse
t); | 75 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse
t); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace blink | 78 } // namespace blink |
| OLD | NEW |