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

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

Issue 1321613002: Refactor ObjectPainter::paintOutline to take a paintOffset (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove ObjectPainter::outlineRectForSVG Created 5 years, 3 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/ObjectPainter.h ('k') | Source/core/paint/PartPainter.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/ObjectPainter.h" 6 #include "core/paint/ObjectPainter.h"
7 7
8 #include "core/layout/LayoutObject.h" 8 #include "core/layout/LayoutObject.h"
9 #include "core/layout/LayoutTheme.h" 9 #include "core/layout/LayoutTheme.h"
10 #include "core/paint/BoxBorderPainter.h" 10 #include "core/paint/BoxBorderPainter.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 "core/style/BorderEdge.h" 13 #include "core/style/BorderEdge.h"
14 #include "core/style/ComputedStyle.h" 14 #include "core/style/ComputedStyle.h"
15 #include "platform/geometry/LayoutPoint.h" 15 #include "platform/geometry/LayoutPoint.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 LayoutRect ObjectPainter::outlineBounds(const LayoutRect& objectBounds, const Co mputedStyle& style)
20 {
21 LayoutRect outlineBounds(objectBounds);
22 outlineBounds.inflate(style.outlineOutsetExtent());
23 return outlineBounds;
24 }
25
26 void ObjectPainter::paintFocusRing(const PaintInfo& paintInfo, const ComputedSty le& style, const Vector<LayoutRect>& focusRingRects) 19 void ObjectPainter::paintFocusRing(const PaintInfo& paintInfo, const ComputedSty le& style, const Vector<LayoutRect>& focusRingRects)
27 { 20 {
28 ASSERT(style.outlineStyleIsAuto()); 21 ASSERT(style.outlineStyleIsAuto());
29 Vector<IntRect> focusRingIntRects; 22 Vector<IntRect> focusRingIntRects;
30 for (size_t i = 0; i < focusRingRects.size(); ++i) 23 for (size_t i = 0; i < focusRingRects.size(); ++i)
31 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i])); 24 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i]));
32 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor) ); 25 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor) );
33 } 26 }
34 27
35 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& o bjectBounds, const LayoutRect& visualOverflowBounds) 28 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& v isualOverflowRect, const LayoutSize& objectSize, const LayoutPoint& paintOffset)
36 { 29 {
37 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); 30 const ComputedStyle& styleToUse = m_layoutObject.styleRef();
38 if (!styleToUse.hasOutline()) 31 if (!styleToUse.hasOutline())
39 return; 32 return;
40 33
41 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutObject, paintInfo.phase)) 34 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutObject, paintInfo.phase))
42 return; 35 return;
43 36
37 LayoutRect visualOverflowBounds(visualOverflowRect);
38 visualOverflowBounds.moveBy(paintOffset);
44 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai ntInfo.phase, visualOverflowBounds); 39 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai ntInfo.phase, visualOverflowBounds);
45 40
46 if (styleToUse.outlineStyleIsAuto()) { 41 if (styleToUse.outlineStyleIsAuto()) {
47 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutObject)) { 42 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutObject)) {
48 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring. 43 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
49 Vector<LayoutRect> focusRingRects; 44 Vector<LayoutRect> focusRingRects;
50 m_layoutObject.addOutlineRects(focusRingRects, objectBounds.location ()); 45 m_layoutObject.addOutlineRects(focusRingRects, paintOffset);
51 paintFocusRing(paintInfo, styleToUse, focusRingRects); 46 paintFocusRing(paintInfo, styleToUse, focusRingRects);
52 } 47 }
53 return; 48 return;
54 } 49 }
55 50
56 if (styleToUse.outlineStyle() == BNONE) 51 if (styleToUse.outlineStyle() == BNONE)
57 return; 52 return;
58 53
59 LayoutRect inner(pixelSnappedIntRect(objectBounds)); 54 LayoutRect inner(paintOffset, objectSize);
55 inner = LayoutRect(pixelSnappedIntRect(inner));
60 inner.inflate(styleToUse.outlineOffset()); 56 inner.inflate(styleToUse.outlineOffset());
61 57
62 LayoutRect outer(inner); 58 LayoutRect outer(inner);
63 int outlineWidth = styleToUse.outlineWidth(); 59 int outlineWidth = styleToUse.outlineWidth();
64 outer.inflate(outlineWidth); 60 outer.inflate(outlineWidth);
65 61
66 const BorderEdge commonEdgeInfo(outlineWidth, 62 const BorderEdge commonEdgeInfo(outlineWidth,
67 m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColor), styleT oUse.outlineStyle()); 63 m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColor), styleT oUse.outlineStyle());
68 BoxBorderPainter(styleToUse, outer, inner, commonEdgeInfo).paintBorder(paint Info, outer); 64 BoxBorderPainter(styleToUse, outer, inner, commonEdgeInfo).paintBorder(paint Info, outer);
69 } 65 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); 336 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0));
341 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); 337 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0));
342 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); 338 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0));
343 break; 339 break;
344 } 340 }
345 341
346 graphicsContext->fillPolygon(4, quad, color, antialias); 342 graphicsContext->fillPolygon(4, quad, color, antialias);
347 } 343 }
348 344
349 } // namespace blink 345 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/ObjectPainter.h ('k') | Source/core/paint/PartPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698