| 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/Layer.h" | 9 #include "core/layout/Layer.h" |
| 10 #include "core/layout/LayoutBlockFlow.h" | 10 #include "core/layout/LayoutBlockFlow.h" |
| 11 #include "core/layout/PaintInfo.h" | 11 #include "core/layout/PaintInfo.h" |
| 12 #include "core/paint/RenderDrawingRecorder.h" | 12 #include "core/paint/RenderDrawingRecorder.h" |
| 13 #include "platform/graphics/paint/ClipRecorderStack.h" | 13 #include "platform/graphics/paint/ClipRecorderStack.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 void BlockFlowPainter::paintFloats(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset, bool preservePhase) | 17 void BlockFlowPainter::paintFloats(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset, bool preservePhase) |
| 18 { | 18 { |
| 19 if (!m_layoutBlockFlow.floatingObjects()) | 19 if (!m_layoutBlockFlow.floatingObjects()) |
| 20 return; | 20 return; |
| 21 | 21 |
| 22 const FloatingObjectSet& floatingObjectSet = m_layoutBlockFlow.floatingObjec
ts()->set(); | 22 const FloatingObjectSet& floatingObjectSet = m_layoutBlockFlow.floatingObjec
ts()->set(); |
| 23 FloatingObjectSetIterator end = floatingObjectSet.end(); | 23 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 24 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 24 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
| 25 FloatingObject* floatingObject = it->get(); | 25 FloatingObject* floatingObject = it->get(); |
| 26 // Only paint the object if our m_shouldPaint flag is set. | 26 // Only paint the object if our m_shouldPaint flag is set. |
| 27 if (floatingObject->shouldPaint() && !floatingObject->renderer()->hasSel
fPaintingLayer()) { | 27 if (floatingObject->shouldPaint() && !floatingObject->layoutObject()->ha
sSelfPaintingLayer()) { |
| 28 PaintInfo currentPaintInfo(paintInfo); | 28 PaintInfo currentPaintInfo(paintInfo); |
| 29 currentPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhas
eBlockBackground; | 29 currentPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhas
eBlockBackground; |
| 30 // FIXME: LayoutPoint version of xPositionForFloatIncludingMargin wo
uld make this much cleaner. | 30 // FIXME: LayoutPoint version of xPositionForFloatIncludingMargin wo
uld make this much cleaner. |
| 31 LayoutPoint childPoint = m_layoutBlockFlow.flipFloatForWritingModeFo
rChild( | 31 LayoutPoint childPoint = m_layoutBlockFlow.flipFloatForWritingModeFo
rChild( |
| 32 floatingObject, LayoutPoint(paintOffset.x() | 32 floatingObject, LayoutPoint(paintOffset.x() |
| 33 + m_layoutBlockFlow.xPositionForFloatIncludingMargin(floatingObj
ect) - floatingObject->renderer()->location().x(), paintOffset.y() | 33 + m_layoutBlockFlow.xPositionForFloatIncludingMargin(floatingObj
ect) - floatingObject->layoutObject()->location().x(), paintOffset.y() |
| 34 + m_layoutBlockFlow.yPositionForFloatIncludingMargin(floatingObj
ect) - floatingObject->renderer()->location().y())); | 34 + m_layoutBlockFlow.yPositionForFloatIncludingMargin(floatingObj
ect) - floatingObject->layoutObject()->location().y())); |
| 35 floatingObject->renderer()->paint(currentPaintInfo, childPoint); | 35 floatingObject->layoutObject()->paint(currentPaintInfo, childPoint); |
| 36 if (!preservePhase) { | 36 if (!preservePhase) { |
| 37 currentPaintInfo.phase = PaintPhaseChildBlockBackgrounds; | 37 currentPaintInfo.phase = PaintPhaseChildBlockBackgrounds; |
| 38 floatingObject->renderer()->paint(currentPaintInfo, childPoint); | 38 floatingObject->layoutObject()->paint(currentPaintInfo, childPoi
nt); |
| 39 currentPaintInfo.phase = PaintPhaseFloat; | 39 currentPaintInfo.phase = PaintPhaseFloat; |
| 40 floatingObject->renderer()->paint(currentPaintInfo, childPoint); | 40 floatingObject->layoutObject()->paint(currentPaintInfo, childPoi
nt); |
| 41 currentPaintInfo.phase = PaintPhaseForeground; | 41 currentPaintInfo.phase = PaintPhaseForeground; |
| 42 floatingObject->renderer()->paint(currentPaintInfo, childPoint); | 42 floatingObject->layoutObject()->paint(currentPaintInfo, childPoi
nt); |
| 43 currentPaintInfo.phase = PaintPhaseOutline; | 43 currentPaintInfo.phase = PaintPhaseOutline; |
| 44 floatingObject->renderer()->paint(currentPaintInfo, childPoint); | 44 floatingObject->layoutObject()->paint(currentPaintInfo, childPoi
nt); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 void BlockFlowPainter::paintSelection(const PaintInfo& paintInfo, const LayoutPo
int& paintOffset) | 50 void BlockFlowPainter::paintSelection(const PaintInfo& paintInfo, const LayoutPo
int& paintOffset) |
| 51 { | 51 { |
| 52 if (m_layoutBlockFlow.shouldPaintSelectionGaps() && paintInfo.phase == Paint
PhaseForeground) { | 52 if (m_layoutBlockFlow.shouldPaintSelectionGaps() && paintInfo.phase == Paint
PhaseForeground) { |
| 53 LayoutUnit lastTop = 0; | 53 LayoutUnit lastTop = 0; |
| 54 LayoutUnit lastLeft = m_layoutBlockFlow.logicalLeftSelectionOffset(&m_la
youtBlockFlow, lastTop); | 54 LayoutUnit lastLeft = m_layoutBlockFlow.logicalLeftSelectionOffset(&m_la
youtBlockFlow, lastTop); |
| 55 LayoutUnit lastRight = m_layoutBlockFlow.logicalRightSelectionOffset(&m_
layoutBlockFlow, lastTop); | 55 LayoutUnit lastRight = m_layoutBlockFlow.logicalRightSelectionOffset(&m_
layoutBlockFlow, lastTop); |
| 56 ClipRecorderStack clipRecorderStack(paintInfo.context); | 56 ClipRecorderStack clipRecorderStack(paintInfo.context); |
| 57 | 57 |
| 58 LayoutRect bounds; | 58 LayoutRect bounds; |
| 59 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 59 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 60 bounds = m_layoutBlockFlow.visualOverflowRect(); | 60 bounds = m_layoutBlockFlow.visualOverflowRect(); |
| 61 bounds.moveBy(paintOffset); | 61 bounds.moveBy(paintOffset); |
| 62 } | 62 } |
| 63 RenderDrawingRecorder recorder(paintInfo.context, m_layoutBlockFlow, Dis
playItem::SelectionGap, bounds); | 63 RenderDrawingRecorder recorder(paintInfo.context, m_layoutBlockFlow, Dis
playItem::SelectionGap, bounds); |
| 64 | 64 |
| 65 LayoutRect gapRectsBounds = m_layoutBlockFlow.selectionGaps(&m_layoutBlo
ckFlow, paintOffset, LayoutSize(), lastTop, lastLeft, lastRight, | 65 LayoutRect gapRectsBounds = m_layoutBlockFlow.selectionGaps(&m_layoutBlo
ckFlow, paintOffset, LayoutSize(), lastTop, lastLeft, lastRight, |
| 66 recorder.canUseCachedDrawing() ? nullptr : &paintInfo); | 66 recorder.canUseCachedDrawing() ? nullptr : &paintInfo); |
| 67 if (!gapRectsBounds.isEmpty()) { | 67 if (!gapRectsBounds.isEmpty()) { |
| 68 Layer* layer = m_layoutBlockFlow.enclosingLayer(); | 68 Layer* layer = m_layoutBlockFlow.enclosingLayer(); |
| 69 gapRectsBounds.moveBy(-paintOffset); | 69 gapRectsBounds.moveBy(-paintOffset); |
| 70 if (!m_layoutBlockFlow.hasLayer()) { | 70 if (!m_layoutBlockFlow.hasLayer()) { |
| 71 LayoutRect localBounds(gapRectsBounds); | 71 LayoutRect localBounds(gapRectsBounds); |
| 72 m_layoutBlockFlow.flipForWritingMode(localBounds); | 72 m_layoutBlockFlow.flipForWritingMode(localBounds); |
| 73 gapRectsBounds = LayoutRect(m_layoutBlockFlow.localToContainerQu
ad(FloatRect(localBounds), layer->renderer()).enclosingBoundingBox()); | 73 gapRectsBounds = LayoutRect(m_layoutBlockFlow.localToContainerQu
ad(FloatRect(localBounds), layer->layoutObject()).enclosingBoundingBox()); |
| 74 if (layer->renderer()->hasOverflowClip()) | 74 if (layer->layoutObject()->hasOverflowClip()) |
| 75 gapRectsBounds.move(layer->layoutBox()->scrolledContentOffse
t()); | 75 gapRectsBounds.move(layer->layoutBox()->scrolledContentOffse
t()); |
| 76 } | 76 } |
| 77 layer->addBlockSelectionGapsBounds(gapRectsBounds); | 77 layer->addBlockSelectionGapsBounds(gapRectsBounds); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace blink | 82 } // namespace blink |
| OLD | NEW |