OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #include "core/layout/LayoutState.h" | 26 #include "core/layout/LayoutState.h" |
27 | 27 |
28 #include "core/layout/LayoutFlowThread.h" | 28 #include "core/layout/LayoutFlowThread.h" |
29 #include "core/layout/LayoutInline.h" | 29 #include "core/layout/LayoutInline.h" |
30 #include "core/layout/LayoutView.h" | 30 #include "core/layout/LayoutView.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 LayoutState::LayoutState(LayoutUnit pageLogicalHeight, | 34 LayoutState::LayoutState(LayoutUnit pageLogicalHeight, |
35 bool pageLogicalHeightChanged, | |
36 LayoutView& view) | 35 LayoutView& view) |
37 : m_isPaginated(pageLogicalHeight), | 36 : m_isPaginated(pageLogicalHeight), |
38 m_pageLogicalHeightChanged(pageLogicalHeightChanged), | |
39 m_containingBlockLogicalWidthChanged(false), | 37 m_containingBlockLogicalWidthChanged(false), |
40 m_paginationStateChanged(false), | 38 m_paginationStateChanged(false), |
41 m_flowThread(nullptr), | 39 m_flowThread(nullptr), |
42 m_next(nullptr), | 40 m_next(nullptr), |
43 m_pageLogicalHeight(pageLogicalHeight), | 41 m_pageLogicalHeight(pageLogicalHeight), |
44 m_layoutObject(view) { | 42 m_layoutObject(view) { |
45 ASSERT(!view.layoutState()); | 43 ASSERT(!view.layoutState()); |
46 view.pushLayoutState(*this); | 44 view.pushLayoutState(*this); |
47 } | 45 } |
48 | 46 |
49 LayoutState::LayoutState(LayoutBox& layoutObject, | 47 LayoutState::LayoutState(LayoutBox& layoutObject, |
50 LayoutUnit pageLogicalHeight, | 48 LayoutUnit pageLogicalHeight, |
51 bool pageLogicalHeightChanged, | |
52 bool containingBlockLogicalWidthChanged) | 49 bool containingBlockLogicalWidthChanged) |
53 : m_containingBlockLogicalWidthChanged(containingBlockLogicalWidthChanged), | 50 : m_containingBlockLogicalWidthChanged(containingBlockLogicalWidthChanged), |
54 m_next(layoutObject.view()->layoutState()), | 51 m_next(layoutObject.view()->layoutState()), |
55 m_layoutObject(layoutObject) { | 52 m_layoutObject(layoutObject) { |
56 if (layoutObject.isLayoutFlowThread()) | 53 if (layoutObject.isLayoutFlowThread()) |
57 m_flowThread = toLayoutFlowThread(&layoutObject); | 54 m_flowThread = toLayoutFlowThread(&layoutObject); |
58 else if (!layoutObject.isOutOfFlowPositioned()) | 55 else if (!layoutObject.isOutOfFlowPositioned()) |
59 m_flowThread = m_next->flowThread(); | 56 m_flowThread = m_next->flowThread(); |
60 else | 57 else |
61 m_flowThread = nullptr; | 58 m_flowThread = nullptr; |
62 m_paginationStateChanged = m_next->m_paginationStateChanged; | 59 m_paginationStateChanged = m_next->m_paginationStateChanged; |
63 layoutObject.view()->pushLayoutState(*this); | 60 layoutObject.view()->pushLayoutState(*this); |
64 m_heightOffsetForTableHeaders = m_next->heightOffsetForTableHeaders(); | 61 m_heightOffsetForTableHeaders = m_next->heightOffsetForTableHeaders(); |
65 | 62 |
66 if (pageLogicalHeight || layoutObject.isLayoutFlowThread()) { | 63 if (pageLogicalHeight || layoutObject.isLayoutFlowThread()) { |
67 // Entering a new pagination context. | 64 // Entering a new pagination context. |
68 m_pageLogicalHeight = pageLogicalHeight; | 65 m_pageLogicalHeight = pageLogicalHeight; |
69 m_pageLogicalHeightChanged = pageLogicalHeightChanged; | |
70 m_paginationOffset = LayoutSize(); | 66 m_paginationOffset = LayoutSize(); |
71 m_isPaginated = true; | 67 m_isPaginated = true; |
72 return; | 68 return; |
73 } | 69 } |
74 | 70 |
75 // Disable pagination for objects we don't support. For now this includes | 71 // Disable pagination for objects we don't support. For now this includes |
76 // overflow:scroll/auto, inline blocks and writing mode roots. Additionally, | 72 // overflow:scroll/auto, inline blocks and writing mode roots. Additionally, |
77 // pagination inside SVG is not allowed. | 73 // pagination inside SVG is not allowed. |
78 if (layoutObject.getPaginationBreakability() == LayoutBox::ForbidBreaks || | 74 if (layoutObject.getPaginationBreakability() == LayoutBox::ForbidBreaks || |
79 (m_layoutObject.isSVG() && !m_layoutObject.isSVGRoot())) { | 75 (m_layoutObject.isSVG() && !m_layoutObject.isSVGRoot())) { |
80 m_flowThread = nullptr; | 76 m_flowThread = nullptr; |
81 m_pageLogicalHeight = LayoutUnit(); | 77 m_pageLogicalHeight = LayoutUnit(); |
82 m_pageLogicalHeightChanged = false; | |
83 m_isPaginated = false; | 78 m_isPaginated = false; |
84 return; | 79 return; |
85 } | 80 } |
86 | 81 |
87 // Propagate the old page height and offset down. | 82 // Propagate the old page height and offset down. |
88 m_pageLogicalHeight = m_next->m_pageLogicalHeight; | 83 m_pageLogicalHeight = m_next->m_pageLogicalHeight; |
89 m_pageLogicalHeightChanged = m_next->m_pageLogicalHeightChanged; | |
90 | 84 |
91 m_isPaginated = m_pageLogicalHeight || m_flowThread; | 85 m_isPaginated = m_pageLogicalHeight || m_flowThread; |
92 if (!m_isPaginated) | 86 if (!m_isPaginated) |
93 return; | 87 return; |
94 | 88 |
95 // Now adjust the pagination offset, so that we can easily figure out how far | 89 // Now adjust the pagination offset, so that we can easily figure out how far |
96 // away we are from the start of the pagination context. | 90 // away we are from the start of the pagination context. |
97 m_paginationOffset = m_next->m_paginationOffset; | 91 m_paginationOffset = m_next->m_paginationOffset; |
98 bool fixed = layoutObject.isOutOfFlowPositioned() && | 92 bool fixed = layoutObject.isOutOfFlowPositioned() && |
99 layoutObject.style()->position() == FixedPosition; | 93 layoutObject.style()->position() == FixedPosition; |
(...skipping 11 matching lines...) Expand all Loading... |
111 layoutObject); | 105 layoutObject); |
112 } | 106 } |
113 } | 107 } |
114 | 108 |
115 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if | 109 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if |
116 // present. | 110 // present. |
117 } | 111 } |
118 | 112 |
119 LayoutState::LayoutState(LayoutObject& root) | 113 LayoutState::LayoutState(LayoutObject& root) |
120 : m_isPaginated(false), | 114 : m_isPaginated(false), |
121 m_pageLogicalHeightChanged(false), | |
122 m_containingBlockLogicalWidthChanged(false), | 115 m_containingBlockLogicalWidthChanged(false), |
123 m_paginationStateChanged(false), | 116 m_paginationStateChanged(false), |
124 m_flowThread(nullptr), | 117 m_flowThread(nullptr), |
125 m_next(root.view()->layoutState()), | 118 m_next(root.view()->layoutState()), |
126 m_layoutObject(root) { | 119 m_layoutObject(root) { |
127 ASSERT(!m_next); | 120 ASSERT(!m_next); |
128 // We'll end up pushing in LayoutView itself, so don't bother adding it. | 121 // We'll end up pushing in LayoutView itself, so don't bother adding it. |
129 if (root.isLayoutView()) | 122 if (root.isLayoutView()) |
130 return; | 123 return; |
131 | 124 |
132 root.view()->pushLayoutState(*this); | 125 root.view()->pushLayoutState(*this); |
133 } | 126 } |
134 | 127 |
135 LayoutState::~LayoutState() { | 128 LayoutState::~LayoutState() { |
136 if (m_layoutObject.view()->layoutState()) { | 129 if (m_layoutObject.view()->layoutState()) { |
137 ASSERT(m_layoutObject.view()->layoutState() == this); | 130 ASSERT(m_layoutObject.view()->layoutState() == this); |
138 m_layoutObject.view()->popLayoutState(); | 131 m_layoutObject.view()->popLayoutState(); |
139 } | 132 } |
140 } | 133 } |
141 | 134 |
142 LayoutUnit LayoutState::pageLogicalOffset( | 135 LayoutUnit LayoutState::pageLogicalOffset( |
143 const LayoutBox& child, | 136 const LayoutBox& child, |
144 const LayoutUnit& childLogicalOffset) const { | 137 const LayoutUnit& childLogicalOffset) const { |
145 if (child.isHorizontalWritingMode()) | 138 if (child.isHorizontalWritingMode()) |
146 return m_paginationOffset.height() + childLogicalOffset; | 139 return m_paginationOffset.height() + childLogicalOffset; |
147 return m_paginationOffset.width() + childLogicalOffset; | 140 return m_paginationOffset.width() + childLogicalOffset; |
148 } | 141 } |
149 | 142 |
150 } // namespace blink | 143 } // namespace blink |
OLD | NEW |