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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp

Issue 2128073002: [css-flexbox] Minor performance optimization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« 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 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 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max()); 1198 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max());
1199 1199
1200 bool lineHasInFlowItem = false; 1200 bool lineHasInFlowItem = false;
1201 1201
1202 for (LayoutBox* child = m_orderIterator.currentChild(); child; child = m_ord erIterator.next()) { 1202 for (LayoutBox* child = m_orderIterator.currentChild(); child; child = m_ord erIterator.next()) {
1203 if (child->isOutOfFlowPositioned()) { 1203 if (child->isOutOfFlowPositioned()) {
1204 orderedChildren.append(FlexItem(child)); 1204 orderedChildren.append(FlexItem(child));
1205 continue; 1205 continue;
1206 } 1206 }
1207 1207
1208 ChildLayoutType layoutType = relayoutChildren ? ForceLayout : LayoutIfNe eded;
1209
1208 // If this condition is true, then computeMainAxisExtentForChild will ca ll child.intrinsicContentLogicalHeight() 1210 // If this condition is true, then computeMainAxisExtentForChild will ca ll child.intrinsicContentLogicalHeight()
1209 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min /max/preferred size, 1211 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min /max/preferred size,
1210 // run layout on it now to make sure its logical height and scroll bars are up to date. 1212 // run layout on it now to make sure its logical height and scroll bars are up to date.
1211 if (childHasIntrinsicMainAxisSize(*child) && child->needsLayout()) { 1213 if (childHasIntrinsicMainAxisSize(*child) && child->needsLayout()) {
1212 child->clearOverrideSize(); 1214 child->clearOverrideSize();
1213 child->layoutIfNeeded(); 1215 child->layoutIfNeeded();
1214 cacheChildMainSize(*child); 1216 cacheChildMainSize(*child);
1217 layoutType = LayoutIfNeeded;
1215 } 1218 }
1216 1219
1217 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(*ch ild, relayoutChildren ? ForceLayout : LayoutIfNeeded); 1220 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(*ch ild, layoutType);
1218 LayoutUnit childMainAxisMarginBorderPadding = mainAxisBorderAndPaddingEx tentForChild(*child) 1221 LayoutUnit childMainAxisMarginBorderPadding = mainAxisBorderAndPaddingEx tentForChild(*child)
1219 + (isHorizontalFlow() ? child->marginWidth() : child->marginHeight() ); 1222 + (isHorizontalFlow() ? child->marginWidth() : child->marginHeight() );
1220 LayoutUnit childOuterFlexBaseSize = childInnerFlexBaseSize + childMainAx isMarginBorderPadding; 1223 LayoutUnit childOuterFlexBaseSize = childInnerFlexBaseSize + childMainAx isMarginBorderPadding;
1221 1224
1222 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMa x(*child, childInnerFlexBaseSize); 1225 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMa x(*child, childInnerFlexBaseSize);
1223 LayoutUnit childHypotheticalMainSize = childMinMaxAppliedMainAxisExtent + childMainAxisMarginBorderPadding; 1226 LayoutUnit childHypotheticalMainSize = childMinMaxAppliedMainAxisExtent + childMainAxisMarginBorderPadding;
1224 1227
1225 if (isMultiline() && sumHypotheticalMainSize + childHypotheticalMainSize > lineBreakLength && lineHasInFlowItem) 1228 if (isMultiline() && sumHypotheticalMainSize + childHypotheticalMainSize > lineBreakLength && lineHasInFlowItem)
1226 break; 1229 break;
1227 orderedChildren.append(FlexItem(child, childInnerFlexBaseSize, childMinM axAppliedMainAxisExtent)); 1230 orderedChildren.append(FlexItem(child, childInnerFlexBaseSize, childMinM axAppliedMainAxisExtent));
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 ASSERT(child); 1888 ASSERT(child);
1886 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1889 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1887 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1890 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1888 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1891 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1889 adjustAlignmentForChild(*child, newOffset - originalOffset); 1892 adjustAlignmentForChild(*child, newOffset - originalOffset);
1890 } 1893 }
1891 } 1894 }
1892 } 1895 }
1893 1896
1894 } // namespace blink 1897 } // namespace blink
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