| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 LayoutRectRecorder recorder(*this); | 169 LayoutRectRecorder recorder(*this); |
| 170 RenderBlockFlow::layout(); | 170 RenderBlockFlow::layout(); |
| 171 | 171 |
| 172 if (RuntimeEnabledFeatures::dialogElementEnabled()) | 172 if (RuntimeEnabledFeatures::dialogElementEnabled()) |
| 173 positionDialogs(); | 173 positionDialogs(); |
| 174 | 174 |
| 175 if (m_frameView->partialLayout().isStopping()) | 175 if (m_frameView->partialLayout().isStopping()) |
| 176 return; | 176 return; |
| 177 | 177 |
| 178 if (hasRenderNamedFlowThreads()) | |
| 179 flowThreadController()->layoutRenderNamedFlowThreads(); | |
| 180 | |
| 181 #ifndef NDEBUG | 178 #ifndef NDEBUG |
| 182 checkLayoutState(state); | 179 checkLayoutState(state); |
| 183 #endif | 180 #endif |
| 184 } | 181 } |
| 185 | 182 |
| 186 #ifndef NDEBUG | 183 #ifndef NDEBUG |
| 187 void RenderView::checkLayoutState(const LayoutState& state) | 184 void RenderView::checkLayoutState(const LayoutState& state) |
| 188 { | 185 { |
| 189 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { | 186 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { |
| 190 ASSERT(layoutDeltaMatches(LayoutSize())); | 187 ASSERT(layoutDeltaMatches(LayoutSize())); |
| 191 } | 188 } |
| 192 ASSERT(!m_layoutStateDisableCount); | 189 ASSERT(!m_layoutStateDisableCount); |
| 193 ASSERT(m_layoutState == &state); | 190 ASSERT(m_layoutState == &state); |
| 194 } | 191 } |
| 195 #endif | 192 #endif |
| 196 | 193 |
| 197 void RenderView::initializeLayoutState(LayoutState& state) | 194 void RenderView::initializeLayoutState(LayoutState& state) |
| 198 { | 195 { |
| 199 // FIXME: May be better to push a clip and avoid issuing offscreen repaints. | 196 // FIXME: May be better to push a clip and avoid issuing offscreen repaints. |
| 200 state.m_clipped = false; | 197 state.m_clipped = false; |
| 201 state.m_pageLogicalHeight = m_pageLogicalHeight; | 198 state.m_pageLogicalHeight = m_pageLogicalHeight; |
| 202 state.m_pageLogicalHeightChanged = m_pageLogicalHeightChanged; | 199 state.m_pageLogicalHeightChanged = m_pageLogicalHeightChanged; |
| 203 state.m_isPaginated = state.m_pageLogicalHeight; | 200 state.m_isPaginated = state.m_pageLogicalHeight; |
| 204 } | 201 } |
| 205 | 202 |
| 206 // The algorithm below assumes this is a full layout. In case there are previous
ly computed values for regions, supplemental steps are taken | |
| 207 // to ensure the results are the same as those obtained from a full layout (i.e.
the auto-height regions from all the flows are marked as needing | |
| 208 // layout). | |
| 209 // 1. The flows are laid out from the outer flow to the inner flow. This success
fully computes the outer non-auto-height regions size so the | |
| 210 // inner flows have the necessary information to correctly fragment the content. | |
| 211 // 2. The flows are laid out from the inner flow to the outer flow. After an inn
er flow is laid out it goes into the constrained layout phase | |
| 212 // and marks the auto-height regions they need layout. This means the outer flow
s will relayout if they depend on regions with auto-height regions | |
| 213 // belonging to inner flows. This step will correctly set the computedAutoHeight
for the auto-height regions. It's possible for non-auto-height | |
| 214 // regions to relayout if they depend on auto-height regions. This will invalida
te the inner flow threads and mark them as needing layout. | |
| 215 // 3. The last step is to do one last layout if there are pathological dependenc
ies between non-auto-height regions and auto-height regions | |
| 216 // as detected in the previous step. | |
| 217 void RenderView::layoutContentInAutoLogicalHeightRegions(const LayoutState& stat
e) | |
| 218 { | |
| 219 if (!m_frameView->partialLayout().isStopping()) { | |
| 220 // Disable partial layout for any two-pass layout algorithm. | |
| 221 m_frameView->partialLayout().reset(); | |
| 222 } | |
| 223 | |
| 224 // We need to invalidate all the flows with auto-height regions if one such
flow needs layout. | |
| 225 // If none is found we do a layout a check back again afterwards. | |
| 226 if (!flowThreadController()->updateFlowThreadsNeedingLayout()) { | |
| 227 // Do a first layout of the content. In some cases more layouts are not
needed (e.g. only flows with non-auto-height regions have changed). | |
| 228 layoutContent(state); | |
| 229 | |
| 230 // If we find no named flow needing a two step layout after the first la
yout, exit early. | |
| 231 // Otherwise, initiate the two step layout algorithm and recompute all t
he flows. | |
| 232 if (!flowThreadController()->updateFlowThreadsNeedingTwoStepLayout()) | |
| 233 return; | |
| 234 } | |
| 235 | |
| 236 // Layout to recompute all the named flows with auto-height regions. | |
| 237 layoutContent(state); | |
| 238 | |
| 239 // Propagate the computed auto-height values upwards. | |
| 240 // Non-auto-height regions may invalidate the flow thread because they depen
ded on auto-height regions, but that's ok. | |
| 241 flowThreadController()->updateFlowThreadsIntoConstrainedPhase(); | |
| 242 | |
| 243 // Do one last layout that should update the auto-height regions found in th
e main flow | |
| 244 // and solve pathological dependencies between regions (e.g. a non-auto-heig
ht region depending | |
| 245 // on an auto-height one). | |
| 246 if (needsLayout()) | |
| 247 layoutContent(state); | |
| 248 } | |
| 249 | |
| 250 void RenderView::layout() | 203 void RenderView::layout() |
| 251 { | 204 { |
| 252 if (!document().paginated()) | 205 if (!document().paginated()) |
| 253 setPageLogicalHeight(0); | 206 setPageLogicalHeight(0); |
| 254 | 207 |
| 255 if (shouldUsePrintingLayout()) | 208 if (shouldUsePrintingLayout()) |
| 256 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth()
; | 209 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth()
; |
| 257 | 210 |
| 258 SubtreeLayoutScope layoutScope(this); | 211 SubtreeLayoutScope layoutScope(this); |
| 259 | 212 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 279 ASSERT(!m_layoutState); | 232 ASSERT(!m_layoutState); |
| 280 if (!needsLayout()) | 233 if (!needsLayout()) |
| 281 return; | 234 return; |
| 282 | 235 |
| 283 LayoutState state; | 236 LayoutState state; |
| 284 initializeLayoutState(state); | 237 initializeLayoutState(state); |
| 285 | 238 |
| 286 m_pageLogicalHeightChanged = false; | 239 m_pageLogicalHeightChanged = false; |
| 287 m_layoutState = &state; | 240 m_layoutState = &state; |
| 288 | 241 |
| 289 if (checkTwoPassLayoutForAutoHeightRegions()) | 242 layoutContent(state); |
| 290 layoutContentInAutoLogicalHeightRegions(state); | |
| 291 else | |
| 292 layoutContent(state); | |
| 293 | 243 |
| 294 if (m_frameView->partialLayout().isStopping()) { | 244 if (m_frameView->partialLayout().isStopping()) { |
| 295 m_layoutState = 0; | 245 m_layoutState = 0; |
| 296 return; | 246 return; |
| 297 } | 247 } |
| 298 | 248 |
| 299 #ifndef NDEBUG | 249 #ifndef NDEBUG |
| 300 checkLayoutState(state); | 250 checkLayoutState(state); |
| 301 #endif | 251 #endif |
| 302 m_layoutState = 0; | 252 m_layoutState = 0; |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 | 946 |
| 997 return m_compositor.get(); | 947 return m_compositor.get(); |
| 998 } | 948 } |
| 999 | 949 |
| 1000 void RenderView::setIsInWindow(bool isInWindow) | 950 void RenderView::setIsInWindow(bool isInWindow) |
| 1001 { | 951 { |
| 1002 if (m_compositor) | 952 if (m_compositor) |
| 1003 m_compositor->setIsInWindow(isInWindow); | 953 m_compositor->setIsInWindow(isInWindow); |
| 1004 } | 954 } |
| 1005 | 955 |
| 1006 void RenderView::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl
e) | |
| 1007 { | |
| 1008 RenderBlock::styleDidChange(diff, oldStyle); | |
| 1009 if (hasRenderNamedFlowThreads()) | |
| 1010 flowThreadController()->styleDidChange(); | |
| 1011 } | |
| 1012 | |
| 1013 bool RenderView::hasRenderNamedFlowThreads() const | |
| 1014 { | |
| 1015 return m_flowThreadController && m_flowThreadController->hasRenderNamedFlowT
hreads(); | |
| 1016 } | |
| 1017 | |
| 1018 bool RenderView::checkTwoPassLayoutForAutoHeightRegions() const | |
| 1019 { | |
| 1020 return hasRenderNamedFlowThreads() && m_flowThreadController->hasFlowThreads
WithAutoLogicalHeightRegions(); | |
| 1021 } | |
| 1022 | |
| 1023 FlowThreadController* RenderView::flowThreadController() | 956 FlowThreadController* RenderView::flowThreadController() |
| 1024 { | 957 { |
| 1025 if (!m_flowThreadController) | 958 if (!m_flowThreadController) |
| 1026 m_flowThreadController = FlowThreadController::create(this); | 959 m_flowThreadController = FlowThreadController::create(); |
| 1027 | 960 |
| 1028 return m_flowThreadController.get(); | 961 return m_flowThreadController.get(); |
| 1029 } | 962 } |
| 1030 | 963 |
| 1031 void RenderView::pushLayoutStateForCurrentFlowThread(const RenderObject* object) | 964 void RenderView::pushLayoutStateForCurrentFlowThread(const RenderObject* object) |
| 1032 { | 965 { |
| 1033 if (!m_flowThreadController) | 966 if (!m_flowThreadController) |
| 1034 return; | 967 return; |
| 1035 | 968 |
| 1036 RenderFlowThread* currentFlowThread = m_flowThreadController->currentRenderF
lowThread(); | 969 RenderFlowThread* currentFlowThread = m_flowThreadController->currentRenderF
lowThread(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 return viewWidth(ScrollableArea::IncludeScrollbars) / scale; | 1007 return viewWidth(ScrollableArea::IncludeScrollbars) / scale; |
| 1075 } | 1008 } |
| 1076 | 1009 |
| 1077 double RenderView::layoutViewportHeight() const | 1010 double RenderView::layoutViewportHeight() const |
| 1078 { | 1011 { |
| 1079 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; | 1012 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; |
| 1080 return viewHeight(ScrollableArea::IncludeScrollbars) / scale; | 1013 return viewHeight(ScrollableArea::IncludeScrollbars) / scale; |
| 1081 } | 1014 } |
| 1082 | 1015 |
| 1083 } // namespace WebCore | 1016 } // namespace WebCore |
| OLD | NEW |