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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp

Issue 2215133005: Add grid/flex layout support for <fieldset> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed more ClusterFuzz tests 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp b/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
index faf7545ad346fd2180591bd09eddc5ecbabab77e..ea3d2788d6fd9f85e75d79729ca6f2f5865f2d34 100644
--- a/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
@@ -410,12 +410,12 @@ void LayoutFlexibleBox::paintChildren(const PaintInfo& paintInfo, const LayoutPo
BlockPainter::paintChildrenOfFlexibleBox(*this, paintInfo, paintOffset);
}
-void LayoutFlexibleBox::repositionLogicalHeightDependentFlexItems(Vector<LineContext>& lineContexts)
+void LayoutFlexibleBox::repositionLogicalHeightDependentFlexItems(Vector<LineContext>& lineContexts, LayoutObject* childToExclude)
{
LayoutUnit crossAxisStartEdge = lineContexts.isEmpty() ? LayoutUnit() : lineContexts[0].crossAxisOffset;
alignFlexLines(lineContexts);
- alignChildren(lineContexts);
+ alignChildren(lineContexts, childToExclude);
if (style()->flexWrap() == FlexWrapReverse)
flipForWrapReverse(lineContexts, crossAxisStartEdge);
@@ -900,9 +900,14 @@ void LayoutFlexibleBox::layoutFlexItems(bool relayoutChildren, SubtreeLayoutScop
PaintLayerScrollableArea::PreventRelayoutScope preventRelayoutScope(layoutScope);
+ // Fieldsets need to find their legend and position it inside the border of the object.
+ // The legend then gets skipped during normal layout.
+ // It doesn't get included in the normal layout process but is instead skipped.
+ LayoutObject* childToExclude = layoutSpecialExcludedChild(relayoutChildren, layoutScope);
+
m_orderIterator.first();
LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefore();
- while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink, sumHypotheticalMainSize, relayoutChildren)) {
+ while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow, totalFlexShrink, totalWeightedFlexShrink, sumHypotheticalMainSize, relayoutChildren, childToExclude)) {
LayoutUnit containerMainInnerSize = mainAxisContentExtent(sumHypotheticalMainSize);
// availableFreeSpace is the initial amount of free space in this flexbox.
// remainingFreeSpace starts out at the same value but as we place and lay out
@@ -940,7 +945,7 @@ void LayoutFlexibleBox::layoutFlexItems(bool relayoutChildren, SubtreeLayoutScop
}
updateLogicalHeight();
- repositionLogicalHeightDependentFlexItems(lineContexts);
+ repositionLogicalHeightDependentFlexItems(lineContexts, childToExclude);
}
LayoutUnit LayoutFlexibleBox::autoMarginOffsetInMainAxis(const OrderedFlexItemList& children, LayoutUnit& availableFreeSpace)
@@ -1229,7 +1234,7 @@ LayoutFlexibleBox::FlexItem LayoutFlexibleBox::constructFlexItem(LayoutBox& chil
return FlexItem(&child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisExtent, borderAndPadding, margin);
}
-bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren, LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalFlexShrink, double& totalWeightedFlexShrink, LayoutUnit& sumHypotheticalMainSize, bool relayoutChildren)
+bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren, LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalFlexShrink, double& totalWeightedFlexShrink, LayoutUnit& sumHypotheticalMainSize, bool relayoutChildren, LayoutObject* childToExclude)
{
orderedChildren.clear();
sumFlexBaseSize = LayoutUnit();
@@ -1244,6 +1249,10 @@ bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren
bool lineHasInFlowItem = false;
for (LayoutBox* child = m_orderIterator.currentChild(); child; child = m_orderIterator.next()) {
+
+ if (childToExclude == child)
+ continue; // Skip this child, since it will be positioned by the specialized subclass (fieldsets runs).
+
if (child->isOutOfFlowPositioned()) {
orderedChildren.append(FlexItem(child));
continue;
@@ -1815,7 +1824,7 @@ void LayoutFlexibleBox::adjustAlignmentForChild(LayoutBox& child, LayoutUnit del
setFlowAwareLocationForChild(child, flowAwareLocationForChild(child) + LayoutSize(LayoutUnit(), delta));
}
-void LayoutFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts)
+void LayoutFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts, LayoutObject* childToExclude)
{
// Keep track of the space between the baseline edge and the after edge of the box for each line.
Vector<LayoutUnit> minMarginAfterBaselines;
@@ -1828,6 +1837,8 @@ void LayoutFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts)
for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numberOfChildren; ++childNumber, child = m_orderIterator.next()) {
DCHECK(child);
+ if (child == childToExclude)
+ continue;
if (child->isOutOfFlowPositioned()) {
if (style()->flexWrap() == FlexWrapReverse)
adjustAlignmentForChild(*child, lineCrossAxisExtent);
« 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