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

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

Issue 2250713002: Handle auto-positioned out-of-flow objects inside multicol containers correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code review 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/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index ed8fbdf554cf772335cb0ce3606ee482438e9846..91e7767fc81822e8d6184d17d4a58363cc0622eb 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -3206,11 +3206,30 @@ LayoutUnit LayoutBox::containingBlockLogicalHeightForPositioned(const LayoutBoxM
return heightResult;
}
+static LayoutUnit accumulateStaticOffsetForFlowThread(LayoutBox& layoutBox, LayoutUnit inlinePosition, LayoutUnit& blockPosition)
+{
+ if (layoutBox.isTableRow())
+ return LayoutUnit();
+ blockPosition += layoutBox.logicalTop();
+ if (!layoutBox.isLayoutFlowThread())
+ return LayoutUnit();
+ LayoutUnit previousInlinePosition = inlinePosition;
+ // We're walking out of a flowthread here. This flow thread is not in the containing block
+ // chain, so we need to convert the position from the coordinate space of this flowthread to
+ // the containing coordinate space.
+ toLayoutFlowThread(layoutBox).flowThreadToContainingCoordinateSpace(blockPosition, inlinePosition);
+ return inlinePosition - previousInlinePosition;
+}
+
void LayoutBox::computeInlineStaticDistance(Length& logicalLeft, Length& logicalRight, const LayoutBox* child, const LayoutBoxModelObject* containerBlock, LayoutUnit containerLogicalWidth)
{
if (!logicalLeft.isAuto() || !logicalRight.isAuto())
return;
+ // For multicol we also need to keep track of the block position, since that determines which
+ // column we're in and thus affects the inline position.
+ LayoutUnit staticBlockPosition = child->layer()->staticBlockPosition();
+
// FIXME: The static distance computation has not been patched for mixed writing modes yet.
if (child->parent()->style()->direction() == LTR) {
LayoutUnit staticPosition = child->layer()->staticInlinePosition() - containerBlock->borderLogicalLeft();
@@ -3219,6 +3238,8 @@ void LayoutBox::computeInlineStaticDistance(Length& logicalLeft, Length& logical
staticPosition += toLayoutBox(curr)->logicalLeft();
if (toLayoutBox(curr)->isInFlowPositioned())
staticPosition += toLayoutBox(curr)->offsetForInFlowPosition().width();
+ if (curr->isInsideFlowThread())
+ staticPosition += accumulateStaticOffsetForFlowThread(*toLayoutBox(curr), staticPosition, staticBlockPosition);
} else if (curr->isInline()) {
if (curr->isInFlowPositioned()) {
if (!curr->style()->logicalLeft().isAuto())
@@ -3234,13 +3255,15 @@ void LayoutBox::computeInlineStaticDistance(Length& logicalLeft, Length& logical
LayoutUnit staticPosition = child->layer()->staticInlinePosition() + containerLogicalWidth + containerBlock->borderLogicalLeft();
for (LayoutObject* curr = child->parent(); curr; curr = curr->container()) {
if (curr->isBox()) {
+ if (curr == enclosingBox)
+ staticPosition -= enclosingBox->logicalWidth();
if (curr != containerBlock) {
staticPosition -= toLayoutBox(curr)->logicalLeft();
if (toLayoutBox(curr)->isInFlowPositioned())
staticPosition -= toLayoutBox(curr)->offsetForInFlowPosition().width();
+ if (curr->isInsideFlowThread())
+ staticPosition -= accumulateStaticOffsetForFlowThread(*toLayoutBox(curr), staticPosition, staticBlockPosition);
}
- if (curr == enclosingBox)
- staticPosition -= enclosingBox->logicalWidth();
} else if (curr->isInline()) {
if (curr->isInFlowPositioned()) {
if (!curr->style()->logicalLeft().isAuto())
@@ -3574,12 +3597,22 @@ void LayoutBox::computeBlockStaticDistance(Length& logicalTop, Length& logicalBo
return;
// FIXME: The static distance computation has not been patched for mixed writing modes.
- LayoutUnit staticLogicalTop = child->layer()->staticBlockPosition() - containerBlock->borderBefore();
+ LayoutUnit staticLogicalTop = child->layer()->staticBlockPosition();
for (LayoutObject* curr = child->parent(); curr && curr != containerBlock; curr = curr->container()) {
- if (curr->isBox() && !curr->isTableRow())
- staticLogicalTop += toLayoutBox(curr)->logicalTop();
- }
- logicalTop.setValue(Fixed, staticLogicalTop);
+ if (!curr->isBox() || curr->isTableRow())
+ continue;
+ const LayoutBox& box = *toLayoutBox(curr);
+ staticLogicalTop += box.logicalTop();
+ if (!box.isLayoutFlowThread())
+ continue;
+ // We're walking out of a flowthread here. This flow thread is not in the containing block
+ // chain, so we need to convert the position from the coordinate space of this flowthread
+ // to the containing coordinate space. The inline position cannot affect the block
+ // position, so we don't bother calculating it.
+ LayoutUnit dummyInlinePosition;
+ toLayoutFlowThread(box).flowThreadToContainingCoordinateSpace(staticLogicalTop, dummyInlinePosition);
+ }
+ logicalTop.setValue(Fixed, staticLogicalTop - containerBlock->borderBefore());
}
void LayoutBox::computePositionedLogicalHeight(LogicalExtentComputedValues& computedValues) const

Powered by Google App Engine
This is Rietveld 408576698