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

Side by Side Diff: Source/core/layout/LayoutGrid.cpp

Issue 1025213002: Begin tracking why layout is invalidated (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 8 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/layout/LayoutFullScreen.cpp ('k') | Source/core/layout/LayoutHTMLCanvas.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 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 607
608 return GridTrackSize(minTrackBreadth, maxTrackBreadth); 608 return GridTrackSize(minTrackBreadth, maxTrackBreadth);
609 } 609 }
610 610
611 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, Vector<GridTrack> & columnTracks) 611 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, Vector<GridTrack> & columnTracks)
612 { 612 {
613 SubtreeLayoutScope layoutScope(child); 613 SubtreeLayoutScope layoutScope(child);
614 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth () : LayoutUnit(); 614 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth () : LayoutUnit();
615 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh ild(child, ForColumns, columnTracks); 615 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh ild(child, ForColumns, columnTracks);
616 if (child.hasRelativeLogicalHeight() || oldOverrideContainingBlockContentLog icalWidth != overrideContainingBlockContentLogicalWidth) { 616 if (child.hasRelativeLogicalHeight() || oldOverrideContainingBlockContentLog icalWidth != overrideContainingBlockContentLogicalWidth) {
617 layoutScope.setNeedsLayout(&child); 617 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged );
618 // We need to clear the stretched height to properly compute logical hei ght during layout. 618 // We need to clear the stretched height to properly compute logical hei ght during layout.
619 child.clearOverrideLogicalContentHeight(); 619 child.clearOverrideLogicalContentHeight();
620 } 620 }
621 621
622 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC ontentLogicalWidth); 622 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC ontentLogicalWidth);
623 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is 623 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is
624 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). 624 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution).
625 if (child.hasRelativeLogicalHeight()) 625 if (child.hasRelativeLogicalHeight())
626 child.setOverrideContainingBlockContentLogicalHeight(-1); 626 child.setOverrideContainingBlockContentLogicalHeight(-1);
627 child.layoutIfNeeded(); 627 child.layoutIfNeeded();
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 return style()->isGridAutoFlowDirectionColumn() ? ForRows : ForColumns; 1101 return style()->isGridAutoFlowDirectionColumn() ? ForRows : ForColumns;
1102 } 1102 }
1103 1103
1104 void LayoutGrid::dirtyGrid() 1104 void LayoutGrid::dirtyGrid()
1105 { 1105 {
1106 // Even if this could be redundant, it could be seen as a defensive strategy against 1106 // Even if this could be redundant, it could be seen as a defensive strategy against
1107 // style changes events happening during the layout phase or even while the painting process 1107 // style changes events happening during the layout phase or even while the painting process
1108 // is still ongoing. 1108 // is still ongoing.
1109 // Forcing a new layout for the Grid render would cancel any ongoing paintin g and ensure 1109 // Forcing a new layout for the Grid render would cancel any ongoing paintin g and ensure
1110 // the grid and its children are correctly laid out according to the new sty le rules. 1110 // the grid and its children are correctly laid out according to the new sty le rules.
1111 setNeedsLayout(); 1111 setNeedsLayout(LayoutInvalidationReason::GridChanged);
1112 1112
1113 m_grid.resize(0); 1113 m_grid.resize(0);
1114 m_gridItemCoordinate.clear(); 1114 m_gridItemCoordinate.clear();
1115 m_gridIsDirty = true; 1115 m_gridIsDirty = true;
1116 m_gridItemsOverflowingGridArea.resize(0); 1116 m_gridItemsOverflowingGridArea.resize(0);
1117 m_gridItemsIndexesMap.clear(); 1117 m_gridItemsIndexesMap.clear();
1118 } 1118 }
1119 1119
1120 void LayoutGrid::layoutGridItems() 1120 void LayoutGrid::layoutGridItems()
1121 { 1121 {
(...skipping 23 matching lines...) Expand all
1145 // Because the grid area cannot be styled, we don't need to adjust 1145 // Because the grid area cannot be styled, we don't need to adjust
1146 // the grid breadth to account for 'box-sizing'. 1146 // the grid breadth to account for 'box-sizing'.
1147 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit(); 1147 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit();
1148 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit(); 1148 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit();
1149 1149
1150 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChild(*child, ForColumns, sizingData.columnTracks); 1150 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChild(*child, ForColumns, sizingData.columnTracks);
1151 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChild(*child, ForRows, sizingData.rowTracks); 1151 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChild(*child, ForRows, sizingData.rowTracks);
1152 1152
1153 SubtreeLayoutScope layoutScope(*child); 1153 SubtreeLayoutScope layoutScope(*child);
1154 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) 1154 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight()))
1155 layoutScope.setNeedsLayout(child); 1155 layoutScope.setNeedsLayout(child, LayoutInvalidationReason::GridChan ged);
1156 1156
1157 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth); 1157 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth);
1158 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight); 1158 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight);
1159 1159
1160 // Stretching logic might force a child layout, so we need to run it bef ore the layoutIfNeeded 1160 // Stretching logic might force a child layout, so we need to run it bef ore the layoutIfNeeded
1161 // call to avoid unnecessary relayouts. This might imply that child marg ins, needed to correctly 1161 // call to avoid unnecessary relayouts. This might imply that child marg ins, needed to correctly
1162 // determine the available space before stretching, are not set yet. 1162 // determine the available space before stretching, are not set yet.
1163 applyStretchAlignmentToChildIfNeeded(*child, overrideContainingBlockCont entLogicalHeight); 1163 applyStretchAlignmentToChildIfNeeded(*child, overrideContainingBlockCont entLogicalHeight);
1164 1164
1165 child->layoutIfNeeded(); 1165 child->layoutIfNeeded();
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 if (!hasOrthogonalWritingMode) { 1554 if (!hasOrthogonalWritingMode) {
1555 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB eforeStretching(gridAreaBreadthForChild, child); 1555 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB eforeStretching(gridAreaBreadthForChild, child);
1556 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, -1); 1556 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, -1);
1557 1557
1558 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905. 1558 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905.
1559 bool childNeedsRelayout = desiredLogicalHeight != child.logicalHeigh t(); 1559 bool childNeedsRelayout = desiredLogicalHeight != child.logicalHeigh t();
1560 if (childNeedsRelayout || !child.hasOverrideHeight()) 1560 if (childNeedsRelayout || !child.hasOverrideHeight())
1561 child.setOverrideLogicalContentHeight(desiredLogicalHeight - chi ld.borderAndPaddingLogicalHeight()); 1561 child.setOverrideLogicalContentHeight(desiredLogicalHeight - chi ld.borderAndPaddingLogicalHeight());
1562 if (childNeedsRelayout) { 1562 if (childNeedsRelayout) {
1563 child.setLogicalHeight(0); 1563 child.setLogicalHeight(0);
1564 child.setNeedsLayout(); 1564 child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
1565 } 1565 }
1566 } 1566 }
1567 } 1567 }
1568 } 1568 }
1569 1569
1570 LayoutUnit LayoutGrid::rowPositionForChild(const LayoutBox& child) const 1570 LayoutUnit LayoutGrid::rowPositionForChild(const LayoutBox& child) const
1571 { 1571 {
1572 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1572 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1573 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) { 1573 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) {
1574 case ItemPositionSelfStart: 1574 case ItemPositionSelfStart:
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 if (isFloating()) 1767 if (isFloating())
1768 return "LayoutGrid (floating)"; 1768 return "LayoutGrid (floating)";
1769 if (isAnonymous()) 1769 if (isAnonymous())
1770 return "LayoutGrid (anonymous)"; 1770 return "LayoutGrid (anonymous)";
1771 if (isRelPositioned()) 1771 if (isRelPositioned())
1772 return "LayoutGrid (relative positioned)"; 1772 return "LayoutGrid (relative positioned)";
1773 return "LayoutGrid"; 1773 return "LayoutGrid";
1774 } 1774 }
1775 1775
1776 } // namespace blink 1776 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutFullScreen.cpp ('k') | Source/core/layout/LayoutHTMLCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698