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

Unified Diff: Source/core/layout/LayoutBlock.cpp

Issue 1121173002: Fix shrink-to-fit when children's writing-mode is orthogonal (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: float tests added + cleanup a bit Created 5 years, 7 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: Source/core/layout/LayoutBlock.cpp
diff --git a/Source/core/layout/LayoutBlock.cpp b/Source/core/layout/LayoutBlock.cpp
index f9b493b9844ca95fb63757a302ec7634069e2145..7f11f8bf907c283542259916abd9a8c94bbe7c5a 100644
--- a/Source/core/layout/LayoutBlock.cpp
+++ b/Source/core/layout/LayoutBlock.cpp
@@ -154,6 +154,7 @@ LayoutBlock::LayoutBlock(ContainerNode* node)
, m_widthAvailableToChildrenChanged(false)
, m_hasOnlySelfCollapsingChildren(false)
, m_descendantsWithFloatsMarkedForLayout(false)
+ , m_needsRecalcLogicalWidthAfterLayoutChildren(false)
{
// LayoutBlockFlow calls setChildrenInline(true).
// By default, subclasses do not have inline children.
@@ -3063,12 +3064,7 @@ void LayoutBlock::computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth
margin = marginStart + marginEnd;
LayoutUnit childMinPreferredLogicalWidth, childMaxPreferredLogicalWidth;
- if (child->isBox() && child->isHorizontalWritingMode() != isHorizontalWritingMode()) {
- childMinPreferredLogicalWidth = childMaxPreferredLogicalWidth = toLayoutBox(child)->computeLogicalHeightWithoutLayout();
- } else {
- childMinPreferredLogicalWidth = child->minPreferredLogicalWidth();
- childMaxPreferredLogicalWidth = child->maxPreferredLogicalWidth();
- }
+ minMaxPreferredLogicalWidthOfChild(*child, childMinPreferredLogicalWidth, childMaxPreferredLogicalWidth);
LayoutUnit w = childMinPreferredLogicalWidth + margin;
minLogicalWidth = std::max(w, minLogicalWidth);
@@ -3116,6 +3112,30 @@ void LayoutBlock::computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth
maxLogicalWidth = std::max(floatLeftWidth + floatRightWidth, maxLogicalWidth);
}
+void LayoutBlock::minMaxPreferredLogicalWidthOfChild(LayoutObject& child, LayoutUnit& minPreferredLogicalWidth, LayoutUnit& maxPreferredLogicalWidth) const
+{
+ ASSERT(child.parent() == this);
+
+ if (!(child.isBox() && toLayoutBox(child).isWritingModeOrthogonalToParent())) {
+ minPreferredLogicalWidth = child.minPreferredLogicalWidth();
+ maxPreferredLogicalWidth = child.maxPreferredLogicalWidth();
+ return;
+ }
+
+#ifdef CRBUG410320_APPROACH_1
+ child.layoutIfNeeded();
+#else
+ // If the child is an orthogonal flow, child's height determines the width, but the height is not available until layout.
+ // http://dev.w3.org/csswg/css-writing-modes-3/#orthogonal-shrink-to-fit
+ if (child.needsLayout()) {
+ minPreferredLogicalWidth = maxPreferredLogicalWidth = toLayoutBox(child).computeLogicalHeightWithoutLayout();
+ m_needsRecalcLogicalWidthAfterLayoutChildren = true;
+ return;
+ }
+#endif
+ minPreferredLogicalWidth = maxPreferredLogicalWidth = toLayoutBox(child).logicalHeight();
+}
+
bool LayoutBlock::hasLineIfEmpty() const
{
if (!node())

Powered by Google App Engine
This is Rietveld 408576698