Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / paint / BlockFlowPainter.cpp
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.
4
5 #include "config.h"
6 #include "core/paint/BlockFlowPainter.h"
7
8 #include "core/rendering/FloatingObjects.h"
9 #include "core/rendering/PaintInfo.h"
10 #include "core/rendering/RenderBlockFlow.h"
11
12 namespace blink {
13
14 void BlockFlowPainter::paintFloats(PaintInfo& paintInfo, const LayoutPoint& paintOffset, bool preservePhase)
15 {
16     if (!m_renderBlockFlow.floatingObjects())
17         return;
18
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);
33             if (!preservePhase) {
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);
42             }
43         }
44     }
45 }
46
47 } // namespace blink