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

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

Issue 2150003005: Add grid/flex layout support for <fieldset> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert a11y test expectations & explicitely set a11y fieldset role to GroupRole 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
895 m_orderIterator.first(); 900 m_orderIterator.first();
896 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefor e(); 901 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefor e();
897 while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink, sumHypotheticalMainSize, relayoutChild ren)) { 902 while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink, sumHypotheticalMainSize, relayoutChild ren, childToExclude)) {
898 LayoutUnit containerMainInnerSize = mainAxisContentExtent(sumHypothetica lMainSize); 903 LayoutUnit containerMainInnerSize = mainAxisContentExtent(sumHypothetica lMainSize);
899 // availableFreeSpace is the initial amount of free space in this flexbo x. 904 // availableFreeSpace is the initial amount of free space in this flexbo x.
900 // remainingFreeSpace starts out at the same value but as we place and l ay out 905 // remainingFreeSpace starts out at the same value but as we place and l ay out
901 // flex items we subtract from it. Note that both values can be negative . 906 // flex items we subtract from it. Note that both values can be negative .
902 LayoutUnit remainingFreeSpace = containerMainInnerSize - sumFlexBaseSize ; 907 LayoutUnit remainingFreeSpace = containerMainInnerSize - sumFlexBaseSize ;
903 FlexSign flexSign = (sumHypotheticalMainSize < containerMainInnerSize) ? PositiveFlexibility : NegativeFlexibility; 908 FlexSign flexSign = (sumHypotheticalMainSize < containerMainInnerSize) ? PositiveFlexibility : NegativeFlexibility;
904 freezeInflexibleItems(flexSign, orderedChildren, remainingFreeSpace, tot alFlexGrow, totalFlexShrink, totalWeightedFlexShrink); 909 freezeInflexibleItems(flexSign, orderedChildren, remainingFreeSpace, tot alFlexGrow, totalFlexShrink, totalWeightedFlexShrink);
905 // The initial free space gets calculated after freezing inflexible item s. https://drafts.csswg.org/css-flexbox/#resolve-flexible-lengths step 3 910 // The initial free space gets calculated after freezing inflexible item s. https://drafts.csswg.org/css-flexbox/#resolve-flexible-lengths step 3
906 const LayoutUnit initialFreeSpace = remainingFreeSpace; 911 const LayoutUnit initialFreeSpace = remainingFreeSpace;
907 while (!resolveFlexibleLengths(flexSign, orderedChildren, initialFreeSpa ce, remainingFreeSpace, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink) ) { 912 while (!resolveFlexibleLengths(flexSign, orderedChildren, initialFreeSpa ce, remainingFreeSpace, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink) ) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 1218
1214 LayoutFlexibleBox::FlexItem LayoutFlexibleBox::constructFlexItem(LayoutBox& chil d, ChildLayoutType layoutType) 1219 LayoutFlexibleBox::FlexItem LayoutFlexibleBox::constructFlexItem(LayoutBox& chil d, ChildLayoutType layoutType)
1215 { 1220 {
1216 LayoutUnit borderAndPadding = isHorizontalFlow() ? child.borderAndPaddingWid th() : child.borderAndPaddingHeight(); 1221 LayoutUnit borderAndPadding = isHorizontalFlow() ? child.borderAndPaddingWid th() : child.borderAndPaddingHeight();
1217 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child, borderAndPadding, layoutType); 1222 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child, borderAndPadding, layoutType);
1218 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(ch ild, childInnerFlexBaseSize); 1223 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(ch ild, childInnerFlexBaseSize);
1219 LayoutUnit margin = isHorizontalFlow() ? child.marginWidth() : child.marginH eight(); 1224 LayoutUnit margin = isHorizontalFlow() ? child.marginWidth() : child.marginH eight();
1220 return FlexItem(&child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisEx tent, borderAndPadding, margin); 1225 return FlexItem(&child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisEx tent, borderAndPadding, margin);
1221 } 1226 }
1222 1227
1223 bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren , LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalFlexShrink, d ouble& totalWeightedFlexShrink, LayoutUnit& sumHypotheticalMainSize, bool relayo utChildren) 1228 bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren , LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalFlexShrink, d ouble& totalWeightedFlexShrink, LayoutUnit& sumHypotheticalMainSize, bool relayo utChildren, LayoutObject* childToExclude)
1224 { 1229 {
1225 orderedChildren.clear(); 1230 orderedChildren.clear();
1226 sumFlexBaseSize = LayoutUnit(); 1231 sumFlexBaseSize = LayoutUnit();
1227 totalFlexGrow = totalFlexShrink = totalWeightedFlexShrink = 0; 1232 totalFlexGrow = totalFlexShrink = totalWeightedFlexShrink = 0;
1228 sumHypotheticalMainSize = LayoutUnit(); 1233 sumHypotheticalMainSize = LayoutUnit();
1229 1234
1230 if (!m_orderIterator.currentChild()) 1235 if (!m_orderIterator.currentChild())
1231 return false; 1236 return false;
1232 1237
1233 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max()); 1238 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max());
1234 1239
1235 bool lineHasInFlowItem = false; 1240 bool lineHasInFlowItem = false;
1236 1241
1237 for (LayoutBox* child = m_orderIterator.currentChild(); child; child = m_ord erIterator.next()) { 1242 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
1238 if (child->isOutOfFlowPositioned()) { 1247 if (child->isOutOfFlowPositioned()) {
1239 orderedChildren.append(FlexItem(child)); 1248 orderedChildren.append(FlexItem(child));
1240 continue; 1249 continue;
1241 } 1250 }
1242 1251
1243 ChildLayoutType layoutType = relayoutChildren ? ForceLayout : LayoutIfNe eded; 1252 ChildLayoutType layoutType = relayoutChildren ? ForceLayout : LayoutIfNe eded;
1244 1253
1245 // If this condition is true, then computeMainAxisExtentForChild will ca ll child.intrinsicContentLogicalHeight() 1254 // If this condition is true, then computeMainAxisExtentForChild will ca ll child.intrinsicContentLogicalHeight()
1246 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min /max/preferred size, 1255 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min /max/preferred size,
1247 // run layout on it now to make sure its logical height and scroll bars are up to date. 1256 // 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
1919 ASSERT(child); 1928 ASSERT(child);
1920 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1929 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1921 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1930 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1922 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1931 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1923 adjustAlignmentForChild(*child, newOffset - originalOffset); 1932 adjustAlignmentForChild(*child, newOffset - originalOffset);
1924 } 1933 }
1925 } 1934 }
1926 } 1935 }
1927 1936
1928 } // namespace blink 1937 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698