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

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

Issue 2206793004: Revert of Add grid/flex layout support for <fieldset> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 1213
1219 LayoutFlexibleBox::FlexItem LayoutFlexibleBox::constructFlexItem(LayoutBox& chil d, ChildLayoutType layoutType) 1214 LayoutFlexibleBox::FlexItem LayoutFlexibleBox::constructFlexItem(LayoutBox& chil d, ChildLayoutType layoutType)
1220 { 1215 {
1221 LayoutUnit borderAndPadding = isHorizontalFlow() ? child.borderAndPaddingWid th() : child.borderAndPaddingHeight(); 1216 LayoutUnit borderAndPadding = isHorizontalFlow() ? child.borderAndPaddingWid th() : child.borderAndPaddingHeight();
1222 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child, borderAndPadding, layoutType); 1217 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child, borderAndPadding, layoutType);
1223 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(ch ild, childInnerFlexBaseSize); 1218 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(ch ild, childInnerFlexBaseSize);
1224 LayoutUnit margin = isHorizontalFlow() ? child.marginWidth() : child.marginH eight(); 1219 LayoutUnit margin = isHorizontalFlow() ? child.marginWidth() : child.marginH eight();
1225 return FlexItem(&child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisEx tent, borderAndPadding, margin); 1220 return FlexItem(&child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisEx tent, borderAndPadding, margin);
1226 } 1221 }
1227 1222
1228 bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren , LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalFlexShrink, d ouble& totalWeightedFlexShrink, LayoutUnit& sumHypotheticalMainSize, bool relayo utChildren, LayoutObject* childToExclude) 1223 bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren , LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalFlexShrink, d ouble& totalWeightedFlexShrink, LayoutUnit& sumHypotheticalMainSize, bool relayo utChildren)
1229 { 1224 {
1230 orderedChildren.clear(); 1225 orderedChildren.clear();
1231 sumFlexBaseSize = LayoutUnit(); 1226 sumFlexBaseSize = LayoutUnit();
1232 totalFlexGrow = totalFlexShrink = totalWeightedFlexShrink = 0; 1227 totalFlexGrow = totalFlexShrink = totalWeightedFlexShrink = 0;
1233 sumHypotheticalMainSize = LayoutUnit(); 1228 sumHypotheticalMainSize = LayoutUnit();
1234 1229
1235 if (!m_orderIterator.currentChild()) 1230 if (!m_orderIterator.currentChild())
1236 return false; 1231 return false;
1237 1232
1238 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max()); 1233 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max());
1239 1234
1240 bool lineHasInFlowItem = false; 1235 bool lineHasInFlowItem = false;
1241 1236
1242 for (LayoutBox* child = m_orderIterator.currentChild(); child; child = m_ord erIterator.next()) { 1237 for (LayoutBox* child = m_orderIterator.currentChild(); child; child = m_ord erIterator.next()) {
1243
1244 if (childToExclude == child)
1245 continue; // Skip this child, since it will be positioned by the spe cialized subclass (fieldsets runs).
1246
1247 if (child->isOutOfFlowPositioned()) { 1238 if (child->isOutOfFlowPositioned()) {
1248 orderedChildren.append(FlexItem(child)); 1239 orderedChildren.append(FlexItem(child));
1249 continue; 1240 continue;
1250 } 1241 }
1251 1242
1252 ChildLayoutType layoutType = relayoutChildren ? ForceLayout : LayoutIfNe eded; 1243 ChildLayoutType layoutType = relayoutChildren ? ForceLayout : LayoutIfNe eded;
1253 1244
1254 // If this condition is true, then computeMainAxisExtentForChild will ca ll child.intrinsicContentLogicalHeight() 1245 // If this condition is true, then computeMainAxisExtentForChild will ca ll child.intrinsicContentLogicalHeight()
1255 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min /max/preferred size, 1246 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min /max/preferred size,
1256 // run layout on it now to make sure its logical height and scroll bars are up to date. 1247 // run layout on it now to make sure its logical height and scroll bars are up to date.
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 ASSERT(child); 1919 ASSERT(child);
1929 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1920 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1930 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1921 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1931 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1922 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1932 adjustAlignmentForChild(*child, newOffset - originalOffset); 1923 adjustAlignmentForChild(*child, newOffset - originalOffset);
1933 } 1924 }
1934 } 1925 }
1935 } 1926 }
1936 1927
1937 } // namespace blink 1928 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutFlexibleBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutGrid.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698