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/ListMarkerPainter.h" | 6 #include "core/paint/ListMarkerPainter.h" |
7 | 7 |
8 #include "core/layout/LayoutListItem.h" | 8 #include "core/layout/LayoutListItem.h" |
9 #include "core/layout/LayoutListMarker.h" | 9 #include "core/layout/LayoutListMarker.h" |
10 #include "core/layout/TextRunConstructor.h" | 10 #include "core/layout/TextRunConstructor.h" |
11 #include "core/paint/BlockPainter.h" | 11 #include "core/paint/BlockPainter.h" |
12 #include "core/paint/LayoutObjectDrawingRecorder.h" | 12 #include "core/paint/LayoutObjectDrawingRecorder.h" |
13 #include "core/paint/PaintInfo.h" | 13 #include "core/paint/PaintInfo.h" |
14 #include "platform/geometry/LayoutPoint.h" | 14 #include "platform/geometry/LayoutPoint.h" |
15 #include "platform/graphics/GraphicsContextStateSaver.h" | 15 #include "platform/graphics/GraphicsContextStateSaver.h" |
16 #include "wtf/unicode/CharacterNames.h" | 16 #include "wtf/unicode/CharacterNames.h" |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 void ListMarkerPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& pai
ntOffset) | 20 void ListMarkerPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& pai
ntOffset) |
21 { | 21 { |
22 if (paintInfo.phase != PaintPhaseForeground) | 22 if (paintInfo.phase != PaintPhaseForeground) |
23 return; | 23 return; |
24 | 24 |
25 if (m_layoutListMarker.style()->visibility() != VISIBLE) | 25 if (m_layoutListMarker.style()->visibility() != VISIBLE) |
26 return; | 26 return; |
27 | 27 |
| 28 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutListMarker, paintInfo.phase)) |
| 29 return; |
| 30 |
28 LayoutPoint boxOrigin(paintOffset + m_layoutListMarker.location()); | 31 LayoutPoint boxOrigin(paintOffset + m_layoutListMarker.location()); |
29 LayoutRect overflowRect(m_layoutListMarker.visualOverflowRect()); | 32 LayoutRect overflowRect(m_layoutListMarker.visualOverflowRect()); |
30 if (m_layoutListMarker.selectionState() != LayoutObject::SelectionNone) | 33 if (m_layoutListMarker.selectionState() != LayoutObject::SelectionNone) |
31 overflowRect.unite(m_layoutListMarker.localSelectionRect()); | 34 overflowRect.unite(m_layoutListMarker.localSelectionRect()); |
32 overflowRect.moveBy(boxOrigin); | 35 overflowRect.moveBy(boxOrigin); |
33 | 36 |
34 IntRect pixelSnappedOverflowRect = pixelSnappedIntRect(overflowRect); | 37 IntRect pixelSnappedOverflowRect = pixelSnappedIntRect(overflowRect); |
35 if (!paintInfo.rect.intersects(pixelSnappedOverflowRect)) | 38 if (!paintInfo.rect.intersects(pixelSnappedOverflowRect)) |
36 return; | 39 return; |
37 | 40 |
38 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutListMarker,
paintInfo.phase, pixelSnappedOverflowRect); | 41 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutListMarker,
paintInfo.phase, pixelSnappedOverflowRect); |
39 if (recorder.canUseCachedDrawing()) | |
40 return; | |
41 | 42 |
42 LayoutRect box(boxOrigin, m_layoutListMarker.size()); | 43 LayoutRect box(boxOrigin, m_layoutListMarker.size()); |
43 | 44 |
44 IntRect marker = m_layoutListMarker.getRelativeMarkerRect(); | 45 IntRect marker = m_layoutListMarker.getRelativeMarkerRect(); |
45 marker.moveBy(roundedIntPoint(boxOrigin)); | 46 marker.moveBy(roundedIntPoint(boxOrigin)); |
46 | 47 |
47 GraphicsContext* context = paintInfo.context; | 48 GraphicsContext* context = paintInfo.context; |
48 | 49 |
49 if (m_layoutListMarker.isImage()) { | 50 if (m_layoutListMarker.isImage()) { |
50 context->drawImage(m_layoutListMarker.image()->image(&m_layoutListMarker
, marker.size()).get(), marker); | 51 context->drawImage(m_layoutListMarker.image()->image(&m_layoutListMarker
, marker.size()).get(), marker); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 if (m_layoutListMarker.style()->isLeftToRightDirection()) { | 182 if (m_layoutListMarker.style()->isLeftToRightDirection()) { |
182 context->drawText(font, textRunPaintInfo, textOrigin); | 183 context->drawText(font, textRunPaintInfo, textOrigin); |
183 context->drawText(font, suffixRunInfo, textOrigin + IntSize(font.width(t
extRun), 0)); | 184 context->drawText(font, suffixRunInfo, textOrigin + IntSize(font.width(t
extRun), 0)); |
184 } else { | 185 } else { |
185 context->drawText(font, suffixRunInfo, textOrigin); | 186 context->drawText(font, suffixRunInfo, textOrigin); |
186 context->drawText(font, textRunPaintInfo, textOrigin + IntSize(font.widt
h(suffixRun), 0)); | 187 context->drawText(font, textRunPaintInfo, textOrigin + IntSize(font.widt
h(suffixRun), 0)); |
187 } | 188 } |
188 } | 189 } |
189 | 190 |
190 } // namespace blink | 191 } // namespace blink |
OLD | NEW |