| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 LayoutRectRecorder recorder(*this); | 167 LayoutRectRecorder recorder(*this); |
| 168 RenderBlock::layout(); | 168 RenderBlock::layout(); |
| 169 | 169 |
| 170 if (RuntimeEnabledFeatures::dialogElementEnabled()) | 170 if (RuntimeEnabledFeatures::dialogElementEnabled()) |
| 171 positionDialogs(); | 171 positionDialogs(); |
| 172 | 172 |
| 173 if (m_frameView->partialLayout().isStopping()) | 173 if (m_frameView->partialLayout().isStopping()) |
| 174 return; | 174 return; |
| 175 | 175 |
| 176 if (hasRenderNamedFlowThreads()) | |
| 177 flowThreadController()->layoutRenderNamedFlowThreads(); | |
| 178 | |
| 179 #ifndef NDEBUG | 176 #ifndef NDEBUG |
| 180 checkLayoutState(state); | 177 checkLayoutState(state); |
| 181 #endif | 178 #endif |
| 182 } | 179 } |
| 183 | 180 |
| 184 #ifndef NDEBUG | 181 #ifndef NDEBUG |
| 185 void RenderView::checkLayoutState(const LayoutState& state) | 182 void RenderView::checkLayoutState(const LayoutState& state) |
| 186 { | 183 { |
| 187 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { | 184 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { |
| 188 ASSERT(layoutDeltaMatches(LayoutSize())); | 185 ASSERT(layoutDeltaMatches(LayoutSize())); |
| 189 } | 186 } |
| 190 ASSERT(!m_layoutStateDisableCount); | 187 ASSERT(!m_layoutStateDisableCount); |
| 191 ASSERT(m_layoutState == &state); | 188 ASSERT(m_layoutState == &state); |
| 192 } | 189 } |
| 193 #endif | 190 #endif |
| 194 | 191 |
| 195 void RenderView::initializeLayoutState(LayoutState& state) | 192 void RenderView::initializeLayoutState(LayoutState& state) |
| 196 { | 193 { |
| 197 // FIXME: May be better to push a clip and avoid issuing offscreen repaints. | 194 // FIXME: May be better to push a clip and avoid issuing offscreen repaints. |
| 198 state.m_clipped = false; | 195 state.m_clipped = false; |
| 199 state.m_pageLogicalHeight = m_pageLogicalHeight; | 196 state.m_pageLogicalHeight = m_pageLogicalHeight; |
| 200 state.m_pageLogicalHeightChanged = m_pageLogicalHeightChanged; | 197 state.m_pageLogicalHeightChanged = m_pageLogicalHeightChanged; |
| 201 state.m_isPaginated = state.m_pageLogicalHeight; | 198 state.m_isPaginated = state.m_pageLogicalHeight; |
| 202 } | 199 } |
| 203 | 200 |
| 204 // The algorithm below assumes this is a full layout. In case there are previous
ly computed values for regions, supplemental steps are taken | |
| 205 // 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 | |
| 206 // layout). | |
| 207 // 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 | |
| 208 // inner flows have the necessary information to correctly fragment the content. | |
| 209 // 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 | |
| 210 // 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 | |
| 211 // belonging to inner flows. This step will correctly set the computedAutoHeight
for the auto-height regions. It's possible for non-auto-height | |
| 212 // regions to relayout if they depend on auto-height regions. This will invalida
te the inner flow threads and mark them as needing layout. | |
| 213 // 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 | |
| 214 // as detected in the previous step. | |
| 215 void RenderView::layoutContentInAutoLogicalHeightRegions(const LayoutState& stat
e) | |
| 216 { | |
| 217 if (!m_frameView->partialLayout().isStopping()) { | |
| 218 // Disable partial layout for any two-pass layout algorithm. | |
| 219 m_frameView->partialLayout().reset(); | |
| 220 } | |
| 221 | |
| 222 // We need to invalidate all the flows with auto-height regions if one such
flow needs layout. | |
| 223 // If none is found we do a layout a check back again afterwards. | |
| 224 if (!flowThreadController()->updateFlowThreadsNeedingLayout()) { | |
| 225 // 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). | |
| 226 layoutContent(state); | |
| 227 | |
| 228 // If we find no named flow needing a two step layout after the first la
yout, exit early. | |
| 229 // Otherwise, initiate the two step layout algorithm and recompute all t
he flows. | |
| 230 if (!flowThreadController()->updateFlowThreadsNeedingTwoStepLayout()) | |
| 231 return; | |
| 232 } | |
| 233 | |
| 234 // Layout to recompute all the named flows with auto-height regions. | |
| 235 layoutContent(state); | |
| 236 | |
| 237 // Propagate the computed auto-height values upwards. | |
| 238 // Non-auto-height regions may invalidate the flow thread because they depen
ded on auto-height regions, but that's ok. | |
| 239 flowThreadController()->updateFlowThreadsIntoConstrainedPhase(); | |
| 240 | |
| 241 // Do one last layout that should update the auto-height regions found in th
e main flow | |
| 242 // and solve pathological dependencies between regions (e.g. a non-auto-heig
ht region depending | |
| 243 // on an auto-height one). | |
| 244 if (needsLayout()) | |
| 245 layoutContent(state); | |
| 246 } | |
| 247 | |
| 248 void RenderView::layout() | 201 void RenderView::layout() |
| 249 { | 202 { |
| 250 if (!document().paginated()) | 203 if (!document().paginated()) |
| 251 setPageLogicalHeight(0); | 204 setPageLogicalHeight(0); |
| 252 | 205 |
| 253 if (shouldUsePrintingLayout()) | 206 if (shouldUsePrintingLayout()) |
| 254 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth()
; | 207 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth()
; |
| 255 | 208 |
| 256 SubtreeLayoutScope layoutScope(this); | 209 SubtreeLayoutScope layoutScope(this); |
| 257 | 210 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 277 ASSERT(!m_layoutState); | 230 ASSERT(!m_layoutState); |
| 278 if (!needsLayout()) | 231 if (!needsLayout()) |
| 279 return; | 232 return; |
| 280 | 233 |
| 281 LayoutState state; | 234 LayoutState state; |
| 282 initializeLayoutState(state); | 235 initializeLayoutState(state); |
| 283 | 236 |
| 284 m_pageLogicalHeightChanged = false; | 237 m_pageLogicalHeightChanged = false; |
| 285 m_layoutState = &state; | 238 m_layoutState = &state; |
| 286 | 239 |
| 287 if (checkTwoPassLayoutForAutoHeightRegions()) | 240 layoutContent(state); |
| 288 layoutContentInAutoLogicalHeightRegions(state); | |
| 289 else | |
| 290 layoutContent(state); | |
| 291 | 241 |
| 292 if (m_frameView->partialLayout().isStopping()) { | 242 if (m_frameView->partialLayout().isStopping()) { |
| 293 m_layoutState = 0; | 243 m_layoutState = 0; |
| 294 return; | 244 return; |
| 295 } | 245 } |
| 296 | 246 |
| 297 #ifndef NDEBUG | 247 #ifndef NDEBUG |
| 298 checkLayoutState(state); | 248 checkLayoutState(state); |
| 299 #endif | 249 #endif |
| 300 m_layoutState = 0; | 250 m_layoutState = 0; |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 | 971 |
| 1022 return m_compositor.get(); | 972 return m_compositor.get(); |
| 1023 } | 973 } |
| 1024 | 974 |
| 1025 void RenderView::setIsInWindow(bool isInWindow) | 975 void RenderView::setIsInWindow(bool isInWindow) |
| 1026 { | 976 { |
| 1027 if (m_compositor) | 977 if (m_compositor) |
| 1028 m_compositor->setIsInWindow(isInWindow); | 978 m_compositor->setIsInWindow(isInWindow); |
| 1029 } | 979 } |
| 1030 | 980 |
| 1031 void RenderView::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl
e) | |
| 1032 { | |
| 1033 RenderBlock::styleDidChange(diff, oldStyle); | |
| 1034 if (hasRenderNamedFlowThreads()) | |
| 1035 flowThreadController()->styleDidChange(); | |
| 1036 } | |
| 1037 | |
| 1038 bool RenderView::hasRenderNamedFlowThreads() const | |
| 1039 { | |
| 1040 return m_flowThreadController && m_flowThreadController->hasRenderNamedFlowT
hreads(); | |
| 1041 } | |
| 1042 | |
| 1043 bool RenderView::checkTwoPassLayoutForAutoHeightRegions() const | |
| 1044 { | |
| 1045 return hasRenderNamedFlowThreads() && m_flowThreadController->hasFlowThreads
WithAutoLogicalHeightRegions(); | |
| 1046 } | |
| 1047 | |
| 1048 FlowThreadController* RenderView::flowThreadController() | 981 FlowThreadController* RenderView::flowThreadController() |
| 1049 { | 982 { |
| 1050 if (!m_flowThreadController) | 983 if (!m_flowThreadController) |
| 1051 m_flowThreadController = FlowThreadController::create(this); | 984 m_flowThreadController = FlowThreadController::create(); |
| 1052 | 985 |
| 1053 return m_flowThreadController.get(); | 986 return m_flowThreadController.get(); |
| 1054 } | 987 } |
| 1055 | 988 |
| 1056 void RenderView::pushLayoutStateForCurrentFlowThread(const RenderObject* object) | 989 void RenderView::pushLayoutStateForCurrentFlowThread(const RenderObject* object) |
| 1057 { | 990 { |
| 1058 if (!m_flowThreadController) | 991 if (!m_flowThreadController) |
| 1059 return; | 992 return; |
| 1060 | 993 |
| 1061 RenderFlowThread* currentFlowThread = m_flowThreadController->currentRenderF
lowThread(); | 994 RenderFlowThread* currentFlowThread = m_flowThreadController->currentRenderF
lowThread(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 return viewWidth(ScrollableArea::IncludeScrollbars) / scale; | 1032 return viewWidth(ScrollableArea::IncludeScrollbars) / scale; |
| 1100 } | 1033 } |
| 1101 | 1034 |
| 1102 double RenderView::layoutViewportHeight() const | 1035 double RenderView::layoutViewportHeight() const |
| 1103 { | 1036 { |
| 1104 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; | 1037 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; |
| 1105 return viewHeight(ScrollableArea::IncludeScrollbars) / scale; | 1038 return viewHeight(ScrollableArea::IncludeScrollbars) / scale; |
| 1106 } | 1039 } |
| 1107 | 1040 |
| 1108 } // namespace WebCore | 1041 } // namespace WebCore |
| OLD | NEW |