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/BlockFlowPainter.h" | 6 #include "core/paint/BlockFlowPainter.h" |
7 | 7 |
8 #include "core/layout/FloatingObjects.h" | 8 #include "core/layout/FloatingObjects.h" |
9 #include "core/layout/LayoutBlockFlow.h" | 9 #include "core/layout/LayoutBlockFlow.h" |
10 #include "core/paint/ClipScope.h" | 10 #include "core/paint/ClipScope.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 LayoutUnit lastTop = 0; | 56 LayoutUnit lastTop = 0; |
57 LayoutUnit lastLeft = m_layoutBlockFlow.logicalLeftSelectionOffset(&m_layout
BlockFlow, lastTop); | 57 LayoutUnit lastLeft = m_layoutBlockFlow.logicalLeftSelectionOffset(&m_layout
BlockFlow, lastTop); |
58 LayoutUnit lastRight = m_layoutBlockFlow.logicalRightSelectionOffset(&m_layo
utBlockFlow, lastTop); | 58 LayoutUnit lastRight = m_layoutBlockFlow.logicalRightSelectionOffset(&m_layo
utBlockFlow, lastTop); |
59 | 59 |
60 LayoutRect bounds; | 60 LayoutRect bounds; |
61 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 61 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
62 bounds = m_layoutBlockFlow.visualOverflowRect(); | 62 bounds = m_layoutBlockFlow.visualOverflowRect(); |
63 bounds.moveBy(paintOffset); | 63 bounds.moveBy(paintOffset); |
64 } | 64 } |
65 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBlockFlow,
DisplayItem::SelectionGap, bounds); | 65 |
66 ClipScope clipScope(paintInfo.context); | 66 // Only create a DrawingRecorder and ClipScope if skipRecording is false. Th
is logic is needed |
| 67 // because selectionGaps(...) needs to be called even when we do not record. |
| 68 bool skipRecording = LayoutObjectDrawingRecorder::useCachedDrawingIfPossible
(*paintInfo.context, m_layoutBlockFlow, DisplayItem::SelectionGap); |
| 69 Optional<DrawingRecorder> drawingRecorder; |
| 70 Optional<ClipScope> clipScope; |
| 71 if (!skipRecording) { |
| 72 drawingRecorder.emplace(*paintInfo.context, m_layoutBlockFlow, DisplayIt
em::SelectionGap, bounds); |
| 73 clipScope.emplace(paintInfo.context); |
| 74 } |
67 | 75 |
68 LayoutRect gapRectsBounds = m_layoutBlockFlow.selectionGaps(&m_layoutBlockFl
ow, paintOffset, LayoutSize(), lastTop, lastLeft, lastRight, | 76 LayoutRect gapRectsBounds = m_layoutBlockFlow.selectionGaps(&m_layoutBlockFl
ow, paintOffset, LayoutSize(), lastTop, lastLeft, lastRight, |
69 recorder.canUseCachedDrawing() ? nullptr : &paintInfo, | 77 skipRecording ? nullptr : &paintInfo, |
70 recorder.canUseCachedDrawing() ? nullptr : &clipScope); | 78 skipRecording ? nullptr : &(*clipScope)); |
71 // TODO(wkorman): Rework below to process paint invalidation rects during la
yout rather than paint. | 79 // TODO(wkorman): Rework below to process paint invalidation rects during la
yout rather than paint. |
72 if (!gapRectsBounds.isEmpty()) { | 80 if (!gapRectsBounds.isEmpty()) { |
73 DeprecatedPaintLayer* layer = m_layoutBlockFlow.enclosingLayer(); | 81 DeprecatedPaintLayer* layer = m_layoutBlockFlow.enclosingLayer(); |
74 gapRectsBounds.moveBy(-paintOffset); | 82 gapRectsBounds.moveBy(-paintOffset); |
75 if (!m_layoutBlockFlow.hasLayer()) { | 83 if (!m_layoutBlockFlow.hasLayer()) { |
76 LayoutRect localBounds(gapRectsBounds); | 84 LayoutRect localBounds(gapRectsBounds); |
77 m_layoutBlockFlow.flipForWritingMode(localBounds); | 85 m_layoutBlockFlow.flipForWritingMode(localBounds); |
78 gapRectsBounds = LayoutRect(m_layoutBlockFlow.localToContainerQuad(F
loatRect(localBounds), layer->layoutObject()).enclosingBoundingBox()); | 86 gapRectsBounds = LayoutRect(m_layoutBlockFlow.localToContainerQuad(F
loatRect(localBounds), layer->layoutObject()).enclosingBoundingBox()); |
79 if (layer->layoutObject()->hasOverflowClip()) | 87 if (layer->layoutObject()->hasOverflowClip()) |
80 gapRectsBounds.move(layer->layoutBox()->scrolledContentOffset())
; | 88 gapRectsBounds.move(layer->layoutBox()->scrolledContentOffset())
; |
81 } | 89 } |
82 layer->addBlockSelectionGapsBounds(gapRectsBounds); | 90 layer->addBlockSelectionGapsBounds(gapRectsBounds); |
83 } | 91 } |
84 } | 92 } |
85 | 93 |
86 } // namespace blink | 94 } // namespace blink |
OLD | NEW |