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
3 // found in the LICENSE file.
6 #include "core/paint/BlockFlowPainter.h"
8 #include "core/rendering/FloatingObjects.h"
9 #include "core/rendering/PaintInfo.h"
10 #include "core/rendering/RenderBlockFlow.h"
14 void BlockFlowPainter::paintFloats(PaintInfo& paintInfo, const LayoutPoint& paintOffset, bool preservePhase)
16 if (!m_renderBlockFlow.floatingObjects())
19 const FloatingObjectSet& floatingObjectSet = m_renderBlockFlow.floatingObjects()->set();
20 FloatingObjectSetIterator end = floatingObjectSet.end();
21 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
22 FloatingObject* floatingObject = it->get();
23 // Only paint the object if our m_shouldPaint flag is set.
24 if (floatingObject->shouldPaint() && !floatingObject->renderer()->hasSelfPaintingLayer()) {
25 PaintInfo currentPaintInfo(paintInfo);
26 currentPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
27 // FIXME: LayoutPoint version of xPositionForFloatIncludingMargin would make this much cleaner.
28 LayoutPoint childPoint = m_renderBlockFlow.flipFloatForWritingModeForChild(
29 floatingObject, LayoutPoint(paintOffset.x()
30 + m_renderBlockFlow.xPositionForFloatIncludingMargin(floatingObject) - floatingObject->renderer()->x(), paintOffset.y()
31 + m_renderBlockFlow.yPositionForFloatIncludingMargin(floatingObject) - floatingObject->renderer()->y()));
32 floatingObject->renderer()->paint(currentPaintInfo, childPoint);
34 currentPaintInfo.phase = PaintPhaseChildBlockBackgrounds;
35 floatingObject->renderer()->paint(currentPaintInfo, childPoint);
36 currentPaintInfo.phase = PaintPhaseFloat;
37 floatingObject->renderer()->paint(currentPaintInfo, childPoint);
38 currentPaintInfo.phase = PaintPhaseForeground;
39 floatingObject->renderer()->paint(currentPaintInfo, childPoint);
40 currentPaintInfo.phase = PaintPhaseOutline;
41 floatingObject->renderer()->paint(currentPaintInfo, childPoint);