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

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: different approach 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutFlexibleBox.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7bdedffe98a2f22b971ebb69df9b6880274b714c..bed1c2fd7b7bfb052fa6b25d5efbcc697265273c 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(SizeDefiniteness::Unknown)
{
ASSERT(!childrenInline());
}
@@ -380,6 +381,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 = SizeDefiniteness::Unknown;
}
void LayoutFlexibleBox::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) const
@@ -769,9 +774,13 @@ 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 == SizeDefiniteness::Definite)
+ return true;
+ if (m_hasDefiniteHeight == SizeDefiniteness::Indefinite)
+ return false;
+ bool definite = child.computePercentageLogicalHeight(flexBasis) != -1;
+ m_hasDefiniteHeight = definite ? SizeDefiniteness::Definite : SizeDefiniteness::Indefinite;
+ return definite;
}
return true;
}
@@ -781,9 +790,13 @@ 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 == SizeDefiniteness::Definite)
+ return true;
+ if (m_hasDefiniteHeight == SizeDefiniteness::Indefinite)
+ return false;
+ bool definite = child.computePercentageLogicalHeight(length) != -1;
+ m_hasDefiniteHeight = definite ? SizeDefiniteness::Definite : SizeDefiniteness::Indefinite;
+ return definite;
}
// TODO(cbiesinger): Eventually we should support other types of sizes here. Requires updating
// computeMainSizeFromAspectRatioUsing.
@@ -1147,7 +1160,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);
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutFlexibleBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698