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

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

Issue 23694023: Remove an extra relayout for non-percent logical height grid items (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | « no previous file | no next file » | 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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 return (flow == AutoFlowColumn) ? ForRows : ForColumns; 838 return (flow == AutoFlowColumn) ? ForRows : ForColumns;
839 } 839 }
840 840
841 void RenderGrid::dirtyGrid() 841 void RenderGrid::dirtyGrid()
842 { 842 {
843 m_grid.resize(0); 843 m_grid.resize(0);
844 m_gridItemCoordinate.clear(); 844 m_gridItemCoordinate.clear();
845 m_gridIsDirty = true; 845 m_gridIsDirty = true;
846 } 846 }
847 847
848 static bool gridItemDependsOnGridAreaLogicalHeight(const RenderBox* gridItem)
849 {
850 const Length& logicalHeight = gridItem->style()->logicalHeight();
851 // FIXME: This is wrong if the grid area and the grid item have orthogonal w riting modes,
852 // but the rest of the code doesn't handle this case anyway (http://crbug.co m/234194).
853 return logicalHeight.isPercent();
ojan 2013/09/07 17:13:20 Don't you also need to check maxHeight/minHeight?
Julien - ping for review 2013/09/09 18:04:42 I think you are right, I will add more testing for
854 }
855
848 void RenderGrid::layoutGridItems() 856 void RenderGrid::layoutGridItems()
849 { 857 {
850 placeItemsOnGrid(); 858 placeItemsOnGrid();
851 859
852 Vector<GridTrack> columnTracks(gridColumnCount()); 860 Vector<GridTrack> columnTracks(gridColumnCount());
853 Vector<GridTrack> rowTracks(gridRowCount()); 861 Vector<GridTrack> rowTracks(gridRowCount());
854 computedUsedBreadthOfGridTracks(ForColumns, columnTracks, rowTracks); 862 computedUsedBreadthOfGridTracks(ForColumns, columnTracks, rowTracks);
855 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, columnTracks)); 863 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, columnTracks));
856 computedUsedBreadthOfGridTracks(ForRows, columnTracks, rowTracks); 864 computedUsedBreadthOfGridTracks(ForRows, columnTracks, rowTracks);
857 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, rowTracks)); 865 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, rowTracks));
858 866
859 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { 867 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
860 LayoutPoint childPosition = findChildLogicalPosition(child, columnTracks , rowTracks); 868 LayoutPoint childPosition = findChildLogicalPosition(child, columnTracks , rowTracks);
861 869
862 // Because the grid area cannot be styled, we don't need to adjust 870 // Because the grid area cannot be styled, we don't need to adjust
863 // the grid breadth to account for 'box-sizing'. 871 // the grid breadth to account for 'box-sizing'.
864 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit(); 872 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit();
865 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit(); 873 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit();
866 874
867 // FIXME: For children in a content sized track, we clear the overrideCo ntainingBlockContentLogicalHeight 875 // FIXME: For children in a content sized track, we clear the overrideCo ntainingBlockContentLogicalHeight
868 // in minContentForChild / maxContentForChild which means that we will a lways relayout the child. 876 // in minContentForChild / maxContentForChild which means that we will a lways relayout the child.
869 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChild(child, ForColumns, columnTracks); 877 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChild(child, ForColumns, columnTracks);
870 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChild(child, ForRows, rowTracks); 878 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChild(child, ForRows, rowTracks);
871 879
872 SubtreeLayoutScope layoutScope(child); 880 SubtreeLayoutScope layoutScope(child);
873 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || oldOverrideContainingBlockContentLogicalHeight != ove rrideContainingBlockContentLogicalHeight) 881 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (gridItemDependsOnGridAreaLogicalHeight(child) && old OverrideContainingBlockContentLogicalHeight != overrideContainingBlockContentLog icalHeight))
874 layoutScope.setNeedsLayout(child); 882 layoutScope.setNeedsLayout(child);
875 883
876 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth); 884 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth);
877 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight); 885 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight);
878 886
879 LayoutRect oldChildRect = child->frameRect(); 887 LayoutRect oldChildRect = child->frameRect();
880 888
881 // FIXME: Grid items should stretch to fill their cells. Once we 889 // FIXME: Grid items should stretch to fill their cells. Once we
882 // implement grid-{column,row}-align, we can also shrink to fit. For 890 // implement grid-{column,row}-align, we can also shrink to fit. For
883 // now, just size as if we were a regular child. 891 // now, just size as if we were a regular child.
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 if (isOutOfFlowPositioned()) 1160 if (isOutOfFlowPositioned())
1153 return "RenderGrid (positioned)"; 1161 return "RenderGrid (positioned)";
1154 if (isAnonymous()) 1162 if (isAnonymous())
1155 return "RenderGrid (generated)"; 1163 return "RenderGrid (generated)";
1156 if (isRelPositioned()) 1164 if (isRelPositioned())
1157 return "RenderGrid (relative positioned)"; 1165 return "RenderGrid (relative positioned)";
1158 return "RenderGrid"; 1166 return "RenderGrid";
1159 } 1167 }
1160 1168
1161 } // namespace WebCore 1169 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698