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

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

Issue 196533012: Make LayoutState always be RAII (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated to ToT 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
« no previous file with comments | « Source/core/rendering/RenderFlexibleBox.h ('k') | Source/core/rendering/RenderGrid.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); 235 LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
236 LayoutRectRecorder recorder(*this); 236 LayoutRectRecorder recorder(*this);
237 237
238 if (updateLogicalWidthAndColumnWidth()) 238 if (updateLogicalWidthAndColumnWidth())
239 relayoutChildren = true; 239 relayoutChildren = true;
240 240
241 LayoutUnit previousHeight = logicalHeight(); 241 LayoutUnit previousHeight = logicalHeight();
242 setLogicalHeight(borderAndPaddingLogicalHeight() + scrollbarLogicalHeight()) ; 242 setLogicalHeight(borderAndPaddingLogicalHeight() + scrollbarLogicalHeight()) ;
243 243
244 LayoutStateMaintainer statePusher(*this, locationOffset()); 244 {
245 LayoutStateMaintainer statePusher(*this, locationOffset());
245 246
246 RenderFlowThread* flowThread = flowThreadContainingBlock(); 247 RenderFlowThread* flowThread = flowThreadContainingBlock();
247 if (updateRegionsAndShapesLogicalSize(flowThread)) 248 if (updateRegionsAndShapesLogicalSize(flowThread))
248 relayoutChildren = true; 249 relayoutChildren = true;
249 250
250 m_numberOfInFlowChildrenOnFirstLine = -1; 251 m_numberOfInFlowChildrenOnFirstLine = -1;
251 252
252 RenderBlock::startDelayUpdateScrollInfo(); 253 RenderBlock::startDelayUpdateScrollInfo();
253 254
254 prepareOrderIteratorAndMargins(); 255 prepareOrderIteratorAndMargins();
255 256
256 ChildFrameRects oldChildRects; 257 ChildFrameRects oldChildRects;
257 appendChildFrameRects(oldChildRects); 258 appendChildFrameRects(oldChildRects);
258 259
259 Vector<LineContext> lineContexts; 260 layoutFlexItems(relayoutChildren);
260 layoutFlexItems(relayoutChildren, lineContexts);
261 261
262 updateLogicalHeight(); 262 RenderBlock::finishDelayUpdateScrollInfo();
263 repositionLogicalHeightDependentFlexItems(lineContexts);
264 263
265 RenderBlock::finishDelayUpdateScrollInfo(); 264 if (logicalHeight() != previousHeight)
265 relayoutChildren = true;
266 266
267 if (logicalHeight() != previousHeight) 267 layoutPositionedObjects(relayoutChildren || isRoot());
268 relayoutChildren = true;
269 268
270 layoutPositionedObjects(relayoutChildren || isRoot()); 269 computeRegionRangeForBlock(flowThread);
271 270
272 computeRegionRangeForBlock(flowThread); 271 repaintChildrenDuringLayoutIfMoved(oldChildRects);
273 272 // FIXME: css3/flexbox/repaint-rtl-column.html seems to repaint more ove rflow than it needs to.
274 repaintChildrenDuringLayoutIfMoved(oldChildRects); 273 computeOverflow(clientLogicalBottomAfterRepositioning());
275 // FIXME: css3/flexbox/repaint-rtl-column.html seems to repaint more overflo w than it needs to. 274 }
276 computeOverflow(clientLogicalBottomAfterRepositioning());
277 statePusher.pop();
278 275
279 updateLayerTransform(); 276 updateLayerTransform();
280 277
281 // Update our scroll information if we're overflow:auto/scroll/hidden now th at we know if 278 // Update our scroll information if we're overflow:auto/scroll/hidden now th at we know if
282 // we overflow or not. 279 // we overflow or not.
283 updateScrollInfoAfterLayout(); 280 updateScrollInfoAfterLayout();
284 281
285 repainter.repaintAfterLayout(); 282 repainter.repaintAfterLayout();
286 283
287 clearNeedsLayout(); 284 clearNeedsLayout();
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(child); 660 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(child);
664 } else { 661 } else {
665 mainAxisExtent = child->maxPreferredLogicalWidth(); 662 mainAxisExtent = child->maxPreferredLogicalWidth();
666 } 663 }
667 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >= 0); 664 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >= 0);
668 return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child); 665 return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child);
669 } 666 }
670 return std::max(LayoutUnit(0), computeMainAxisExtentForChild(child, MainOrPr eferredSize, flexBasis)); 667 return std::max(LayoutUnit(0), computeMainAxisExtentForChild(child, MainOrPr eferredSize, flexBasis));
671 } 668 }
672 669
673 void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren, Vector<LineContex t>& lineContexts) 670 void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren)
674 { 671 {
672 Vector<LineContext> lineContexts;
675 OrderedFlexItemList orderedChildren; 673 OrderedFlexItemList orderedChildren;
676 LayoutUnit sumFlexBaseSize; 674 LayoutUnit sumFlexBaseSize;
677 double totalFlexGrow; 675 double totalFlexGrow;
678 double totalWeightedFlexShrink; 676 double totalWeightedFlexShrink;
679 LayoutUnit sumHypotheticalMainSize; 677 LayoutUnit sumHypotheticalMainSize;
680 678
681 Vector<LayoutUnit, 16> childSizes; 679 Vector<LayoutUnit, 16> childSizes;
682 680
683 m_orderIterator.first(); 681 m_orderIterator.first();
684 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefor e(); 682 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefor e();
(...skipping 15 matching lines...) Expand all
700 // Even if computeNextFlexLine returns true, the flexbox might not have 698 // Even if computeNextFlexLine returns true, the flexbox might not have
701 // a line because all our children might be out of flow positioned. 699 // a line because all our children might be out of flow positioned.
702 // Instead of just checking if we have a line, make sure the flexbox 700 // Instead of just checking if we have a line, make sure the flexbox
703 // has at least a line's worth of height to cover this case. 701 // has at least a line's worth of height to cover this case.
704 LayoutUnit minHeight = borderAndPaddingLogicalHeight() 702 LayoutUnit minHeight = borderAndPaddingLogicalHeight()
705 + lineHeight(true, isHorizontalWritingMode() ? HorizontalLine : Vert icalLine, PositionOfInteriorLineBoxes) 703 + lineHeight(true, isHorizontalWritingMode() ? HorizontalLine : Vert icalLine, PositionOfInteriorLineBoxes)
706 + scrollbarLogicalHeight(); 704 + scrollbarLogicalHeight();
707 if (height() < minHeight) 705 if (height() < minHeight)
708 setLogicalHeight(minHeight); 706 setLogicalHeight(minHeight);
709 } 707 }
708
709 updateLogicalHeight();
710 repositionLogicalHeightDependentFlexItems(lineContexts);
710 } 711 }
711 712
712 LayoutUnit RenderFlexibleBox::autoMarginOffsetInMainAxis(const OrderedFlexItemLi st& children, LayoutUnit& availableFreeSpace) 713 LayoutUnit RenderFlexibleBox::autoMarginOffsetInMainAxis(const OrderedFlexItemLi st& children, LayoutUnit& availableFreeSpace)
713 { 714 {
714 if (availableFreeSpace <= 0) 715 if (availableFreeSpace <= 0)
715 return 0; 716 return 0;
716 717
717 int numberOfAutoMargins = 0; 718 int numberOfAutoMargins = 0;
718 bool isHorizontal = isHorizontalFlow(); 719 bool isHorizontal = isHorizontalFlow();
719 for (size_t i = 0; i < children.size(); ++i) { 720 for (size_t i = 0; i < children.size(); ++i) {
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 ASSERT(child); 1403 ASSERT(child);
1403 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1404 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1404 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1405 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1405 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1406 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1406 adjustAlignmentForChild(child, newOffset - originalOffset); 1407 adjustAlignmentForChild(child, newOffset - originalOffset);
1407 } 1408 }
1408 } 1409 }
1409 } 1410 }
1410 1411
1411 } 1412 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderFlexibleBox.h ('k') | Source/core/rendering/RenderGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698