Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / LayoutState.h
1 /*
2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef LayoutState_h
27 #define LayoutState_h
28
29 #include "core/rendering/ColumnInfo.h"
30 #include "platform/geometry/LayoutRect.h"
31 #include "wtf/HashMap.h"
32 #include "wtf/Noncopyable.h"
33
34 namespace WebCore {
35
36 class RenderBlockFlow;
37 class RenderBox;
38 class RenderObject;
39 class RenderFlowThread;
40 class ShapeInsideInfo;
41
42 class LayoutState {
43     WTF_MAKE_NONCOPYABLE(LayoutState);
44 public:
45     LayoutState()
46         : m_clipped(false)
47         , m_isPaginated(false)
48         , m_pageLogicalHeightChanged(false)
49 #if !ASSERT_DISABLED
50         , m_layoutDeltaXSaturated(false)
51         , m_layoutDeltaYSaturated(false)
52 #endif
53         , m_columnInfo(0)
54         , m_next(0)
55         , m_shapeInsideInfo(0)
56         , m_pageLogicalHeight(0)
57 #ifndef NDEBUG
58         , m_renderer(0)
59 #endif
60     {
61     }
62
63     LayoutState(LayoutState*, RenderBox*, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged, ColumnInfo*);
64     LayoutState(RenderObject*);
65
66     // LayoutState is allocated out of the rendering partition.
67     void* operator new(size_t);
68     void operator delete(void*);
69
70     void clearPaginationInformation();
71     bool isPaginatingColumns() const { return m_columnInfo; }
72     bool isPaginated() const { return m_isPaginated; }
73
74     // The page logical offset is the object's offset from the top of the page in the page progression
75     // direction (so an x-offset in vertical text and a y-offset for horizontal text).
76     LayoutUnit pageLogicalOffset(const RenderBox*, LayoutUnit childLogicalOffset) const;
77
78     void addForcedColumnBreak(RenderBox*, LayoutUnit childLogicalOffset);
79
80     LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; }
81     bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; }
82
83     LayoutSize layoutOffset() const { return m_layoutOffset; }
84
85     bool needsBlockDirectionLocationSetBeforeLayout() const { return m_isPaginated && m_pageLogicalHeight; }
86
87     ShapeInsideInfo* shapeInsideInfo() const { return m_shapeInsideInfo; }
88
89 #ifndef NDEBUG
90     RenderObject* renderer() const { return m_renderer; }
91 #endif
92
93 public:
94     // Do not add anything apart from bitfields until after m_columnInfo. See https://bugs.webkit.org/show_bug.cgi?id=100173
95     bool m_clipped:1;
96     bool m_isPaginated:1;
97     // If our page height has changed, this will force all blocks to relayout.
98     bool m_pageLogicalHeightChanged:1;
99 #if !ASSERT_DISABLED
100     bool m_layoutDeltaXSaturated:1;
101     bool m_layoutDeltaYSaturated:1;
102 #endif
103     // If the enclosing pagination model is a column model, then this will store column information for easy retrieval/manipulation.
104     ColumnInfo* m_columnInfo;
105     LayoutState* m_next;
106     ShapeInsideInfo* m_shapeInsideInfo;
107
108     // FIXME: Distinguish between the layout clip rect and the paint clip rect which may be larger,
109     // e.g., because of composited scrolling.
110     LayoutRect m_clipRect;
111
112     // x/y offset from container. Includes relative positioning and scroll offsets.
113     LayoutSize m_paintOffset;
114     // x/y offset from container. Does not include relative positioning or scroll offsets.
115     LayoutSize m_layoutOffset;
116     // Transient offset from the final position of the object
117     // used to ensure that repaints happen in the correct place.
118     // This is a total delta accumulated from the root.
119     LayoutSize m_layoutDelta;
120
121     // The current page height for the pagination model that encloses us.
122     LayoutUnit m_pageLogicalHeight;
123     // The offset of the start of the first page in the nearest enclosing pagination model.
124     LayoutSize m_pageOffset;
125
126 #ifndef NDEBUG
127     RenderObject* m_renderer;
128 #endif
129 };
130
131 } // namespace WebCore
132
133 #endif // LayoutState_h