| 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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 Vector<LineContext> lineContexts; | 885 Vector<LineContext> lineContexts; |
| 886 OrderedFlexItemList orderedChildren; | 886 OrderedFlexItemList orderedChildren; |
| 887 LayoutUnit sumFlexBaseSize; | 887 LayoutUnit sumFlexBaseSize; |
| 888 double totalFlexGrow; | 888 double totalFlexGrow; |
| 889 double totalFlexShrink; | 889 double totalFlexShrink; |
| 890 double totalWeightedFlexShrink; | 890 double totalWeightedFlexShrink; |
| 891 LayoutUnit sumHypotheticalMainSize; | 891 LayoutUnit sumHypotheticalMainSize; |
| 892 | 892 |
| 893 PaintLayerScrollableArea::PreventRelayoutScope preventRelayoutScope(layoutSc
ope); | 893 PaintLayerScrollableArea::PreventRelayoutScope preventRelayoutScope(layoutSc
ope); |
| 894 | 894 |
| 895 // Fieldsets need to find their legend and position it inside the border of
the object. | |
| 896 // The legend then gets skipped during normal layout. | |
| 897 // It doesn't get included in the normal layout process but is instead skipp
ed. | |
| 898 LayoutObject* childToExclude = layoutSpecialExcludedChild(relayoutChildren,
layoutScope); | |
| 899 | |
| 900 m_orderIterator.first(); | 895 m_orderIterator.first(); |
| 901 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefor
e(); | 896 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefor
e(); |
| 902 while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow,
totalFlexShrink, totalWeightedFlexShrink, sumHypotheticalMainSize, relayoutChild
ren, childToExclude)) { | 897 while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow,
totalFlexShrink, totalWeightedFlexShrink, sumHypotheticalMainSize, relayoutChild
ren)) { |
| 903 LayoutUnit containerMainInnerSize = mainAxisContentExtent(sumHypothetica
lMainSize); | 898 LayoutUnit containerMainInnerSize = mainAxisContentExtent(sumHypothetica
lMainSize); |
| 904 // availableFreeSpace is the initial amount of free space in this flexbo
x. | 899 // availableFreeSpace is the initial amount of free space in this flexbo
x. |
| 905 // remainingFreeSpace starts out at the same value but as we place and l
ay out | 900 // remainingFreeSpace starts out at the same value but as we place and l
ay out |
| 906 // flex items we subtract from it. Note that both values can be negative
. | 901 // flex items we subtract from it. Note that both values can be negative
. |
| 907 LayoutUnit remainingFreeSpace = containerMainInnerSize - sumFlexBaseSize
; | 902 LayoutUnit remainingFreeSpace = containerMainInnerSize - sumFlexBaseSize
; |
| 908 FlexSign flexSign = (sumHypotheticalMainSize < containerMainInnerSize) ?
PositiveFlexibility : NegativeFlexibility; | 903 FlexSign flexSign = (sumHypotheticalMainSize < containerMainInnerSize) ?
PositiveFlexibility : NegativeFlexibility; |
| 909 freezeInflexibleItems(flexSign, orderedChildren, remainingFreeSpace, tot
alFlexGrow, totalFlexShrink, totalWeightedFlexShrink); | 904 freezeInflexibleItems(flexSign, orderedChildren, remainingFreeSpace, tot
alFlexGrow, totalFlexShrink, totalWeightedFlexShrink); |
| 910 // The initial free space gets calculated after freezing inflexible item
s. https://drafts.csswg.org/css-flexbox/#resolve-flexible-lengths step 3 | 905 // The initial free space gets calculated after freezing inflexible item
s. https://drafts.csswg.org/css-flexbox/#resolve-flexible-lengths step 3 |
| 911 const LayoutUnit initialFreeSpace = remainingFreeSpace; | 906 const LayoutUnit initialFreeSpace = remainingFreeSpace; |
| 912 while (!resolveFlexibleLengths(flexSign, orderedChildren, initialFreeSpa
ce, remainingFreeSpace, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink)
) { | 907 while (!resolveFlexibleLengths(flexSign, orderedChildren, initialFreeSpa
ce, remainingFreeSpace, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink)
) { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 | 1214 |
| 1220 LayoutFlexibleBox::FlexItem LayoutFlexibleBox::constructFlexItem(LayoutBox& chil
d, ChildLayoutType layoutType) | 1215 LayoutFlexibleBox::FlexItem LayoutFlexibleBox::constructFlexItem(LayoutBox& chil
d, ChildLayoutType layoutType) |
| 1221 { | 1216 { |
| 1222 LayoutUnit borderAndPadding = isHorizontalFlow() ? child.borderAndPaddingWid
th() : child.borderAndPaddingHeight(); | 1217 LayoutUnit borderAndPadding = isHorizontalFlow() ? child.borderAndPaddingWid
th() : child.borderAndPaddingHeight(); |
| 1223 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child,
borderAndPadding, layoutType); | 1218 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child,
borderAndPadding, layoutType); |
| 1224 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(ch
ild, childInnerFlexBaseSize); | 1219 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(ch
ild, childInnerFlexBaseSize); |
| 1225 LayoutUnit margin = isHorizontalFlow() ? child.marginWidth() : child.marginH
eight(); | 1220 LayoutUnit margin = isHorizontalFlow() ? child.marginWidth() : child.marginH
eight(); |
| 1226 return FlexItem(&child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisEx
tent, borderAndPadding, margin); | 1221 return FlexItem(&child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisEx
tent, borderAndPadding, margin); |
| 1227 } | 1222 } |
| 1228 | 1223 |
| 1229 bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren
, LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalFlexShrink, d
ouble& totalWeightedFlexShrink, LayoutUnit& sumHypotheticalMainSize, bool relayo
utChildren, LayoutObject* childToExclude) | 1224 bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren
, LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalFlexShrink, d
ouble& totalWeightedFlexShrink, LayoutUnit& sumHypotheticalMainSize, bool relayo
utChildren) |
| 1230 { | 1225 { |
| 1231 orderedChildren.clear(); | 1226 orderedChildren.clear(); |
| 1232 sumFlexBaseSize = LayoutUnit(); | 1227 sumFlexBaseSize = LayoutUnit(); |
| 1233 totalFlexGrow = totalFlexShrink = totalWeightedFlexShrink = 0; | 1228 totalFlexGrow = totalFlexShrink = totalWeightedFlexShrink = 0; |
| 1234 sumHypotheticalMainSize = LayoutUnit(); | 1229 sumHypotheticalMainSize = LayoutUnit(); |
| 1235 | 1230 |
| 1236 if (!m_orderIterator.currentChild()) | 1231 if (!m_orderIterator.currentChild()) |
| 1237 return false; | 1232 return false; |
| 1238 | 1233 |
| 1239 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max()); | 1234 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max()); |
| 1240 | 1235 |
| 1241 bool lineHasInFlowItem = false; | 1236 bool lineHasInFlowItem = false; |
| 1242 | 1237 |
| 1243 for (LayoutBox* child = m_orderIterator.currentChild(); child; child = m_ord
erIterator.next()) { | 1238 for (LayoutBox* child = m_orderIterator.currentChild(); child; child = m_ord
erIterator.next()) { |
| 1244 | |
| 1245 if (childToExclude == child) | |
| 1246 continue; // Skip this child, since it will be positioned by the spe
cialized subclass (fieldsets runs). | |
| 1247 | |
| 1248 if (child->isOutOfFlowPositioned()) { | 1239 if (child->isOutOfFlowPositioned()) { |
| 1249 orderedChildren.append(FlexItem(child)); | 1240 orderedChildren.append(FlexItem(child)); |
| 1250 continue; | 1241 continue; |
| 1251 } | 1242 } |
| 1252 | 1243 |
| 1253 ChildLayoutType layoutType = relayoutChildren ? ForceLayout : LayoutIfNe
eded; | 1244 ChildLayoutType layoutType = relayoutChildren ? ForceLayout : LayoutIfNe
eded; |
| 1254 | 1245 |
| 1255 // If this condition is true, then computeMainAxisExtentForChild will ca
ll child.intrinsicContentLogicalHeight() | 1246 // If this condition is true, then computeMainAxisExtentForChild will ca
ll child.intrinsicContentLogicalHeight() |
| 1256 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min
/max/preferred size, | 1247 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min
/max/preferred size, |
| 1257 // run layout on it now to make sure its logical height and scroll bars
are up to date. | 1248 // run layout on it now to make sure its logical height and scroll bars
are up to date. |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 DCHECK(child); | 1922 DCHECK(child); |
| 1932 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1923 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
| 1933 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1924 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
| 1934 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1925 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
| 1935 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1926 adjustAlignmentForChild(*child, newOffset - originalOffset); |
| 1936 } | 1927 } |
| 1937 } | 1928 } |
| 1938 } | 1929 } |
| 1939 | 1930 |
| 1940 } // namespace blink | 1931 } // namespace blink |
| OLD | NEW |