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

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

Issue 1129793005: Replace OwnPtr with WTF::Optional for optional recorders. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge with master Created 5 years, 6 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 | Annotate | Revision Log
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"
11 #include "core/paint/LayoutObjectDrawingRecorder.h" 11 #include "core/paint/LayoutObjectDrawingRecorder.h"
12 #include "core/paint/PaintInfo.h" 12 #include "core/paint/PaintInfo.h"
13 #include "platform/graphics/paint/ClipRecorder.h" 13 #include "platform/graphics/paint/ClipRecorder.h"
14 #include "wtf/Optional.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 const int buttonShadowHeight = 2; 18 const int buttonShadowHeight = 2;
18 19
19 void FileUploadControlPainter::paintObject(const PaintInfo& paintInfo, const Lay outPoint& paintOffset) 20 void FileUploadControlPainter::paintObject(const PaintInfo& paintInfo, const Lay outPoint& paintOffset)
20 { 21 {
21 if (m_layoutFileUploadControl.style()->visibility() != VISIBLE) 22 if (m_layoutFileUploadControl.style()->visibility() != VISIBLE)
22 return; 23 return;
23 24
24 // Push a clip. 25 // Push a clip.
25 OwnPtr<ClipRecorder> clipRecorder; 26 Optional<ClipRecorder> clipRecorder;
26 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhase ChildBlockBackgrounds) { 27 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhase ChildBlockBackgrounds) {
27 IntRect clipRect = enclosingIntRect(LayoutRect( 28 IntRect clipRect = enclosingIntRect(LayoutRect(
28 LayoutPoint(paintOffset.x() + m_layoutFileUploadControl.borderLeft() , paintOffset.y() + m_layoutFileUploadControl.borderTop()), 29 LayoutPoint(paintOffset.x() + m_layoutFileUploadControl.borderLeft() , paintOffset.y() + m_layoutFileUploadControl.borderTop()),
29 m_layoutFileUploadControl.size() + LayoutSize(0, -m_layoutFileUpload Control.borderWidth() + buttonShadowHeight))); 30 m_layoutFileUploadControl.size() + LayoutSize(0, -m_layoutFileUpload Control.borderWidth() + buttonShadowHeight)));
30 if (clipRect.isEmpty()) 31 if (clipRect.isEmpty())
31 return; 32 return;
32 clipRecorder = adoptPtr(new ClipRecorder(*paintInfo.context, m_layoutFil eUploadControl, DisplayItem::ClipFileUploadControlRect, LayoutRect(clipRect))); 33 clipRecorder.emplace(*paintInfo.context, m_layoutFileUploadControl, Disp layItem::ClipFileUploadControlRect, LayoutRect(clipRect));
33 } 34 }
34 35
35 if (paintInfo.phase == PaintPhaseForeground) { 36 if (paintInfo.phase == PaintPhaseForeground) {
36 const String& displayedFilename = m_layoutFileUploadControl.fileTextValu e(); 37 const String& displayedFilename = m_layoutFileUploadControl.fileTextValu e();
37 const Font& font = m_layoutFileUploadControl.style()->font(); 38 const Font& font = m_layoutFileUploadControl.style()->font();
38 TextRun textRun = constructTextRun(&m_layoutFileUploadControl, font, dis playedFilename, m_layoutFileUploadControl.styleRef(), RespectDirection | Respect DirectionOverride); 39 TextRun textRun = constructTextRun(&m_layoutFileUploadControl, font, dis playedFilename, m_layoutFileUploadControl.styleRef(), RespectDirection | Respect DirectionOverride);
39 textRun.setExpansionBehavior(TextRun::AllowTrailingExpansion); 40 textRun.setExpansionBehavior(TextRun::AllowTrailingExpansion);
40 41
41 // Determine where the filename should be placed 42 // Determine where the filename should be placed
42 LayoutUnit contentLeft = paintOffset.x() + m_layoutFileUploadControl.bor derLeft() + m_layoutFileUploadControl.paddingLeft(); 43 LayoutUnit contentLeft = paintOffset.x() + m_layoutFileUploadControl.bor derLeft() + m_layoutFileUploadControl.paddingLeft();
(...skipping 28 matching lines...) Expand all
71 paintInfo.context->setFillColor(m_layoutFileUploadControl.resolveCol or(CSSPropertyColor)); 72 paintInfo.context->setFillColor(m_layoutFileUploadControl.resolveCol or(CSSPropertyColor));
72 paintInfo.context->drawBidiText(font, textRunPaintInfo, FloatPoint(r oundToInt(textX), roundToInt(textY))); 73 paintInfo.context->drawBidiText(font, textRunPaintInfo, FloatPoint(r oundToInt(textX), roundToInt(textY)));
73 } 74 }
74 } 75 }
75 76
76 // Paint the children. 77 // Paint the children.
77 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse t); 78 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse t);
78 } 79 }
79 80
80 } // namespace blink 81 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698