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

Side by Side Diff: third_party/WebKit/Source/core/paint/FileUploadControlPainter.cpp

Issue 1512803004: Use refs for GraphicsContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ScrollbarTheme
Patch Set: Created 5 years 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 "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/TextRunConstructor.h" 10 #include "core/layout/TextRunConstructor.h"
(...skipping 12 matching lines...) Expand all
23 return; 23 return;
24 24
25 // Push a clip. 25 // Push a clip.
26 Optional<ClipRecorder> clipRecorder; 26 Optional<ClipRecorder> clipRecorder;
27 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhase ChildBlockBackgrounds) { 27 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhase ChildBlockBackgrounds) {
28 IntRect clipRect = enclosingIntRect(LayoutRect( 28 IntRect clipRect = enclosingIntRect(LayoutRect(
29 LayoutPoint(paintOffset.x() + m_layoutFileUploadControl.borderLeft() , paintOffset.y() + m_layoutFileUploadControl.borderTop()), 29 LayoutPoint(paintOffset.x() + m_layoutFileUploadControl.borderLeft() , paintOffset.y() + m_layoutFileUploadControl.borderTop()),
30 m_layoutFileUploadControl.size() + LayoutSize(0, -m_layoutFileUpload Control.borderWidth() + buttonShadowHeight))); 30 m_layoutFileUploadControl.size() + LayoutSize(0, -m_layoutFileUpload Control.borderWidth() + buttonShadowHeight)));
31 if (clipRect.isEmpty()) 31 if (clipRect.isEmpty())
32 return; 32 return;
33 clipRecorder.emplace(*paintInfo.context, m_layoutFileUploadControl, Disp layItem::ClipFileUploadControlRect, LayoutRect(clipRect)); 33 clipRecorder.emplace(paintInfo.context, m_layoutFileUploadControl, Displ ayItem::ClipFileUploadControlRect, LayoutRect(clipRect));
34 } 34 }
35 35
36 if (paintInfo.phase == PaintPhaseForeground && !LayoutObjectDrawingRecorder: :useCachedDrawingIfPossible(*paintInfo.context, m_layoutFileUploadControl, paint Info.phase, paintOffset)) { 36 if (paintInfo.phase == PaintPhaseForeground && !LayoutObjectDrawingRecorder: :useCachedDrawingIfPossible(paintInfo.context, m_layoutFileUploadControl, paintI nfo.phase, paintOffset)) {
37 const String& displayedFilename = m_layoutFileUploadControl.fileTextValu e(); 37 const String& displayedFilename = m_layoutFileUploadControl.fileTextValu e();
38 const Font& font = m_layoutFileUploadControl.style()->font(); 38 const Font& font = m_layoutFileUploadControl.style()->font();
39 TextRun textRun = constructTextRun(font, displayedFilename, m_layoutFile UploadControl.styleRef(), RespectDirection | RespectDirectionOverride); 39 TextRun textRun = constructTextRun(font, displayedFilename, m_layoutFile UploadControl.styleRef(), RespectDirection | RespectDirectionOverride);
40 textRun.setExpansionBehavior(TextRun::AllowTrailingExpansion); 40 textRun.setExpansionBehavior(TextRun::AllowTrailingExpansion);
41 41
42 // Determine where the filename should be placed 42 // Determine where the filename should be placed
43 LayoutUnit contentLeft = paintOffset.x() + m_layoutFileUploadControl.bor derLeft() + m_layoutFileUploadControl.paddingLeft(); 43 LayoutUnit contentLeft = paintOffset.x() + m_layoutFileUploadControl.bor derLeft() + m_layoutFileUploadControl.paddingLeft();
44 Node* button = m_layoutFileUploadControl.uploadButton(); 44 Node* button = m_layoutFileUploadControl.uploadButton();
45 if (!button) 45 if (!button)
46 return; 46 return;
(...skipping 13 matching lines...) Expand all
60 if (LayoutButton* buttonLayoutObject = toLayoutButton(button->layoutObje ct())) 60 if (LayoutButton* buttonLayoutObject = toLayoutButton(button->layoutObje ct()))
61 textY = paintOffset.y() + m_layoutFileUploadControl.borderTop() + m_ layoutFileUploadControl.paddingTop() + buttonLayoutObject->baselinePosition(Alph abeticBaseline, true, HorizontalLine, PositionOnContainingLine); 61 textY = paintOffset.y() + m_layoutFileUploadControl.borderTop() + m_ layoutFileUploadControl.paddingTop() + buttonLayoutObject->baselinePosition(Alph abeticBaseline, true, HorizontalLine, PositionOnContainingLine);
62 else 62 else
63 textY = m_layoutFileUploadControl.baselinePosition(AlphabeticBaselin e, true, HorizontalLine, PositionOnContainingLine); 63 textY = m_layoutFileUploadControl.baselinePosition(AlphabeticBaselin e, true, HorizontalLine, PositionOnContainingLine);
64 TextRunPaintInfo textRunPaintInfo(textRun); 64 TextRunPaintInfo textRunPaintInfo(textRun);
65 // FIXME: Shouldn't these offsets be rounded? crbug.com/350474 65 // FIXME: Shouldn't these offsets be rounded? crbug.com/350474
66 textRunPaintInfo.bounds = FloatRect(textX.toFloat(), textY.toFloat() - m _layoutFileUploadControl.style()->fontMetrics().ascent(), 66 textRunPaintInfo.bounds = FloatRect(textX.toFloat(), textY.toFloat() - m _layoutFileUploadControl.style()->fontMetrics().ascent(),
67 textWidth, m_layoutFileUploadControl.style()->fontMetrics().height() ); 67 textWidth, m_layoutFileUploadControl.style()->fontMetrics().height() );
68 68
69 // Draw the filename. 69 // Draw the filename.
70 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFileUpl oadControl, paintInfo.phase, textRunPaintInfo.bounds, paintOffset); 70 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutFileUplo adControl, paintInfo.phase, textRunPaintInfo.bounds, paintOffset);
71 paintInfo.context->setFillColor(m_layoutFileUploadControl.resolveColor(C SSPropertyColor)); 71 paintInfo.context.setFillColor(m_layoutFileUploadControl.resolveColor(CS SPropertyColor));
72 paintInfo.context->drawBidiText(font, textRunPaintInfo, FloatPoint(round ToInt(textX), roundToInt(textY))); 72 paintInfo.context.drawBidiText(font, textRunPaintInfo, FloatPoint(roundT oInt(textX), roundToInt(textY)));
73 } 73 }
74 74
75 // Paint the children. 75 // Paint the children.
76 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse t); 76 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse t);
77 } 77 }
78 78
79 } // namespace blink 79 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/FieldsetPainter.cpp ('k') | third_party/WebKit/Source/core/paint/FilterPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698