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

Side by Side Diff: third_party/WebKit/Source/core/paint/DetailsMarkerPainter.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/DetailsMarkerPainter.h" 6 #include "core/paint/DetailsMarkerPainter.h"
7 7
8 #include "core/layout/LayoutDetailsMarker.h" 8 #include "core/layout/LayoutDetailsMarker.h"
9 #include "core/paint/BlockPainter.h" 9 #include "core/paint/BlockPainter.h"
10 #include "core/paint/LayoutObjectDrawingRecorder.h" 10 #include "core/paint/LayoutObjectDrawingRecorder.h"
11 #include "core/paint/PaintInfo.h" 11 #include "core/paint/PaintInfo.h"
12 #include "platform/geometry/LayoutPoint.h" 12 #include "platform/geometry/LayoutPoint.h"
13 #include "platform/graphics/Path.h" 13 #include "platform/graphics/Path.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 void DetailsMarkerPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 17 void DetailsMarkerPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
18 { 18 {
19 if (paintInfo.phase != PaintPhaseForeground || m_layoutDetailsMarker.style() ->visibility() != VISIBLE) { 19 if (paintInfo.phase != PaintPhaseForeground || m_layoutDetailsMarker.style() ->visibility() != VISIBLE) {
20 BlockPainter(m_layoutDetailsMarker).paint(paintInfo, paintOffset); 20 BlockPainter(m_layoutDetailsMarker).paint(paintInfo, paintOffset);
21 return; 21 return;
22 } 22 }
23 23
24 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutDetailsMarker, paintInfo.phase, paintOffset)) 24 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutDetailsMarker, paintInfo.phase, paintOffset))
25 return; 25 return;
26 26
27 LayoutPoint boxOrigin(paintOffset + m_layoutDetailsMarker.location()); 27 LayoutPoint boxOrigin(paintOffset + m_layoutDetailsMarker.location());
28 LayoutRect overflowRect(m_layoutDetailsMarker.visualOverflowRect()); 28 LayoutRect overflowRect(m_layoutDetailsMarker.visualOverflowRect());
29 overflowRect.moveBy(boxOrigin); 29 overflowRect.moveBy(boxOrigin);
30 30
31 if (!paintInfo.cullRect().intersectsCullRect(overflowRect)) 31 if (!paintInfo.cullRect().intersectsCullRect(overflowRect))
32 return; 32 return;
33 33
34 LayoutObjectDrawingRecorder layoutDrawingRecorder(*paintInfo.context, m_layo utDetailsMarker, paintInfo.phase, overflowRect, paintOffset); 34 LayoutObjectDrawingRecorder layoutDrawingRecorder(paintInfo.context, m_layou tDetailsMarker, paintInfo.phase, overflowRect, paintOffset);
35 const Color color(m_layoutDetailsMarker.resolveColor(CSSPropertyColor)); 35 const Color color(m_layoutDetailsMarker.resolveColor(CSSPropertyColor));
36 paintInfo.context->setStrokeColor(color); 36 paintInfo.context.setStrokeColor(color);
37 paintInfo.context->setStrokeStyle(SolidStroke); 37 paintInfo.context.setStrokeStyle(SolidStroke);
38 paintInfo.context->setStrokeThickness(1.0f); 38 paintInfo.context.setStrokeThickness(1.0f);
39 paintInfo.context->setFillColor(color); 39 paintInfo.context.setFillColor(color);
40 40
41 boxOrigin.move(m_layoutDetailsMarker.borderLeft() + m_layoutDetailsMarker.pa ddingLeft(), m_layoutDetailsMarker.borderTop() + m_layoutDetailsMarker.paddingTo p()); 41 boxOrigin.move(m_layoutDetailsMarker.borderLeft() + m_layoutDetailsMarker.pa ddingLeft(), m_layoutDetailsMarker.borderTop() + m_layoutDetailsMarker.paddingTo p());
42 paintInfo.context->fillPath(getPath(boxOrigin)); 42 paintInfo.context.fillPath(getPath(boxOrigin));
43 } 43 }
44 44
45 static Path createPath(const FloatPoint* path) 45 static Path createPath(const FloatPoint* path)
46 { 46 {
47 Path result; 47 Path result;
48 result.moveTo(FloatPoint(path[0].x(), path[0].y())); 48 result.moveTo(FloatPoint(path[0].x(), path[0].y()));
49 for (int i = 1; i < 4; ++i) 49 for (int i = 1; i < 4; ++i)
50 result.addLineTo(FloatPoint(path[i].x(), path[i].y())); 50 result.addLineTo(FloatPoint(path[i].x(), path[i].y()));
51 return result; 51 return result;
52 } 52 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 Path DetailsMarkerPainter::getPath(const LayoutPoint& origin) const 90 Path DetailsMarkerPainter::getPath(const LayoutPoint& origin) const
91 { 91 {
92 Path result = getCanonicalPath(); 92 Path result = getCanonicalPath();
93 result.transform(AffineTransform().scale(m_layoutDetailsMarker.contentWidth( ).toFloat(), m_layoutDetailsMarker.contentHeight().toFloat())); 93 result.transform(AffineTransform().scale(m_layoutDetailsMarker.contentWidth( ).toFloat(), m_layoutDetailsMarker.contentHeight().toFloat()));
94 result.translate(FloatSize(origin.x().toFloat(), origin.y().toFloat())); 94 result.translate(FloatSize(origin.x().toFloat(), origin.y().toFloat()));
95 return result; 95 return result;
96 } 96 }
97 97
98 } // namespace paint 98 } // namespace paint
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/ClipScope.cpp ('k') | third_party/WebKit/Source/core/paint/EllipsisBoxPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698