2 * Copyright (C) 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
29 #include "ColumnInfo.h"
30 #include "LayoutTypes.h"
31 #include <wtf/HashMap.h>
32 #include <wtf/Noncopyable.h>
40 class RenderFlowThread;
43 WTF_MAKE_NONCOPYABLE(LayoutState);
47 , m_isPaginated(false)
48 , m_pageLogicalHeight(0)
49 , m_pageLogicalHeightChanged(false)
59 LayoutState(LayoutState*, RenderBox*, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged, ColumnInfo*);
60 LayoutState(LayoutState*, RenderFlowThread*, bool regionsChanged);
61 LayoutState(RenderObject*);
63 void destroy(RenderArena*);
65 // Overloaded new operator.
66 void* operator new(size_t, RenderArena*);
68 // Overridden to prevent the normal delete from being called.
69 void operator delete(void*, size_t);
71 void clearPaginationInformation();
72 bool isPaginatingColumns() const { return m_columnInfo && m_columnInfo->paginationUnit() == ColumnInfo::Column; }
73 bool isPaginated() const { return m_isPaginated; }
75 // The page logical offset is the object's offset from the top of the page in the page progression
76 // direction (so an x-offset in vertical text and a y-offset for horizontal text).
77 LayoutUnit pageLogicalOffset(RenderBox*, LayoutUnit childLogicalOffset) const;
79 void addForcedColumnBreak(RenderBox*, LayoutUnit childLogicalOffset);
81 LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; }
82 bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; }
84 RenderBlock* lineGrid() const { return m_lineGrid; }
85 LayoutSize lineGridOffset() const { return m_lineGridOffset; }
86 LayoutSize lineGridPaginationOrigin() const { return m_lineGridPaginationOrigin; }
88 LayoutSize layoutOffset() const { return m_layoutOffset; }
90 bool needsBlockDirectionLocationSetBeforeLayout() const { return m_lineGrid || (m_isPaginated && m_pageLogicalHeight); }
93 // The normal operator new is disallowed.
94 void* operator new(size_t) throw();
96 void propagateLineGridInfo(RenderBox*);
97 void establishLineGrid(RenderBlock*);
99 void computeLineGridPaginationOrigin(RenderBox*);
104 LayoutRect m_clipRect;
106 // x/y offset from container. Includes relative positioning and scroll offsets.
107 LayoutSize m_paintOffset;
108 // x/y offset from container. Does not include relative positioning or scroll offsets.
109 LayoutSize m_layoutOffset;
110 // Transient offset from the final position of the object
111 // used to ensure that repaints happen in the correct place.
112 // This is a total delta accumulated from the root.
113 LayoutSize m_layoutDelta;
115 // The current page height for the pagination model that encloses us.
116 LayoutUnit m_pageLogicalHeight;
117 // If our page height has changed, this will force all blocks to relayout.
118 bool m_pageLogicalHeightChanged;
119 // The offset of the start of the first page in the nearest enclosing pagination model.
120 LayoutSize m_pageOffset;
121 // If the enclosing pagination model is a column model, then this will store column information for easy retrieval/manipulation.
122 ColumnInfo* m_columnInfo;
124 // The current line grid that we're snapping to and the offset of the start of the grid.
125 RenderBlock* m_lineGrid;
126 LayoutSize m_lineGridOffset;
127 LayoutSize m_lineGridPaginationOrigin;
131 RenderObject* m_renderer;
135 } // namespace WebCore
137 #endif // LayoutState_h