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

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

Issue 2555413002: Revert commit# 415577 "Add grid/flex layout support for <fieldset>" (Closed)
Patch Set: Created 4 years 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // this value. 436 // this value.
437 m_hasDefiniteHeight = SizeDefiniteness::Unknown; 437 m_hasDefiniteHeight = SizeDefiniteness::Unknown;
438 } 438 }
439 439
440 void LayoutFlexibleBox::paintChildren(const PaintInfo& paintInfo, 440 void LayoutFlexibleBox::paintChildren(const PaintInfo& paintInfo,
441 const LayoutPoint& paintOffset) const { 441 const LayoutPoint& paintOffset) const {
442 BlockPainter::paintChildrenOfFlexibleBox(*this, paintInfo, paintOffset); 442 BlockPainter::paintChildrenOfFlexibleBox(*this, paintInfo, paintOffset);
443 } 443 }
444 444
445 void LayoutFlexibleBox::repositionLogicalHeightDependentFlexItems( 445 void LayoutFlexibleBox::repositionLogicalHeightDependentFlexItems(
446 Vector<LineContext>& lineContexts, 446 Vector<LineContext>& lineContexts) {
447 LayoutObject* childToExclude) {
448 LayoutUnit crossAxisStartEdge = 447 LayoutUnit crossAxisStartEdge =
449 lineContexts.isEmpty() ? LayoutUnit() : lineContexts[0].crossAxisOffset; 448 lineContexts.isEmpty() ? LayoutUnit() : lineContexts[0].crossAxisOffset;
450 alignFlexLines(lineContexts); 449 alignFlexLines(lineContexts);
451 450
452 alignChildren(lineContexts, childToExclude); 451 alignChildren(lineContexts);
453 452
454 if (style()->flexWrap() == FlexWrapReverse) 453 if (style()->flexWrap() == FlexWrapReverse)
455 flipForWrapReverse(lineContexts, crossAxisStartEdge); 454 flipForWrapReverse(lineContexts, crossAxisStartEdge);
456 455
457 // direction:rtl + flex-direction:column means the cross-axis direction is 456 // direction:rtl + flex-direction:column means the cross-axis direction is
458 // flipped. 457 // flipped.
459 flipForRightToLeftColumn(); 458 flipForRightToLeftColumn();
460 } 459 }
461 460
462 DISABLE_CFI_PERF 461 DISABLE_CFI_PERF
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 OrderedFlexItemList orderedChildren; 975 OrderedFlexItemList orderedChildren;
977 LayoutUnit sumFlexBaseSize; 976 LayoutUnit sumFlexBaseSize;
978 double totalFlexGrow; 977 double totalFlexGrow;
979 double totalFlexShrink; 978 double totalFlexShrink;
980 double totalWeightedFlexShrink; 979 double totalWeightedFlexShrink;
981 LayoutUnit sumHypotheticalMainSize; 980 LayoutUnit sumHypotheticalMainSize;
982 981
983 PaintLayerScrollableArea::PreventRelayoutScope preventRelayoutScope( 982 PaintLayerScrollableArea::PreventRelayoutScope preventRelayoutScope(
984 layoutScope); 983 layoutScope);
985 984
986 // Fieldsets need to find their legend and position it inside the border of
987 // the object. The legend then gets skipped during normal layout. It
988 // doesn't get included in the normal layout process but is instead skipped.
989 LayoutObject* childToExclude =
990 layoutSpecialExcludedChild(relayoutChildren, layoutScope);
991 985
992 m_orderIterator.first(); 986 m_orderIterator.first();
993 LayoutUnit crossAxisOffset = 987 LayoutUnit crossAxisOffset =
994 flowAwareBorderBefore() + flowAwarePaddingBefore(); 988 flowAwareBorderBefore() + flowAwarePaddingBefore();
995 while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow, 989 while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow,
996 totalFlexShrink, totalWeightedFlexShrink, 990 totalFlexShrink, totalWeightedFlexShrink,
997 sumHypotheticalMainSize, relayoutChildren, 991 sumHypotheticalMainSize, relayoutChildren)) {
998 childToExclude)) {
999 LayoutUnit containerMainInnerSize = 992 LayoutUnit containerMainInnerSize =
1000 mainAxisContentExtent(sumHypotheticalMainSize); 993 mainAxisContentExtent(sumHypotheticalMainSize);
1001 // availableFreeSpace is the initial amount of free space in this flexbox. 994 // availableFreeSpace is the initial amount of free space in this flexbox.
1002 // remainingFreeSpace starts out at the same value but as we place and lay 995 // remainingFreeSpace starts out at the same value but as we place and lay
1003 // out flex items we subtract from it. Note that both values can be 996 // out flex items we subtract from it. Note that both values can be
1004 // negative. 997 // negative.
1005 LayoutUnit remainingFreeSpace = containerMainInnerSize - sumFlexBaseSize; 998 LayoutUnit remainingFreeSpace = containerMainInnerSize - sumFlexBaseSize;
1006 FlexSign flexSign = (sumHypotheticalMainSize < containerMainInnerSize) 999 FlexSign flexSign = (sumHypotheticalMainSize < containerMainInnerSize)
1007 ? PositiveFlexibility 1000 ? PositiveFlexibility
1008 : NegativeFlexibility; 1001 : NegativeFlexibility;
(...skipping 29 matching lines...) Expand all
1038 // Even if computeNextFlexLine returns true, the flexbox might not have 1031 // Even if computeNextFlexLine returns true, the flexbox might not have
1039 // a line because all our children might be out of flow positioned. 1032 // a line because all our children might be out of flow positioned.
1040 // Instead of just checking if we have a line, make sure the flexbox 1033 // Instead of just checking if we have a line, make sure the flexbox
1041 // has at least a line's worth of height to cover this case. 1034 // has at least a line's worth of height to cover this case.
1042 LayoutUnit minHeight = minimumLogicalHeightForEmptyLine(); 1035 LayoutUnit minHeight = minimumLogicalHeightForEmptyLine();
1043 if (size().height() < minHeight) 1036 if (size().height() < minHeight)
1044 setLogicalHeight(minHeight); 1037 setLogicalHeight(minHeight);
1045 } 1038 }
1046 1039
1047 updateLogicalHeight(); 1040 updateLogicalHeight();
1048 repositionLogicalHeightDependentFlexItems(lineContexts, childToExclude); 1041 repositionLogicalHeightDependentFlexItems(lineContexts);
1049 } 1042 }
1050 1043
1051 LayoutUnit LayoutFlexibleBox::autoMarginOffsetInMainAxis( 1044 LayoutUnit LayoutFlexibleBox::autoMarginOffsetInMainAxis(
1052 const OrderedFlexItemList& children, 1045 const OrderedFlexItemList& children,
1053 LayoutUnit& availableFreeSpace) { 1046 LayoutUnit& availableFreeSpace) {
1054 if (availableFreeSpace <= LayoutUnit()) 1047 if (availableFreeSpace <= LayoutUnit())
1055 return LayoutUnit(); 1048 return LayoutUnit();
1056 1049
1057 int numberOfAutoMargins = 0; 1050 int numberOfAutoMargins = 0;
1058 bool isHorizontal = isHorizontalFlow(); 1051 bool isHorizontal = isHorizontalFlow();
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 childMinMaxAppliedMainAxisExtent, borderAndPadding, margin); 1377 childMinMaxAppliedMainAxisExtent, borderAndPadding, margin);
1385 } 1378 }
1386 1379
1387 bool LayoutFlexibleBox::computeNextFlexLine( 1380 bool LayoutFlexibleBox::computeNextFlexLine(
1388 OrderedFlexItemList& orderedChildren, 1381 OrderedFlexItemList& orderedChildren,
1389 LayoutUnit& sumFlexBaseSize, 1382 LayoutUnit& sumFlexBaseSize,
1390 double& totalFlexGrow, 1383 double& totalFlexGrow,
1391 double& totalFlexShrink, 1384 double& totalFlexShrink,
1392 double& totalWeightedFlexShrink, 1385 double& totalWeightedFlexShrink,
1393 LayoutUnit& sumHypotheticalMainSize, 1386 LayoutUnit& sumHypotheticalMainSize,
1394 bool relayoutChildren, 1387 bool relayoutChildren) {
1395 LayoutObject* childToExclude) {
1396 orderedChildren.clear(); 1388 orderedChildren.clear();
1397 sumFlexBaseSize = LayoutUnit(); 1389 sumFlexBaseSize = LayoutUnit();
1398 totalFlexGrow = totalFlexShrink = totalWeightedFlexShrink = 0; 1390 totalFlexGrow = totalFlexShrink = totalWeightedFlexShrink = 0;
1399 sumHypotheticalMainSize = LayoutUnit(); 1391 sumHypotheticalMainSize = LayoutUnit();
1400 1392
1401 if (!m_orderIterator.currentChild()) 1393 if (!m_orderIterator.currentChild())
1402 return false; 1394 return false;
1403 1395
1404 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max()); 1396 LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max());
1405 1397
1406 bool lineHasInFlowItem = false; 1398 bool lineHasInFlowItem = false;
1407 1399
1408 for (LayoutBox* child = m_orderIterator.currentChild(); child; 1400 for (LayoutBox* child = m_orderIterator.currentChild(); child;
1409 child = m_orderIterator.next()) { 1401 child = m_orderIterator.next()) {
1410 if (childToExclude == child)
1411 continue; // Skip this child, since it will be positioned by the
1412 // specialized subclass (fieldsets runs).
1413 1402
1414 if (child->isOutOfFlowPositioned()) { 1403 if (child->isOutOfFlowPositioned()) {
1415 orderedChildren.append(FlexItem(child)); 1404 orderedChildren.append(FlexItem(child));
1416 continue; 1405 continue;
1417 } 1406 }
1418 1407
1419 ChildLayoutType layoutType = 1408 ChildLayoutType layoutType =
1420 relayoutChildren ? ForceLayout : LayoutIfNeeded; 1409 relayoutChildren ? ForceLayout : LayoutIfNeeded;
1421 1410
1422 // If this condition is true, then computeMainAxisExtentForChild will call 1411 // If this condition is true, then computeMainAxisExtentForChild will call
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 2107
2119 void LayoutFlexibleBox::adjustAlignmentForChild(LayoutBox& child, 2108 void LayoutFlexibleBox::adjustAlignmentForChild(LayoutBox& child,
2120 LayoutUnit delta) { 2109 LayoutUnit delta) {
2121 if (child.isOutOfFlowPositioned()) 2110 if (child.isOutOfFlowPositioned())
2122 return; 2111 return;
2123 2112
2124 setFlowAwareLocationForChild(child, flowAwareLocationForChild(child) + 2113 setFlowAwareLocationForChild(child, flowAwareLocationForChild(child) +
2125 LayoutSize(LayoutUnit(), delta)); 2114 LayoutSize(LayoutUnit(), delta));
2126 } 2115 }
2127 2116
2128 void LayoutFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts, 2117 void LayoutFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts) {
2129 LayoutObject* childToExclude) {
2130 // Keep track of the space between the baseline edge and the after edge of 2118 // Keep track of the space between the baseline edge and the after edge of
2131 // the box for each line. 2119 // the box for each line.
2132 Vector<LayoutUnit> minMarginAfterBaselines; 2120 Vector<LayoutUnit> minMarginAfterBaselines;
2133 2121
2134 LayoutBox* child = m_orderIterator.first(); 2122 LayoutBox* child = m_orderIterator.first();
2135 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) { 2123 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) {
2136 LayoutUnit minMarginAfterBaseline = LayoutUnit::max(); 2124 LayoutUnit minMarginAfterBaseline = LayoutUnit::max();
2137 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisExtent; 2125 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisExtent;
2138 LayoutUnit maxAscent = lineContexts[lineNumber].maxAscent; 2126 LayoutUnit maxAscent = lineContexts[lineNumber].maxAscent;
2139 2127
2140 for (size_t childNumber = 0; 2128 for (size_t childNumber = 0;
2141 childNumber < lineContexts[lineNumber].numberOfChildren; 2129 childNumber < lineContexts[lineNumber].numberOfChildren;
2142 ++childNumber, child = m_orderIterator.next()) { 2130 ++childNumber, child = m_orderIterator.next()) {
2143 DCHECK(child); 2131 DCHECK(child);
2144 if (child == childToExclude)
2145 continue;
2146 if (child->isOutOfFlowPositioned()) { 2132 if (child->isOutOfFlowPositioned()) {
2147 if (style()->flexWrap() == FlexWrapReverse) 2133 if (style()->flexWrap() == FlexWrapReverse)
2148 adjustAlignmentForChild(*child, lineCrossAxisExtent); 2134 adjustAlignmentForChild(*child, lineCrossAxisExtent);
2149 continue; 2135 continue;
2150 } 2136 }
2151 2137
2152 if (updateAutoMarginsInCrossAxis( 2138 if (updateAutoMarginsInCrossAxis(
2153 *child, std::max(LayoutUnit(), availableAlignmentSpaceForChild( 2139 *child, std::max(LayoutUnit(), availableAlignmentSpaceForChild(
2154 lineCrossAxisExtent, *child)))) 2140 lineCrossAxisExtent, *child))))
2155 continue; 2141 continue;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 LayoutUnit originalOffset = 2271 LayoutUnit originalOffset =
2286 lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 2272 lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
2287 LayoutUnit newOffset = 2273 LayoutUnit newOffset =
2288 contentExtent - originalOffset - lineCrossAxisExtent; 2274 contentExtent - originalOffset - lineCrossAxisExtent;
2289 adjustAlignmentForChild(*child, newOffset - originalOffset); 2275 adjustAlignmentForChild(*child, newOffset - originalOffset);
2290 } 2276 }
2291 } 2277 }
2292 } 2278 }
2293 2279
2294 } // namespace blink 2280 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutFlexibleBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698