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

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

Issue 2056043002: [css-flexbox] Cache whether our main axis size is definite (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 5 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 a6a1db68676a4229937e685667849be1d328e084..055c934452d966e9ee79c2668f68bc884859396f 100644
--- a/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
@@ -90,6 +90,7 @@ LayoutFlexibleBox::LayoutFlexibleBox(Element* element)
: LayoutBlock(element)
, m_orderIterator(this)
, m_numberOfInFlowChildrenOnFirstLine(-1)
+ , m_hasDefiniteHeight(-1)
{
ASSERT(!childrenInline());
}
@@ -337,6 +338,10 @@ void LayoutFlexibleBox::layoutBlock(bool relayoutChildren)
if (!relayoutChildren && simplifiedLayout())
return;
+ LayoutBox* firstChild = firstInFlowChildBox();
+ if (firstChild)
+ m_hasDefiniteHeight = firstChild->computePercentageLogicalHeight(Length(0, Percent)) != LayoutUnit(-1);
+
m_relaidOutChildren.clear();
if (updateLogicalWidthAndColumnWidth())
@@ -380,6 +385,10 @@ void LayoutFlexibleBox::layoutBlock(bool relayoutChildren)
updateAfterLayout();
clearNeedsLayout();
+
+ // We have to reset this, because changes to our ancestors' style
+ // can affect this value.
+ m_hasDefiniteHeight = -1;
}
void LayoutFlexibleBox::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) const
@@ -769,9 +778,11 @@ bool LayoutFlexibleBox::mainAxisLengthIsDefinite(const LayoutBox& child, const L
if (flexBasis.isAuto())
return false;
if (flexBasis.hasPercent()) {
- return isColumnFlow() ?
- child.computePercentageLogicalHeight(flexBasis) != -1 :
- true;
+ if (!isColumnFlow() || m_hasDefiniteHeight == 1)
+ return true;
+ if (m_hasDefiniteHeight == 0)
+ return false;
+ return child.computePercentageLogicalHeight(flexBasis) != -1;
}
return true;
}
@@ -781,9 +792,11 @@ bool LayoutFlexibleBox::crossAxisLengthIsDefinite(const LayoutBox& child, const
if (length.isAuto())
return false;
if (length.hasPercent()) {
- return hasOrthogonalFlow(child) ?
- true :
- child.computePercentageLogicalHeight(length) != -1;
+ if (hasOrthogonalFlow(child) || m_hasDefiniteHeight == 1)
+ return true;
+ if (m_hasDefiniteHeight == 0)
+ return false;
+ return child.computePercentageLogicalHeight(length) != -1;
}
// TODO(cbiesinger): Eventually we should support other types of sizes here. Requires updating
// computeMainSizeFromAspectRatioUsing.
@@ -1149,7 +1162,6 @@ LayoutUnit LayoutFlexibleBox::mainSizeForPercentageResolution(const LayoutBox& c
// If flex basis had a percentage, our size is guaranteed to be definite or the flex item's
// size could not be definite.
// Otherwise, we make up a percentage to check whether we have a definite size.
- // TODO(cbiesinger): cache this somewhere
if (!mainAxisLengthIsDefinite(child, Length(0, Percent)))
return LayoutUnit(-1);
}

Powered by Google App Engine
This is Rietveld 408576698