| 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/layout/api/SelectionState.h" |
| 11 #include "core/paint/BlockPainter.h" | 12 #include "core/paint/BlockPainter.h" |
| 12 #include "core/paint/LayoutObjectDrawingRecorder.h" | 13 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 13 #include "core/paint/PaintInfo.h" | 14 #include "core/paint/PaintInfo.h" |
| 14 #include "platform/geometry/LayoutPoint.h" | 15 #include "platform/geometry/LayoutPoint.h" |
| 15 #include "platform/graphics/GraphicsContextStateSaver.h" | 16 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 16 #include "wtf/text/CharacterNames.h" | 17 #include "wtf/text/CharacterNames.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 20 void ListMarkerPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& pai
ntOffset) | 21 void ListMarkerPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& pai
ntOffset) |
| 21 { | 22 { |
| 22 if (paintInfo.phase != PaintPhaseForeground) | 23 if (paintInfo.phase != PaintPhaseForeground) |
| 23 return; | 24 return; |
| 24 | 25 |
| 25 if (m_layoutListMarker.style()->visibility() != VISIBLE) | 26 if (m_layoutListMarker.style()->visibility() != VISIBLE) |
| 26 return; | 27 return; |
| 27 | 28 |
| 28 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutListMarker, paintInfo.phase)) | 29 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutListMarker, paintInfo.phase)) |
| 29 return; | 30 return; |
| 30 | 31 |
| 31 LayoutPoint boxOrigin(paintOffset + m_layoutListMarker.location()); | 32 LayoutPoint boxOrigin(paintOffset + m_layoutListMarker.location()); |
| 32 LayoutRect overflowRect(m_layoutListMarker.visualOverflowRect()); | 33 LayoutRect overflowRect(m_layoutListMarker.visualOverflowRect()); |
| 33 if (m_layoutListMarker.selectionState() != LayoutObject::SelectionNone) | 34 if (m_layoutListMarker.selectionState() != SelectionNone) |
| 34 overflowRect.unite(m_layoutListMarker.localSelectionRect()); | 35 overflowRect.unite(m_layoutListMarker.localSelectionRect()); |
| 35 overflowRect.moveBy(boxOrigin); | 36 overflowRect.moveBy(boxOrigin); |
| 36 | 37 |
| 37 IntRect pixelSnappedOverflowRect = pixelSnappedIntRect(overflowRect); | 38 IntRect pixelSnappedOverflowRect = pixelSnappedIntRect(overflowRect); |
| 38 if (!paintInfo.rect.intersects(pixelSnappedOverflowRect)) | 39 if (!paintInfo.rect.intersects(pixelSnappedOverflowRect)) |
| 39 return; | 40 return; |
| 40 | 41 |
| 41 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutListMarker,
paintInfo.phase, pixelSnappedOverflowRect); | 42 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutListMarker,
paintInfo.phase, pixelSnappedOverflowRect); |
| 42 | 43 |
| 43 LayoutRect box(boxOrigin, m_layoutListMarker.size()); | 44 LayoutRect box(boxOrigin, m_layoutListMarker.size()); |
| 44 | 45 |
| 45 IntRect marker = m_layoutListMarker.getRelativeMarkerRect(); | 46 IntRect marker = m_layoutListMarker.getRelativeMarkerRect(); |
| 46 marker.moveBy(roundedIntPoint(boxOrigin)); | 47 marker.moveBy(roundedIntPoint(boxOrigin)); |
| 47 | 48 |
| 48 GraphicsContext* context = paintInfo.context; | 49 GraphicsContext* context = paintInfo.context; |
| 49 | 50 |
| 50 if (m_layoutListMarker.isImage()) { | 51 if (m_layoutListMarker.isImage()) { |
| 51 context->drawImage(m_layoutListMarker.image()->image(&m_layoutListMarker
, marker.size()).get(), marker); | 52 context->drawImage(m_layoutListMarker.image()->image(&m_layoutListMarker
, marker.size()).get(), marker); |
| 52 if (m_layoutListMarker.selectionState() != LayoutObject::SelectionNone)
{ | 53 if (m_layoutListMarker.selectionState() != SelectionNone) { |
| 53 LayoutRect selRect = m_layoutListMarker.localSelectionRect(); | 54 LayoutRect selRect = m_layoutListMarker.localSelectionRect(); |
| 54 selRect.moveBy(boxOrigin); | 55 selRect.moveBy(boxOrigin); |
| 55 context->fillRect(pixelSnappedIntRect(selRect), m_layoutListMarker.l
istItem()->selectionBackgroundColor()); | 56 context->fillRect(pixelSnappedIntRect(selRect), m_layoutListMarker.l
istItem()->selectionBackgroundColor()); |
| 56 } | 57 } |
| 57 return; | 58 return; |
| 58 } | 59 } |
| 59 | 60 |
| 60 if (m_layoutListMarker.selectionState() != LayoutObject::SelectionNone) { | 61 if (m_layoutListMarker.selectionState() != SelectionNone) { |
| 61 LayoutRect selRect = m_layoutListMarker.localSelectionRect(); | 62 LayoutRect selRect = m_layoutListMarker.localSelectionRect(); |
| 62 selRect.moveBy(boxOrigin); | 63 selRect.moveBy(boxOrigin); |
| 63 context->fillRect(pixelSnappedIntRect(selRect), m_layoutListMarker.listI
tem()->selectionBackgroundColor()); | 64 context->fillRect(pixelSnappedIntRect(selRect), m_layoutListMarker.listI
tem()->selectionBackgroundColor()); |
| 64 } | 65 } |
| 65 | 66 |
| 66 const Color color(m_layoutListMarker.resolveColor(CSSPropertyColor)); | 67 const Color color(m_layoutListMarker.resolveColor(CSSPropertyColor)); |
| 67 context->setStrokeColor(color); | 68 context->setStrokeColor(color); |
| 68 context->setStrokeStyle(SolidStroke); | 69 context->setStrokeStyle(SolidStroke); |
| 69 context->setStrokeThickness(1.0f); | 70 context->setStrokeThickness(1.0f); |
| 70 context->setFillColor(color); | 71 context->setFillColor(color); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 if (m_layoutListMarker.style()->isLeftToRightDirection()) { | 183 if (m_layoutListMarker.style()->isLeftToRightDirection()) { |
| 183 context->drawText(font, textRunPaintInfo, textOrigin); | 184 context->drawText(font, textRunPaintInfo, textOrigin); |
| 184 context->drawText(font, suffixRunInfo, textOrigin + IntSize(font.width(t
extRun), 0)); | 185 context->drawText(font, suffixRunInfo, textOrigin + IntSize(font.width(t
extRun), 0)); |
| 185 } else { | 186 } else { |
| 186 context->drawText(font, suffixRunInfo, textOrigin); | 187 context->drawText(font, suffixRunInfo, textOrigin); |
| 187 context->drawText(font, textRunPaintInfo, textOrigin + IntSize(font.widt
h(suffixRun), 0)); | 188 context->drawText(font, textRunPaintInfo, textOrigin + IntSize(font.widt
h(suffixRun), 0)); |
| 188 } | 189 } |
| 189 } | 190 } |
| 190 | 191 |
| 191 } // namespace blink | 192 } // namespace blink |
| OLD | NEW |