OLD | NEW |
---|---|
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) | 19 // TODO(pdr): This adjustment should be made to LayoutObject::paintInvalidationR ectInLocalCoordinates. |
20 LayoutRect ObjectPainter::outlineRectForSVG(const LayoutSize& size, const Comput edStyle& style) | |
chrishtr
2015/08/27 04:20:41
This seems like an odd method to have, even tempor
pdr.
2015/08/27 05:00:17
SVG's paint invalidation rect concept needs a big
fs
2015/08/27 10:23:17
I can look into this if you like. I assume we want
| |
20 { | 21 { |
21 LayoutRect outlineBounds(objectBounds); | 22 LayoutRect outlineBounds(LayoutPoint(), size); |
22 outlineBounds.inflate(style.outlineOutsetExtent()); | 23 outlineBounds.inflate(style.outlineOutsetExtent()); |
23 return outlineBounds; | 24 return outlineBounds; |
24 } | 25 } |
25 | 26 |
26 void ObjectPainter::paintFocusRing(const PaintInfo& paintInfo, const ComputedSty le& style, const Vector<LayoutRect>& focusRingRects) | 27 void ObjectPainter::paintFocusRing(const PaintInfo& paintInfo, const ComputedSty le& style, const Vector<LayoutRect>& focusRingRects) |
27 { | 28 { |
28 ASSERT(style.outlineStyleIsAuto()); | 29 ASSERT(style.outlineStyleIsAuto()); |
29 Vector<IntRect> focusRingIntRects; | 30 Vector<IntRect> focusRingIntRects; |
30 for (size_t i = 0; i < focusRingRects.size(); ++i) | 31 for (size_t i = 0; i < focusRingRects.size(); ++i) |
31 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i])); | 32 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i])); |
32 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor) ); | 33 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor) ); |
33 } | 34 } |
34 | 35 |
35 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& o bjectBounds, const LayoutRect& visualOverflowBounds) | 36 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& v isualOverflowRect, const LayoutSize& objectSize, const LayoutPoint& paintOffset) |
36 { | 37 { |
37 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); | 38 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); |
38 if (!styleToUse.hasOutline()) | 39 if (!styleToUse.hasOutline()) |
39 return; | 40 return; |
40 | 41 |
41 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutObject, paintInfo.phase)) | 42 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutObject, paintInfo.phase)) |
42 return; | 43 return; |
43 | 44 |
45 LayoutRect visualOverflowBounds(visualOverflowRect); | |
46 visualOverflowBounds.moveBy(paintOffset); | |
44 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai ntInfo.phase, visualOverflowBounds); | 47 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai ntInfo.phase, visualOverflowBounds); |
45 | 48 |
46 if (styleToUse.outlineStyleIsAuto()) { | 49 if (styleToUse.outlineStyleIsAuto()) { |
47 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutObject)) { | 50 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. | 51 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring. |
49 Vector<LayoutRect> focusRingRects; | 52 Vector<LayoutRect> focusRingRects; |
50 m_layoutObject.addOutlineRects(focusRingRects, objectBounds.location ()); | 53 m_layoutObject.addOutlineRects(focusRingRects, paintOffset); |
51 paintFocusRing(paintInfo, styleToUse, focusRingRects); | 54 paintFocusRing(paintInfo, styleToUse, focusRingRects); |
52 } | 55 } |
53 return; | 56 return; |
54 } | 57 } |
55 | 58 |
56 if (styleToUse.outlineStyle() == BNONE) | 59 if (styleToUse.outlineStyle() == BNONE) |
57 return; | 60 return; |
58 | 61 |
59 LayoutRect inner(pixelSnappedIntRect(objectBounds)); | 62 LayoutRect inner(paintOffset, objectSize); |
63 inner = LayoutRect(pixelSnappedIntRect(inner)); | |
60 inner.inflate(styleToUse.outlineOffset()); | 64 inner.inflate(styleToUse.outlineOffset()); |
61 | 65 |
62 LayoutRect outer(inner); | 66 LayoutRect outer(inner); |
63 int outlineWidth = styleToUse.outlineWidth(); | 67 int outlineWidth = styleToUse.outlineWidth(); |
64 outer.inflate(outlineWidth); | 68 outer.inflate(outlineWidth); |
65 | 69 |
66 const BorderEdge commonEdgeInfo(outlineWidth, | 70 const BorderEdge commonEdgeInfo(outlineWidth, |
67 m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColor), styleT oUse.outlineStyle()); | 71 m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColor), styleT oUse.outlineStyle()); |
68 BoxBorderPainter(styleToUse, outer, inner, commonEdgeInfo).paintBorder(paint Info, outer); | 72 BoxBorderPainter(styleToUse, outer, inner, commonEdgeInfo).paintBorder(paint Info, outer); |
69 } | 73 } |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); | 344 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); |
341 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); | 345 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); |
342 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); | 346 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); |
343 break; | 347 break; |
344 } | 348 } |
345 | 349 |
346 graphicsContext->fillPolygon(4, quad, color, antialias); | 350 graphicsContext->fillPolygon(4, quad, color, antialias); |
347 } | 351 } |
348 | 352 |
349 } // namespace blink | 353 } // namespace blink |
OLD | NEW |