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/InlinePainter.h" | 6 #include "core/paint/InlinePainter.h" |
7 | 7 |
8 #include "core/layout/LayoutBlock.h" | 8 #include "core/layout/LayoutBlock.h" |
9 #include "core/layout/LayoutInline.h" | 9 #include "core/layout/LayoutInline.h" |
10 #include "core/layout/LayoutTheme.h" | 10 #include "core/layout/LayoutTheme.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return outlineRect; | 44 return outlineRect; |
45 } | 45 } |
46 | 46 |
47 void InlinePainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 47 void InlinePainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
48 { | 48 { |
49 const ComputedStyle& styleToUse = m_layoutInline.styleRef(); | 49 const ComputedStyle& styleToUse = m_layoutInline.styleRef(); |
50 if (!styleToUse.hasOutline()) | 50 if (!styleToUse.hasOutline()) |
51 return; | 51 return; |
52 | 52 |
53 if (styleToUse.outlineStyleIsAuto()) { | 53 if (styleToUse.outlineStyleIsAuto()) { |
54 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutInline)) { | 54 if (!LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutInline)) |
55 Vector<LayoutRect> focusRingRects; | 55 return; |
56 m_layoutInline.addFocusRingRects(focusRingRects, paintOffset); | 56 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.c
ontext, m_layoutInline, paintInfo.phase)) |
| 57 return; |
57 | 58 |
58 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInl
ine, paintInfo.phase, outlinePaintRect(focusRingRects, LayoutPoint())); | 59 Vector<LayoutRect> focusRingRects; |
59 if (recorder.canUseCachedDrawing()) | 60 m_layoutInline.addFocusRingRects(focusRingRects, paintOffset); |
60 return; | |
61 | 61 |
62 // Only paint the focus ring by hand if the theme isn't able to draw
the focus ring. | 62 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInline,
paintInfo.phase, outlinePaintRect(focusRingRects, LayoutPoint())); |
63 ObjectPainter(m_layoutInline).paintFocusRing(paintInfo, styleToUse,
focusRingRects); | 63 // Only paint the focus ring by hand if the theme isn't able to draw the
focus ring. |
64 } | 64 ObjectPainter(m_layoutInline).paintFocusRing(paintInfo, styleToUse, focu
sRingRects); |
65 return; | 65 return; |
66 } | 66 } |
67 | 67 |
68 if (styleToUse.outlineStyle() == BNONE) | 68 if (styleToUse.outlineStyle() == BNONE) |
69 return; | 69 return; |
70 | 70 |
| 71 GraphicsContext* graphicsContext = paintInfo.context; |
| 72 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext
, m_layoutInline, paintInfo.phase)) |
| 73 return; |
| 74 |
71 Vector<LayoutRect> rects; | 75 Vector<LayoutRect> rects; |
72 | 76 |
73 rects.append(LayoutRect()); | 77 rects.append(LayoutRect()); |
74 for (InlineFlowBox* curr = m_layoutInline.firstLineBox(); curr; curr = curr-
>nextLineBox()) { | 78 for (InlineFlowBox* curr = m_layoutInline.firstLineBox(); curr; curr = curr-
>nextLineBox()) { |
75 RootInlineBox& root = curr->root(); | 79 RootInlineBox& root = curr->root(); |
76 LayoutUnit top = std::max<LayoutUnit>(root.lineTop(), curr->logicalTop()
); | 80 LayoutUnit top = std::max<LayoutUnit>(root.lineTop(), curr->logicalTop()
); |
77 LayoutUnit bottom = std::min<LayoutUnit>(root.lineBottom(), curr->logica
lBottom()); | 81 LayoutUnit bottom = std::min<LayoutUnit>(root.lineBottom(), curr->logica
lBottom()); |
78 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - t
op)); | 82 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - t
op)); |
79 } | 83 } |
80 rects.append(LayoutRect()); | 84 rects.append(LayoutRect()); |
81 | 85 |
82 Color outlineColor = m_layoutInline.resolveColor(styleToUse, CSSPropertyOutl
ineColor); | 86 Color outlineColor = m_layoutInline.resolveColor(styleToUse, CSSPropertyOutl
ineColor); |
83 bool useTransparencyLayer = outlineColor.hasAlpha(); | 87 bool useTransparencyLayer = outlineColor.hasAlpha(); |
84 | 88 |
85 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInline, pai
ntInfo.phase, outlinePaintRect(rects, paintOffset)); | 89 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutInline, paint
Info.phase, outlinePaintRect(rects, paintOffset)); |
86 if (recorder.canUseCachedDrawing()) | |
87 return; | |
88 | |
89 GraphicsContext* graphicsContext = paintInfo.context; | |
90 if (useTransparencyLayer) { | 90 if (useTransparencyLayer) { |
91 graphicsContext->beginLayer(static_cast<float>(outlineColor.alpha()) / 2
55); | 91 graphicsContext->beginLayer(static_cast<float>(outlineColor.alpha()) / 2
55); |
92 outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineCo
lor.blue()); | 92 outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineCo
lor.blue()); |
93 } | 93 } |
94 | 94 |
95 for (unsigned i = 1; i < rects.size() - 1; i++) | 95 for (unsigned i = 1; i < rects.size() - 1; i++) |
96 paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects
.at(i), rects.at(i + 1), outlineColor); | 96 paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects
.at(i), rects.at(i + 1), outlineColor); |
97 | 97 |
98 if (useTransparencyLayer) | 98 if (useTransparencyLayer) |
99 graphicsContext->endLayer(); | 99 graphicsContext->endLayer(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 pixelSnappedBox.maxX() + outlineWidth, | 216 pixelSnappedBox.maxX() + outlineWidth, |
217 pixelSnappedBox.maxY() + outlineWidth, | 217 pixelSnappedBox.maxY() + outlineWidth, |
218 BSBottom, outlineColor, outlineStyle, | 218 BSBottom, outlineColor, outlineStyle, |
219 outlineWidth, | 219 outlineWidth, |
220 outlineWidth, | 220 outlineWidth, |
221 false); | 221 false); |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 } // namespace blink | 225 } // namespace blink |
OLD | NEW |