Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: Source/core/rendering/RenderBlockFlow.cpp

Issue 196533012: Make LayoutState always be RAII (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: It's the ToT as you can see Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return; 294 return;
295 295
296 SubtreeLayoutScope layoutScope(this); 296 SubtreeLayoutScope layoutScope(this);
297 297
298 // Multiple passes might be required for column and pagination based layout 298 // Multiple passes might be required for column and pagination based layout
299 // In the case of the old column code the number of passes will only be two 299 // In the case of the old column code the number of passes will only be two
300 // however, in the newer column code the number of passes could equal the 300 // however, in the newer column code the number of passes could equal the
301 // number of columns. 301 // number of columns.
302 bool done = false; 302 bool done = false;
303 LayoutUnit pageLogicalHeight = 0; 303 LayoutUnit pageLogicalHeight = 0;
304 LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
304 while (!done) 305 while (!done)
305 done = layoutBlockFlow(relayoutChildren, pageLogicalHeight, layoutScope) ; 306 done = layoutBlockFlow(relayoutChildren, pageLogicalHeight, layoutScope) ;
307
308 fitBorderToLinesIfNeeded();
309
310 RenderView* renderView = view();
311 if (renderView->layoutState()->m_pageLogicalHeight)
312 setPageLogicalOffset(renderView->layoutState()->pageLogicalOffset(*this, logicalTop()));
313
314 updateLayerTransform();
315
316 // Update our scroll information if we're overflow:auto/scroll/hidden now th at we know if
317 // we overflow or not.
318 updateScrollInfoAfterLayout();
319
320 // Repaint with our new bounds if they are different from our old bounds.
321 bool didFullRepaint = repainter.repaintAfterLayout();
322 if (!didFullRepaint && m_repaintLogicalTop != m_repaintLogicalBottom && (sty le()->visibility() == VISIBLE || enclosingLayer()->hasVisibleContent())) {
323 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
324 setShouldRepaintOverflowIfNeeded(true);
325 else
326 repaintOverflow();
327 }
328 clearNeedsLayout();
306 } 329 }
307 330
308 inline bool RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, LayoutUnit & pageLogicalHeight, SubtreeLayoutScope& layoutScope) 331 inline bool RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, LayoutUnit & pageLogicalHeight, SubtreeLayoutScope& layoutScope)
309 { 332 {
310 LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
311
312 LayoutUnit oldLeft = logicalLeft(); 333 LayoutUnit oldLeft = logicalLeft();
313 if (updateLogicalWidthAndColumnWidth()) 334 if (updateLogicalWidthAndColumnWidth())
314 relayoutChildren = true; 335 relayoutChildren = true;
315 336
316 rebuildFloatsFromIntruding(); 337 rebuildFloatsFromIntruding();
317 338
318 bool pageLogicalHeightChanged = false; 339 bool pageLogicalHeightChanged = false;
319 bool hasSpecifiedPageLogicalHeight = false; 340 bool hasSpecifiedPageLogicalHeight = false;
320 checkForPaginationLogicalHeightChange(pageLogicalHeight, pageLogicalHeightCh anged, hasSpecifiedPageLogicalHeight); 341 checkForPaginationLogicalHeightChange(pageLogicalHeight, pageLogicalHeightCh anged, hasSpecifiedPageLogicalHeight);
321 342
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 if (!firstChild() && !isAnonymousBlock()) 375 if (!firstChild() && !isAnonymousBlock())
355 setChildrenInline(true); 376 setChildrenInline(true);
356 377
357 FastTextAutosizer::LayoutScope fastTextAutosizerLayoutScope(this); 378 FastTextAutosizer::LayoutScope fastTextAutosizerLayoutScope(this);
358 379
359 if (childrenInline()) 380 if (childrenInline())
360 layoutInlineChildren(relayoutChildren, m_repaintLogicalTop, m_repaintLog icalBottom, afterEdge); 381 layoutInlineChildren(relayoutChildren, m_repaintLogicalTop, m_repaintLog icalBottom, afterEdge);
361 else 382 else
362 layoutBlockChildren(relayoutChildren, maxFloatLogicalBottom, layoutScope , beforeEdge, afterEdge); 383 layoutBlockChildren(relayoutChildren, maxFloatLogicalBottom, layoutScope , beforeEdge, afterEdge);
363 384
364 if (frameView()->partialLayout().isStopping()) { 385 if (frameView()->partialLayout().isStopping())
365 statePusher.pop();
366 return true; 386 return true;
367 }
368 387
369 // Expand our intrinsic height to encompass floats. 388 // Expand our intrinsic height to encompass floats.
370 if (lowestFloatLogicalBottom() > (logicalHeight() - afterEdge) && createsBlo ckFormattingContext()) 389 if (lowestFloatLogicalBottom() > (logicalHeight() - afterEdge) && createsBlo ckFormattingContext())
371 setLogicalHeight(lowestFloatLogicalBottom() + afterEdge); 390 setLogicalHeight(lowestFloatLogicalBottom() + afterEdge);
372 391
373 if (RenderMultiColumnFlowThread* flowThread = multiColumnFlowThread()) { 392 if (RenderMultiColumnFlowThread* flowThread = multiColumnFlowThread()) {
374 if (flowThread->recalculateColumnHeights()) { 393 if (flowThread->recalculateColumnHeights()) {
375 setChildNeedsLayout(MarkOnlyThis); 394 setChildNeedsLayout(MarkOnlyThis);
376 statePusher.pop();
377 return false; 395 return false;
378 } 396 }
379 } else if (hasColumns()) { 397 } else if (hasColumns()) {
380 OwnPtr<RenderOverflow> savedOverflow = m_overflow.release(); 398 OwnPtr<RenderOverflow> savedOverflow = m_overflow.release();
381 if (childrenInline()) 399 if (childrenInline())
382 addOverflowFromInlineChildren(); 400 addOverflowFromInlineChildren();
383 else 401 else
384 addOverflowFromBlockChildren(); 402 addOverflowFromBlockChildren();
385 LayoutUnit layoutOverflowLogicalBottom = (isHorizontalWritingMode() ? la youtOverflowRect().maxY() : layoutOverflowRect().maxX()) - borderBefore() - padd ingBefore(); 403 LayoutUnit layoutOverflowLogicalBottom = (isHorizontalWritingMode() ? la youtOverflowRect().maxY() : layoutOverflowRect().maxX()) - borderBefore() - padd ingBefore();
386 m_overflow = savedOverflow.release(); 404 m_overflow = savedOverflow.release();
387 405
388 if (!hasSpecifiedPageLogicalHeight && shouldRelayoutForPagination(pageLo gicalHeight, layoutOverflowLogicalBottom)) { 406 if (!hasSpecifiedPageLogicalHeight && shouldRelayoutForPagination(pageLo gicalHeight, layoutOverflowLogicalBottom)) {
389 statePusher.pop();
390 setEverHadLayout(true); 407 setEverHadLayout(true);
391 return false; 408 return false;
392 } 409 }
393 410
394 setColumnCountAndHeight(ceilf((float)layoutOverflowLogicalBottom / pageL ogicalHeight), pageLogicalHeight); 411 setColumnCountAndHeight(ceilf((float)layoutOverflowLogicalBottom / pageL ogicalHeight), pageLogicalHeight);
395 } 412 }
396 413
397 if (shouldBreakAtLineToAvoidWidow()) { 414 if (shouldBreakAtLineToAvoidWidow()) {
398 statePusher.pop();
399 setEverHadLayout(true); 415 setEverHadLayout(true);
400 return false; 416 return false;
401 } 417 }
402 418
403 // Calculate our new height. 419 // Calculate our new height.
404 LayoutUnit oldHeight = logicalHeight(); 420 LayoutUnit oldHeight = logicalHeight();
405 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); 421 LayoutUnit oldClientAfterEdge = clientLogicalBottom();
406 422
407 if (isRenderFlowThread()) 423 if (isRenderFlowThread())
408 toRenderFlowThread(this)->applyBreakAfterContent(oldClientAfterEdge); 424 toRenderFlowThread(this)->applyBreakAfterContent(oldClientAfterEdge);
(...skipping 17 matching lines...) Expand all
426 if (heightChanged) 442 if (heightChanged)
427 relayoutChildren = true; 443 relayoutChildren = true;
428 444
429 layoutPositionedObjects(relayoutChildren || isRoot(), oldLeft != logicalLeft () ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout); 445 layoutPositionedObjects(relayoutChildren || isRoot(), oldLeft != logicalLeft () ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout);
430 446
431 updateRegionsAndShapesAfterChildLayout(flowThread, heightChanged); 447 updateRegionsAndShapesAfterChildLayout(flowThread, heightChanged);
432 448
433 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway). 449 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway).
434 computeOverflow(oldClientAfterEdge); 450 computeOverflow(oldClientAfterEdge);
435 451
436 statePusher.pop();
437
438 fitBorderToLinesIfNeeded();
439
440 if (frameView()->partialLayout().isStopping())
441 return true;
442
443 RenderView* renderView = view();
444 if (renderView->layoutState()->m_pageLogicalHeight)
445 setPageLogicalOffset(renderView->layoutState()->pageLogicalOffset(*this, logicalTop()));
446
447 updateLayerTransform();
448
449 // Update our scroll information if we're overflow:auto/scroll/hidden now th at we know if
450 // we overflow or not.
451 updateScrollInfoAfterLayout();
452
453 // Repaint with our new bounds if they are different from our old bounds.
454 bool didFullRepaint = repainter.repaintAfterLayout();
455 if (!didFullRepaint && m_repaintLogicalTop != m_repaintLogicalBottom && (sty le()->visibility() == VISIBLE || enclosingLayer()->hasVisibleContent())) {
456 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
457 setShouldRepaintOverflowIfNeeded(true);
458 else
459 repaintOverflow();
460 }
461
462 clearNeedsLayout();
463 return true; 452 return true;
464 } 453 }
465 454
466 void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox* child, App lyLayoutDeltaMode applyDelta) 455 void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox* child, App lyLayoutDeltaMode applyDelta)
467 { 456 {
468 LayoutUnit startPosition = borderStart() + paddingStart(); 457 LayoutUnit startPosition = borderStart() + paddingStart();
469 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) 458 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
470 startPosition -= verticalScrollbarWidth(); 459 startPosition -= verticalScrollbarWidth();
471 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth(); 460 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth();
472 461
(...skipping 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2844 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() 2833 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData()
2845 { 2834 {
2846 if (m_rareData) 2835 if (m_rareData)
2847 return *m_rareData; 2836 return *m_rareData;
2848 2837
2849 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); 2838 m_rareData = adoptPtr(new RenderBlockFlowRareData(this));
2850 return *m_rareData; 2839 return *m_rareData;
2851 } 2840 }
2852 2841
2853 } // namespace WebCore 2842 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698