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

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

Issue 1220583004: Refactor DrawingRecorders to check for cached drawings earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 5 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
« no previous file with comments | « Source/core/paint/FieldsetPainter.cpp ('k') | Source/core/paint/FramePainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 15 matching lines...) Expand all
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, Disp layItem::ClipFileUploadControlRect, LayoutRect(clipRect));
34 } 34 }
35 35
36 if (paintInfo.phase == PaintPhaseForeground) { 36 if (paintInfo.phase == PaintPhaseForeground && !LayoutObjectDrawingRecorder: :useCachedDrawingIfPossible(*paintInfo.context, m_layoutFileUploadControl, paint Info.phase)) {
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(&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);
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 14 matching lines...) Expand all
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); 70 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFileUpl oadControl, paintInfo.phase, textRunPaintInfo.bounds);
71 if (!recorder.canUseCachedDrawing()) { 71 paintInfo.context->setFillColor(m_layoutFileUploadControl.resolveColor(C SSPropertyColor));
72 paintInfo.context->setFillColor(m_layoutFileUploadControl.resolveCol or(CSSPropertyColor)); 72 paintInfo.context->drawBidiText(font, textRunPaintInfo, FloatPoint(round ToInt(textX), roundToInt(textY)));
73 paintInfo.context->drawBidiText(font, textRunPaintInfo, FloatPoint(r oundToInt(textX), roundToInt(textY)));
74 }
75 } 73 }
76 74
77 // Paint the children. 75 // Paint the children.
78 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse t); 76 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse t);
79 } 77 }
80 78
81 } // namespace blink 79 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/FieldsetPainter.cpp ('k') | Source/core/paint/FramePainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698