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) 2006 Apple Computer, Inc. | 3 * Copyright (C) 2006 Apple Computer, Inc. |
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 || (renderer.isRenderBlock() && toRenderBlock(renderer).shapeInsideI
nfo()) | 227 || (renderer.isRenderBlock() && toRenderBlock(renderer).shapeInsideI
nfo()) |
228 || (m_layoutState->shapeInsideInfo() && renderer.isRenderBlock() &&
!toRenderBlock(renderer).allowsShapeInsideInfoSharing(&m_layoutState->shapeInsid
eInfo()->owner())) | 228 || (m_layoutState->shapeInsideInfo() && renderer.isRenderBlock() &&
!toRenderBlock(renderer).allowsShapeInsideInfoSharing(&m_layoutState->shapeInsid
eInfo()->owner())) |
229 ) { | 229 ) { |
230 pushLayoutStateForCurrentFlowThread(renderer); | 230 pushLayoutStateForCurrentFlowThread(renderer); |
231 m_layoutState = new LayoutState(m_layoutState, renderer, offset, pag
eHeight, pageHeightChanged, colInfo); | 231 m_layoutState = new LayoutState(m_layoutState, renderer, offset, pag
eHeight, pageHeightChanged, colInfo); |
232 return true; | 232 return true; |
233 } | 233 } |
234 return false; | 234 return false; |
235 } | 235 } |
236 | 236 |
237 void layoutContent(const LayoutState&); | 237 void layoutContent(); |
238 #ifndef NDEBUG | 238 #ifndef NDEBUG |
239 void checkLayoutState(const LayoutState&); | 239 void checkLayoutState(); |
240 #endif | 240 #endif |
241 | 241 |
242 void positionDialog(RenderBox*); | 242 void positionDialog(RenderBox*); |
243 void positionDialogs(); | 243 void positionDialogs(); |
244 | 244 |
245 void pushLayoutStateForCurrentFlowThread(const RenderObject&); | 245 void pushLayoutStateForCurrentFlowThread(const RenderObject&); |
246 void popLayoutStateForCurrentFlowThread(); | 246 void popLayoutStateForCurrentFlowThread(); |
247 | 247 |
248 friend class LayoutStateMaintainer; | 248 friend class LayoutStateMaintainer; |
249 friend class LayoutStateDisabler; | 249 friend class LayoutStateDisabler; |
| 250 friend class RootLayoutStateScope; |
250 | 251 |
251 bool shouldUsePrintingLayout() const; | 252 bool shouldUsePrintingLayout() const; |
252 | 253 |
253 FrameView* m_frameView; | 254 FrameView* m_frameView; |
254 | 255 |
255 RenderObject* m_selectionStart; | 256 RenderObject* m_selectionStart; |
256 RenderObject* m_selectionEnd; | 257 RenderObject* m_selectionEnd; |
257 | 258 |
258 int m_selectionStartPos; | 259 int m_selectionStartPos; |
259 int m_selectionEndPos; | 260 int m_selectionEndPos; |
260 | 261 |
261 int m_maximalOutlineSize; // Used to apply a fudge factor to dirty-rect chec
ks on blocks/tables. | 262 int m_maximalOutlineSize; // Used to apply a fudge factor to dirty-rect chec
ks on blocks/tables. |
262 int m_oldMaximalOutlineSize; // The fudge factor from the previous layout. | 263 int m_oldMaximalOutlineSize; // The fudge factor from the previous layout. |
263 | 264 |
264 LayoutUnit m_pageLogicalHeight; | 265 LayoutUnit m_pageLogicalHeight; |
265 bool m_pageLogicalHeightChanged; | 266 bool m_pageLogicalHeightChanged; |
266 LayoutState* m_layoutState; | 267 LayoutState* m_layoutState; |
267 unsigned m_layoutStateDisableCount; | 268 unsigned m_layoutStateDisableCount; |
268 OwnPtr<RenderLayerCompositor> m_compositor; | 269 OwnPtr<RenderLayerCompositor> m_compositor; |
269 OwnPtr<FlowThreadController> m_flowThreadController; | 270 OwnPtr<FlowThreadController> m_flowThreadController; |
270 RefPtr<IntervalArena> m_intervalArena; | 271 RefPtr<IntervalArena> m_intervalArena; |
271 | 272 |
272 RenderQuote* m_renderQuoteHead; | 273 RenderQuote* m_renderQuoteHead; |
273 unsigned m_renderCounterCount; | 274 unsigned m_renderCounterCount; |
274 }; | 275 }; |
275 | 276 |
276 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderView, isRenderView()); | 277 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderView, isRenderView()); |
277 | 278 |
| 279 class RootLayoutStateScope { |
| 280 public: |
| 281 explicit RootLayoutStateScope(RenderView& view) |
| 282 : m_view(view) |
| 283 { |
| 284 ASSERT(!m_view.m_layoutState); |
| 285 initializeLayoutState(); |
| 286 m_view.m_layoutState = &m_rootLayoutState; |
| 287 } |
| 288 |
| 289 ~RootLayoutStateScope() |
| 290 { |
| 291 ASSERT(m_view.m_layoutState == &m_rootLayoutState); |
| 292 m_view.m_layoutState = 0; |
| 293 } |
| 294 private: |
| 295 void initializeLayoutState(); |
| 296 RenderView& m_view; |
| 297 LayoutState m_rootLayoutState; |
| 298 }; |
| 299 |
278 // Stack-based class to assist with LayoutState push/pop | 300 // Stack-based class to assist with LayoutState push/pop |
279 class LayoutStateMaintainer { | 301 class LayoutStateMaintainer { |
280 WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer); | 302 WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer); |
281 public: | 303 public: |
282 // ctor to push now | 304 // ctor to push now |
283 explicit LayoutStateMaintainer(RenderBox& root, const LayoutSize& offset, La
youtUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0
) | 305 explicit LayoutStateMaintainer(RenderBox& root, const LayoutSize& offset, La
youtUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0
) |
284 : m_view(*root.view()) | 306 : m_view(*root.view()) |
285 , m_disabled(root.shouldDisableLayoutState()) | 307 , m_disabled(root.shouldDisableLayoutState()) |
286 , m_didStart(false) | 308 , m_didStart(false) |
287 , m_didEnd(false) | 309 , m_didEnd(false) |
288 , m_didCreateLayoutState(false) | 310 , m_didCreateLayoutState(false) |
289 { | 311 { |
290 push(root, offset, pageHeight, pageHeightChanged, colInfo); | 312 push(root, offset, pageHeight, pageHeightChanged, colInfo); |
291 } | 313 } |
292 | 314 |
293 // ctor to maybe push later | 315 // ctor to maybe push later |
294 explicit LayoutStateMaintainer(RenderBox& root) | 316 explicit LayoutStateMaintainer(RenderBox& root) |
295 : m_view(*root.view()) | 317 : m_view(*root.view()) |
296 , m_disabled(false) | 318 , m_disabled(false) |
297 , m_didStart(false) | 319 , m_didStart(false) |
298 , m_didEnd(false) | 320 , m_didEnd(false) |
299 , m_didCreateLayoutState(false) | 321 , m_didCreateLayoutState(false) |
300 { | 322 { |
301 } | 323 } |
302 | 324 |
303 ~LayoutStateMaintainer() | 325 ~LayoutStateMaintainer() |
304 { | 326 { |
| 327 if (m_didStart) |
| 328 pop(); |
305 ASSERT(m_didStart == m_didEnd); // if this fires, it means that someon
e did a push(), but forgot to pop(). | 329 ASSERT(m_didStart == m_didEnd); // if this fires, it means that someon
e did a push(), but forgot to pop(). |
306 } | 330 } |
307 | 331 |
308 void push(RenderBox& root, const LayoutSize& offset, LayoutUnit pageHeight =
0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0) | 332 void push(RenderBox& root, const LayoutSize& offset, LayoutUnit pageHeight =
0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0) |
309 { | 333 { |
310 ASSERT(!m_didStart); | 334 ASSERT(!m_didStart); |
311 // We push state even if disabled, because we still need to store layout
Delta | 335 // We push state even if disabled, because we still need to store layout
Delta |
312 m_didCreateLayoutState = m_view.pushLayoutState(root, offset, pageHeight
, pageHeightChanged, colInfo); | 336 m_didCreateLayoutState = m_view.pushLayoutState(root, offset, pageHeight
, pageHeightChanged, colInfo); |
313 if (m_disabled && m_didCreateLayoutState) | 337 if (m_disabled && m_didCreateLayoutState) |
314 m_view.disableLayoutState(); | 338 m_view.disableLayoutState(); |
315 m_didStart = true; | 339 m_didStart = true; |
316 } | 340 } |
317 | 341 |
318 void pop() | |
319 { | |
320 if (m_didStart) { | |
321 ASSERT(!m_didEnd); | |
322 if (m_didCreateLayoutState) { | |
323 m_view.popLayoutState(); | |
324 if (m_disabled) | |
325 m_view.enableLayoutState(); | |
326 } | |
327 | |
328 m_didEnd = true; | |
329 } | |
330 } | |
331 | |
332 bool didPush() const { return m_didStart; } | 342 bool didPush() const { return m_didStart; } |
333 | 343 |
334 private: | 344 private: |
| 345 void pop() |
| 346 { |
| 347 ASSERT(m_didStart && !m_didEnd); |
| 348 if (m_didCreateLayoutState) { |
| 349 m_view.popLayoutState(); |
| 350 if (m_disabled) |
| 351 m_view.enableLayoutState(); |
| 352 } |
| 353 |
| 354 m_didEnd = true; |
| 355 } |
| 356 |
335 RenderView& m_view; | 357 RenderView& m_view; |
336 bool m_disabled : 1; // true if the offset and clip part of layoutSta
te is disabled | 358 bool m_disabled : 1; // true if the offset and clip part of layoutSta
te is disabled |
337 bool m_didStart : 1; // true if we did a push or disable | 359 bool m_didStart : 1; // true if we did a push or disable |
338 bool m_didEnd : 1; // true if we popped or re-enabled | 360 bool m_didEnd : 1; // true if we popped or re-enabled |
339 bool m_didCreateLayoutState : 1; // true if we actually made a layout state. | 361 bool m_didCreateLayoutState : 1; // true if we actually made a layout state. |
340 }; | 362 }; |
341 | 363 |
342 class LayoutStateDisabler { | 364 class LayoutStateDisabler { |
343 WTF_MAKE_NONCOPYABLE(LayoutStateDisabler); | 365 WTF_MAKE_NONCOPYABLE(LayoutStateDisabler); |
344 public: | 366 public: |
345 LayoutStateDisabler(const RenderBox& root) | 367 LayoutStateDisabler(const RenderBox& root) |
346 : m_view(*root.view()) | 368 : m_view(*root.view()) |
347 { | 369 { |
348 m_view.disableLayoutState(); | 370 m_view.disableLayoutState(); |
349 } | 371 } |
350 | 372 |
351 ~LayoutStateDisabler() | 373 ~LayoutStateDisabler() |
352 { | 374 { |
353 m_view.enableLayoutState(); | 375 m_view.enableLayoutState(); |
354 } | 376 } |
355 private: | 377 private: |
356 RenderView& m_view; | 378 RenderView& m_view; |
357 }; | 379 }; |
358 | 380 |
359 } // namespace WebCore | 381 } // namespace WebCore |
360 | 382 |
361 #endif // RenderView_h | 383 #endif // RenderView_h |
OLD | NEW |