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/layout/PaintInfo.h" | 10 #include "core/layout/PaintInfo.h" |
11 #include "core/layout/style/LayoutStyle.h" | 11 #include "core/layout/style/ComputedStyle.h" |
12 #include "core/paint/LayoutObjectDrawingRecorder.h" | 12 #include "core/paint/LayoutObjectDrawingRecorder.h" |
13 #include "platform/geometry/LayoutPoint.h" | 13 #include "platform/geometry/LayoutPoint.h" |
14 #include "platform/graphics/GraphicsContextStateSaver.h" | 14 #include "platform/graphics/GraphicsContextStateSaver.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 void ObjectPainter::paintFocusRing(const PaintInfo& paintInfo, const LayoutStyle
& style, const Vector<LayoutRect>& focusRingRects) | 18 void ObjectPainter::paintFocusRing(const PaintInfo& paintInfo, const ComputedSty
le& style, const Vector<LayoutRect>& focusRingRects) |
19 { | 19 { |
20 ASSERT(style.outlineStyleIsAuto()); | 20 ASSERT(style.outlineStyleIsAuto()); |
21 Vector<IntRect> focusRingIntRects; | 21 Vector<IntRect> focusRingIntRects; |
22 for (size_t i = 0; i < focusRingRects.size(); ++i) | 22 for (size_t i = 0; i < focusRingRects.size(); ++i) |
23 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i])); | 23 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i])); |
24 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st
yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor)
); | 24 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st
yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor)
); |
25 } | 25 } |
26 | 26 |
27 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& o
bjectBounds, const LayoutRect& visualOverflowBounds) | 27 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& o
bjectBounds, const LayoutRect& visualOverflowBounds) |
28 { | 28 { |
29 const LayoutStyle& styleToUse = m_layoutObject.styleRef(); | 29 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); |
30 if (!styleToUse.hasOutline()) | 30 if (!styleToUse.hasOutline()) |
31 return; | 31 return; |
32 | 32 |
33 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutObject, pain
tInfo.phase, visualOverflowBounds); | 33 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutObject, pain
tInfo.phase, visualOverflowBounds); |
34 if (recorder.canUseCachedDrawing()) | 34 if (recorder.canUseCachedDrawing()) |
35 return; | 35 return; |
36 | 36 |
37 if (styleToUse.outlineStyleIsAuto()) { | 37 if (styleToUse.outlineStyleIsAuto()) { |
38 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutObject)) { | 38 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutObject)) { |
39 // Only paint the focus ring by hand if the theme isn't able to draw
the focus ring. | 39 // Only paint the focus ring by hand if the theme isn't able to draw
the focus ring. |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); | 342 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); |
343 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); | 343 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); |
344 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); | 344 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); |
345 break; | 345 break; |
346 } | 346 } |
347 | 347 |
348 graphicsContext->fillPolygon(4, quad, color, antialias); | 348 graphicsContext->fillPolygon(4, quad, color, antialias); |
349 } | 349 } |
350 | 350 |
351 } // namespace blink | 351 } // namespace blink |
OLD | NEW |