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

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

Issue 1670643002: [css-flexbox] Fix main size calculation for overflow:auto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 443676981528769f7a65d043f1841741f05f85a6..ed11a5f59456429003e40b71959ad004281aa62b 100644
--- a/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
@@ -707,6 +707,21 @@ bool LayoutFlexibleBox::childFlexBaseSizeRequiresLayout(const LayoutBox& child)
hasOrthogonalFlow(child) || crossAxisOverflowForChild(child) == OAUTO);
}
+void LayoutFlexibleBox::cacheChildMainSize(const LayoutBox& child)
+{
+ ASSERT(!child.needsLayout());
+ LayoutUnit mainSize;
+ if (hasOrthogonalFlow(child)) {
+ mainSize = child.logicalHeight();
+ } else {
+ // The max preferred logical width includes the intrinsic scrollbar logical width, which is only set for
+ // overflow: scroll. To handle overflow: auto, we have to take scrollbarLogicalWidth() into account, and then
+ // subtract the intrinsic width again so as to not double-count overflow: scroll scrollbars.
+ mainSize = child.maxPreferredLogicalWidth() + child.scrollbarLogicalWidth() - child.intrinsicScrollbarLogicalWidth();
+ }
+ m_intrinsicSizeAlongMainAxis.set(&child, mainSize);
+}
+
LayoutUnit LayoutFlexibleBox::computeInnerFlexBaseSizeForChild(LayoutBox& child, ChildLayoutType childLayoutType)
{
child.clearOverrideSize();
@@ -725,7 +740,7 @@ LayoutUnit LayoutFlexibleBox::computeInnerFlexBaseSizeForChild(LayoutBox& child,
if (child.needsLayout() || childLayoutType == ForceLayout || !m_intrinsicSizeAlongMainAxis.contains(&child)) {
child.forceChildLayout();
- m_intrinsicSizeAlongMainAxis.set(&child, hasOrthogonalFlow(child) ? child.logicalHeight() : child.logicalWidth());
+ cacheChildMainSize(child);
}
mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child);
} else {
@@ -1040,8 +1055,7 @@ bool LayoutFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren
if (childHasIntrinsicMainAxisSize(*child) && child->needsLayout()) {
child->clearOverrideSize();
child->layoutIfNeeded();
- // Keep our cache up-to-date
- m_intrinsicSizeAlongMainAxis.set(child, hasOrthogonalFlow(*child) ? child->logicalHeight() : child->logicalWidth());
+ cacheChildMainSize(*child);
}
LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(*child, relayoutChildren ? ForceLayout : LayoutIfNeeded);
« 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