Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 876 LayoutUnit sumFlexBaseSize; | 876 LayoutUnit sumFlexBaseSize; |
| 877 double totalFlexGrow; | 877 double totalFlexGrow; |
| 878 double totalFlexShrink; | 878 double totalFlexShrink; |
| 879 double totalWeightedFlexShrink; | 879 double totalWeightedFlexShrink; |
| 880 LayoutUnit sumHypotheticalMainSize; | 880 LayoutUnit sumHypotheticalMainSize; |
| 881 | 881 |
| 882 PaintLayerScrollableArea::PreventRelayoutScope preventRelayoutScope(layoutSc ope); | 882 PaintLayerScrollableArea::PreventRelayoutScope preventRelayoutScope(layoutSc ope); |
| 883 | 883 |
| 884 m_orderIterator.first(); | 884 m_orderIterator.first(); |
| 885 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefor e(); | 885 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefor e(); |
| 886 while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink, sumHypotheticalMainSize, relayoutChild ren)) { | 886 while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink, sumHypotheticalMainSize, relayoutChild ren, layoutScope)) { |
| 887 LayoutUnit containerMainInnerSize = mainAxisContentExtent(sumHypothetica lMainSize); | 887 LayoutUnit containerMainInnerSize = mainAxisContentExtent(sumHypothetica lMainSize); |
| 888 // availableFreeSpace is the initial amount of free space in this flexbo x. | 888 // availableFreeSpace is the initial amount of free space in this flexbo x. |
| 889 // remainingFreeSpace starts out at the same value but as we place and l ay out | 889 // remainingFreeSpace starts out at the same value but as we place and l ay out |
| 890 // flex items we subtract from it. Note that both values can be negative . | 890 // flex items we subtract from it. Note that both values can be negative . |
| 891 LayoutUnit remainingFreeSpace = containerMainInnerSize - sumFlexBaseSize ; | 891 LayoutUnit remainingFreeSpace = containerMainInnerSize - sumFlexBaseSize ; |
| 892 FlexSign flexSign = (sumHypotheticalMainSize < containerMainInnerSize) ? PositiveFlexibility : NegativeFlexibility; | 892 FlexSign flexSign = (sumHypotheticalMainSize < containerMainInnerSize) ? PositiveFlexibility : NegativeFlexibility; |
| 893 freezeInflexibleItems(flexSign, orderedChildren, remainingFreeSpace, tot alFlexGrow, totalFlexShrink, totalWeightedFlexShrink); | 893 freezeInflexibleItems(flexSign, orderedChildren, remainingFreeSpace, tot alFlexGrow, totalFlexShrink, totalWeightedFlexShrink); |
| 894 // The initial free space gets calculated after freezing inflexible item s. https://drafts.csswg.org/css-flexbox/#resolve-flexible-lengths step 3 | 894 // The initial free space gets calculated after freezing inflexible item s. https://drafts.csswg.org/css-flexbox/#resolve-flexible-lengths step 3 |
| 895 const LayoutUnit initialFreeSpace = remainingFreeSpace; | 895 const LayoutUnit initialFreeSpace = remainingFreeSpace; |
| 896 while (!resolveFlexibleLengths(flexSign, orderedChildren, initialFreeSpa ce, remainingFreeSpace, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink) ) { | 896 while (!resolveFlexibleLengths(flexSign, orderedChildren, initialFreeSpa ce, remainingFreeSpace, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink) ) { |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1193 } | 1193 } |
| 1194 | 1194 |
| 1195 if (crossAxisLengthIsDefinite(child, crossMin)) { | 1195 if (crossAxisLengthIsDefinite(child, crossMin)) { |
| 1196 LayoutUnit minValue = computeMainSizeFromAspectRatioUsing(child, crossMi n); | 1196 LayoutUnit minValue = computeMainSizeFromAspectRatioUsing(child, crossMi n); |
| 1197 childSize = std::max(minValue, childSize); | 1197 childSize = std::max(minValue, childSize); |
| 1198 } | 1198 } |
| 1199 | 1199 |
| 1200 return childSize; | 1200 return childSize; |
| 1201 } | 1201 } |
| 1202 | 1202 |
| 1203 bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren , LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalFlexShrink, d ouble& totalWeightedFlexShrink, LayoutUnit& sumHypotheticalMainSize, bool relayo utChildren) | 1203 bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren , LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalFlexShrink, d ouble& totalWeightedFlexShrink, LayoutUnit& sumHypotheticalMainSize, bool relayo utChildren, SubtreeLayoutScope& layoutScope) |
| 1204 { | 1204 { |
| 1205 orderedChildren.clear(); | 1205 orderedChildren.clear(); |
| 1206 sumFlexBaseSize = LayoutUnit(); | 1206 sumFlexBaseSize = LayoutUnit(); |
| 1207 totalFlexGrow = totalFlexShrink = totalWeightedFlexShrink = 0; | 1207 totalFlexGrow = totalFlexShrink = totalWeightedFlexShrink = 0; |
| 1208 sumHypotheticalMainSize = LayoutUnit(); | 1208 sumHypotheticalMainSize = LayoutUnit(); |
| 1209 | 1209 |
| 1210 if (!m_orderIterator.currentChild()) | 1210 if (!m_orderIterator.currentChild()) |
| 1211 return false; | 1211 return false; |
| 1212 | 1212 |
| 1213 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max()); | 1213 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max()); |
| 1214 | 1214 |
| 1215 bool lineHasInFlowItem = false; | 1215 bool lineHasInFlowItem = false; |
| 1216 | 1216 |
| 1217 // Fieldsets need to find their legend and position it inside the border of the object. | |
| 1218 // The legend then gets skipped during normal layout. | |
| 1219 // It doesn't get included in the normal layout process but is instead skipp ed. | |
| 1220 LayoutObject* childToExclude = layoutSpecialExcludedChild(relayoutChildren, layoutScope); | |
|
cbiesinger
2016/07/20 01:42:31
Thanks for doing this! I'll take a closer look tom
Gleb Lanbin
2016/07/21 18:25:31
Done.
| |
| 1221 | |
| 1217 for (LayoutBox* child = m_orderIterator.currentChild(); child; child = m_ord erIterator.next()) { | 1222 for (LayoutBox* child = m_orderIterator.currentChild(); child; child = m_ord erIterator.next()) { |
| 1223 | |
| 1224 if (childToExclude == child) | |
| 1225 continue; // Skip this child, since it will be positioned by the spe cialized subclass (fieldsets runs). | |
| 1226 | |
| 1218 if (child->isOutOfFlowPositioned()) { | 1227 if (child->isOutOfFlowPositioned()) { |
| 1219 orderedChildren.append(FlexItem(child)); | 1228 orderedChildren.append(FlexItem(child)); |
| 1220 continue; | 1229 continue; |
| 1221 } | 1230 } |
| 1222 | 1231 |
| 1223 ChildLayoutType layoutType = relayoutChildren ? ForceLayout : LayoutIfNe eded; | 1232 ChildLayoutType layoutType = relayoutChildren ? ForceLayout : LayoutIfNe eded; |
| 1224 | 1233 |
| 1225 // If this condition is true, then computeMainAxisExtentForChild will ca ll child.intrinsicContentLogicalHeight() | 1234 // If this condition is true, then computeMainAxisExtentForChild will ca ll child.intrinsicContentLogicalHeight() |
| 1226 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min /max/preferred size, | 1235 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min /max/preferred size, |
| 1227 // run layout on it now to make sure its logical height and scroll bars are up to date. | 1236 // run layout on it now to make sure its logical height and scroll bars are up to date. |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1906 ASSERT(child); | 1915 ASSERT(child); |
| 1907 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; | 1916 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; |
| 1908 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; | 1917 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; |
| 1909 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; | 1918 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; |
| 1910 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1919 adjustAlignmentForChild(*child, newOffset - originalOffset); |
| 1911 } | 1920 } |
| 1912 } | 1921 } |
| 1913 } | 1922 } |
| 1914 | 1923 |
| 1915 } // namespace blink | 1924 } // namespace blink |
| OLD | NEW |