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 "core/paint/BlockFlowPainter.h" | 5 #include "core/paint/BlockFlowPainter.h" |
6 | 6 |
7 #include "core/layout/FloatingObjects.h" | 7 #include "core/layout/FloatingObjects.h" |
8 #include "core/layout/LayoutBlockFlow.h" | 8 #include "core/layout/LayoutBlockFlow.h" |
9 #include "core/paint/ClipScope.h" | 9 #include "core/paint/ClipScope.h" |
10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 // FIXME: LayoutPoint version of xPositionForFloatIncludingMargin would
make this much cleaner. | 35 // FIXME: LayoutPoint version of xPositionForFloatIncludingMargin would
make this much cleaner. |
36 LayoutPoint childPoint = m_layoutBlockFlow.flipFloatForWritingModeForChi
ld( | 36 LayoutPoint childPoint = m_layoutBlockFlow.flipFloatForWritingModeForChi
ld( |
37 *floatingObject, LayoutPoint(paintOffset.x() | 37 *floatingObject, LayoutPoint(paintOffset.x() |
38 + m_layoutBlockFlow.xPositionForFloatIncludingMargin(*floatingObject
) - floatingLayoutObject->location().x(), paintOffset.y() | 38 + m_layoutBlockFlow.xPositionForFloatIncludingMargin(*floatingObject
) - floatingLayoutObject->location().x(), paintOffset.y() |
39 + m_layoutBlockFlow.yPositionForFloatIncludingMargin(*floatingObject
) - floatingLayoutObject->location().y())); | 39 + m_layoutBlockFlow.yPositionForFloatIncludingMargin(*floatingObject
) - floatingLayoutObject->location().y())); |
40 ObjectPainter(*floatingLayoutObject).paintAsPseudoStackingContext(floatP
aintInfo, childPoint); | 40 ObjectPainter(*floatingLayoutObject).paintAsPseudoStackingContext(floatP
aintInfo, childPoint); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 void BlockFlowPainter::paintSelection(const PaintInfo& paintInfo, const LayoutPo
int& paintOffset) | |
45 { | |
46 ASSERT(paintInfo.phase == PaintPhaseForeground); | |
47 if (!m_layoutBlockFlow.shouldPaintSelectionGaps()) | |
48 return; | |
49 | |
50 LayoutUnit lastTop = 0; | |
51 LayoutUnit lastLeft = m_layoutBlockFlow.logicalLeftSelectionOffset(&m_layout
BlockFlow, lastTop); | |
52 LayoutUnit lastRight = m_layoutBlockFlow.logicalRightSelectionOffset(&m_layo
utBlockFlow, lastTop); | |
53 | |
54 LayoutRect bounds = m_layoutBlockFlow.visualOverflowRect(); | |
55 bounds.moveBy(paintOffset); | |
56 | |
57 // Only create a DrawingRecorder and ClipScope if skipRecording is false. Th
is logic is needed | |
58 // because selectionGaps(...) needs to be called even when we do not record. | |
59 bool skipRecording = LayoutObjectDrawingRecorder::useCachedDrawingIfPossible
(paintInfo.context, m_layoutBlockFlow, DisplayItem::SelectionGap, paintOffset); | |
60 Optional<LayoutObjectDrawingRecorder> drawingRecorder; | |
61 Optional<ClipScope> clipScope; | |
62 if (!skipRecording) { | |
63 drawingRecorder.emplace(paintInfo.context, m_layoutBlockFlow, DisplayIte
m::SelectionGap, FloatRect(bounds), paintOffset); | |
64 clipScope.emplace(paintInfo.context); | |
65 } | |
66 | |
67 LayoutRect gapRectsBounds = m_layoutBlockFlow.selectionGaps(&m_layoutBlockFl
ow, paintOffset, LayoutSize(), lastTop, lastLeft, lastRight, | |
68 skipRecording ? nullptr : &paintInfo, | |
69 skipRecording ? nullptr : &(*clipScope)); | |
70 // TODO(wkorman): Rework below to process paint invalidation rects during la
yout rather than paint. | |
71 if (!gapRectsBounds.isEmpty()) { | |
72 PaintLayer* layer = m_layoutBlockFlow.enclosingLayer(); | |
73 gapRectsBounds.moveBy(-paintOffset); | |
74 if (!m_layoutBlockFlow.hasLayer()) { | |
75 LayoutRect localBounds(gapRectsBounds); | |
76 m_layoutBlockFlow.flipForWritingMode(localBounds); | |
77 gapRectsBounds = LayoutRect(m_layoutBlockFlow.localToAncestorQuad(Fl
oatRect(localBounds), layer->layoutObject()).enclosingBoundingBox()); | |
78 if (layer->layoutObject()->hasOverflowClip()) | |
79 gapRectsBounds.move(layer->layoutBox()->scrolledContentOffset())
; | |
80 } | |
81 layer->addBlockSelectionGapsBounds(gapRectsBounds); | |
82 } | |
83 } | |
84 | |
85 } // namespace blink | 44 } // namespace blink |
OLD | NEW |