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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 : m_containingBlockLogicalWidthChanged(containingBlockLogicalWidthChanged), | 53 : m_containingBlockLogicalWidthChanged(containingBlockLogicalWidthChanged), |
54 m_next(layoutObject.view()->layoutState()), | 54 m_next(layoutObject.view()->layoutState()), |
55 m_layoutObject(layoutObject) { | 55 m_layoutObject(layoutObject) { |
56 if (layoutObject.isLayoutFlowThread()) | 56 if (layoutObject.isLayoutFlowThread()) |
57 m_flowThread = toLayoutFlowThread(&layoutObject); | 57 m_flowThread = toLayoutFlowThread(&layoutObject); |
58 else if (!layoutObject.isOutOfFlowPositioned()) | 58 else if (!layoutObject.isOutOfFlowPositioned()) |
59 m_flowThread = m_next->flowThread(); | 59 m_flowThread = m_next->flowThread(); |
60 else | 60 else |
61 m_flowThread = nullptr; | 61 m_flowThread = nullptr; |
62 layoutObject.view()->pushLayoutState(*this); | 62 layoutObject.view()->pushLayoutState(*this); |
| 63 m_heightOffsetForTableHeaders = m_next->heightOffsetForTableHeaders(); |
| 64 |
| 65 if (pageLogicalHeight || layoutObject.isLayoutFlowThread()) { |
| 66 // Entering a new pagination context. |
| 67 m_pageLogicalHeight = pageLogicalHeight; |
| 68 m_pageLogicalHeightChanged = pageLogicalHeightChanged; |
| 69 m_paginationOffset = LayoutSize(); |
| 70 m_isPaginated = true; |
| 71 return; |
| 72 } |
| 73 |
| 74 // Disable pagination for objects we don't support. For now this includes |
| 75 // overflow:scroll/auto, inline blocks and writing mode roots. Additionally, |
| 76 // pagination inside SVG is not allowed. |
| 77 if (layoutObject.getPaginationBreakability() == LayoutBox::ForbidBreaks || |
| 78 (m_layoutObject.isSVG() && !m_layoutObject.isSVGRoot())) { |
| 79 m_flowThread = nullptr; |
| 80 m_pageLogicalHeight = LayoutUnit(); |
| 81 m_pageLogicalHeightChanged = false; |
| 82 m_isPaginated = false; |
| 83 return; |
| 84 } |
| 85 |
| 86 // Propagate the old page height and offset down. |
| 87 m_pageLogicalHeight = m_next->m_pageLogicalHeight; |
| 88 m_pageLogicalHeightChanged = m_next->m_pageLogicalHeightChanged; |
| 89 |
| 90 m_isPaginated = m_pageLogicalHeight || m_flowThread; |
| 91 if (!m_isPaginated) |
| 92 return; |
| 93 |
| 94 // Now adjust the pagination offset, so that we can easily figure out how far |
| 95 // away we are from the start of the pagination context. |
| 96 m_paginationOffset = m_next->m_paginationOffset; |
63 bool fixed = layoutObject.isOutOfFlowPositioned() && | 97 bool fixed = layoutObject.isOutOfFlowPositioned() && |
64 layoutObject.style()->position() == FixedPosition; | 98 layoutObject.style()->position() == FixedPosition; |
65 if (fixed) { | 99 if (fixed) |
66 // FIXME: This doesn't work correctly with transforms. | 100 return; |
67 FloatPoint fixedOffset = | 101 m_paginationOffset = m_next->m_paginationOffset + offset; |
68 layoutObject.view()->localToAbsolute(FloatPoint(), IsFixed); | 102 if (!layoutObject.isOutOfFlowPositioned()) |
69 m_layoutOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + offset; | 103 return; |
70 } else { | 104 if (LayoutObject* container = layoutObject.container()) { |
71 m_layoutOffset = m_next->m_layoutOffset + offset; | 105 if (container->style()->hasInFlowPosition() && |
72 } | 106 container->isLayoutInline()) { |
73 m_heightOffsetForTableHeaders = m_next->heightOffsetForTableHeaders(); | 107 m_paginationOffset += |
74 | 108 toLayoutInline(container)->offsetForInFlowPositionedInline( |
75 if (layoutObject.isOutOfFlowPositioned() && !fixed) { | 109 layoutObject); |
76 if (LayoutObject* container = layoutObject.container()) { | |
77 if (container->style()->hasInFlowPosition() && | |
78 container->isLayoutInline()) | |
79 m_layoutOffset += | |
80 toLayoutInline(container)->offsetForInFlowPositionedInline( | |
81 layoutObject); | |
82 } | |
83 } | |
84 // If we establish a new page height, then cache the offset to the top of the | |
85 // first page. We can compare this later on to figure out what part of the | |
86 // page we're actually on. | |
87 if (pageLogicalHeight || layoutObject.isLayoutFlowThread()) { | |
88 m_pageLogicalHeight = pageLogicalHeight; | |
89 bool isFlipped = layoutObject.style()->isFlippedBlocksWritingMode(); | |
90 m_pageOffset = LayoutSize( | |
91 m_layoutOffset.width() + | |
92 (!isFlipped | |
93 ? layoutObject.borderLeft() + layoutObject.paddingLeft() | |
94 : layoutObject.borderRight() + layoutObject.paddingRight()), | |
95 m_layoutOffset.height() + | |
96 (!isFlipped | |
97 ? layoutObject.borderTop() + layoutObject.paddingTop() | |
98 : layoutObject.borderBottom() + layoutObject.paddingBottom())); | |
99 m_pageLogicalHeightChanged = pageLogicalHeightChanged; | |
100 m_isPaginated = true; | |
101 } else if (m_layoutObject.isSVG() && !m_layoutObject.isSVGRoot()) { | |
102 // Pagination inside SVG is not allowed. | |
103 m_flowThread = nullptr; | |
104 m_pageLogicalHeightChanged = false; | |
105 m_isPaginated = false; | |
106 } else { | |
107 // If we don't establish a new page height, then propagate the old page | |
108 // height and offset down. | |
109 m_pageLogicalHeight = m_next->m_pageLogicalHeight; | |
110 m_pageLogicalHeightChanged = m_next->m_pageLogicalHeightChanged; | |
111 m_pageOffset = m_next->m_pageOffset; | |
112 | |
113 // Disable pagination for objects we don't support. For now this includes | |
114 // overflow:scroll/auto, inline blocks and writing mode roots. | |
115 if (layoutObject.getPaginationBreakability() == LayoutBox::ForbidBreaks) { | |
116 m_flowThread = nullptr; | |
117 m_pageLogicalHeight = LayoutUnit(); | |
118 m_isPaginated = false; | |
119 } else { | |
120 m_isPaginated = m_pageLogicalHeight || m_flowThread; | |
121 } | 110 } |
122 } | 111 } |
123 | 112 |
124 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if | 113 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if |
125 // present. | 114 // present. |
126 } | 115 } |
127 | 116 |
128 LayoutState::LayoutState(LayoutObject& root) | 117 LayoutState::LayoutState(LayoutObject& root) |
129 : m_isPaginated(false), | 118 : m_isPaginated(false), |
130 m_pageLogicalHeightChanged(false), | 119 m_pageLogicalHeightChanged(false), |
131 m_containingBlockLogicalWidthChanged(false), | 120 m_containingBlockLogicalWidthChanged(false), |
132 m_flowThread(nullptr), | 121 m_flowThread(nullptr), |
133 m_next(root.view()->layoutState()), | 122 m_next(root.view()->layoutState()), |
134 m_layoutObject(root) { | 123 m_layoutObject(root) { |
135 ASSERT(!m_next); | 124 ASSERT(!m_next); |
136 // We'll end up pushing in LayoutView itself, so don't bother adding it. | 125 // We'll end up pushing in LayoutView itself, so don't bother adding it. |
137 if (root.isLayoutView()) | 126 if (root.isLayoutView()) |
138 return; | 127 return; |
139 | 128 |
140 root.view()->pushLayoutState(*this); | 129 root.view()->pushLayoutState(*this); |
141 | |
142 LayoutObject* container = root.container(); | |
143 FloatPoint absContentPoint = | |
144 container->localToAbsolute(FloatPoint(), UseTransforms); | |
145 m_layoutOffset = LayoutSize(absContentPoint.x(), absContentPoint.y()); | |
146 } | 130 } |
147 | 131 |
148 LayoutState::~LayoutState() { | 132 LayoutState::~LayoutState() { |
149 if (m_layoutObject.view()->layoutState()) { | 133 if (m_layoutObject.view()->layoutState()) { |
150 ASSERT(m_layoutObject.view()->layoutState() == this); | 134 ASSERT(m_layoutObject.view()->layoutState() == this); |
151 m_layoutObject.view()->popLayoutState(); | 135 m_layoutObject.view()->popLayoutState(); |
152 } | 136 } |
153 } | 137 } |
154 | 138 |
155 LayoutUnit LayoutState::pageLogicalOffset( | 139 LayoutUnit LayoutState::pageLogicalOffset( |
156 const LayoutBox& child, | 140 const LayoutBox& child, |
157 const LayoutUnit& childLogicalOffset) const { | 141 const LayoutUnit& childLogicalOffset) const { |
158 if (child.isHorizontalWritingMode()) | 142 if (child.isHorizontalWritingMode()) |
159 return m_layoutOffset.height() + childLogicalOffset - m_pageOffset.height(); | 143 return m_paginationOffset.height() + childLogicalOffset; |
160 return m_layoutOffset.width() + childLogicalOffset - m_pageOffset.width(); | 144 return m_paginationOffset.width() + childLogicalOffset; |
161 } | 145 } |
162 | 146 |
163 } // namespace blink | 147 } // namespace blink |
OLD | NEW |