From 0a3506ebe5d7f431f0dd4dffa24ac32063b90ff1 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Thu, 1 Jun 2017 15:54:01 +0300 Subject: Import WebKit commit 3ca7a25a550e473d60bbbe321475c6c0ef114b31 Change-Id: I480668a0cb8114dccf7a1195190a993282875759 Reviewed-by: Allan Sandfeld Jensen --- .../rendering/RenderMultiColumnFlowThread.cpp | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp') diff --git a/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp b/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp index b212f632d..06ff8cd3c 100644 --- a/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp +++ b/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp @@ -270,10 +270,34 @@ static bool isValidColumnSpanner(RenderMultiColumnFlowThread* flowThread, Render return false; } +static RenderObject* spannerPlacehoderCandidate(const RenderObject& renderer, const RenderMultiColumnFlowThread& stayWithin) +{ + // Spanner candidate is a next sibling/ancestor's next child within the flow thread and + // it is in the same inflow/out-of-flow layout context. + if (renderer.isOutOfFlowPositioned()) + return nullptr; + + ASSERT(renderer.isDescendantOf(&stayWithin)); + auto* current = &renderer; + while (true) { + // Skip to the first in-flow sibling. + auto* nextSibling = current->nextSibling(); + while (nextSibling && nextSibling->isOutOfFlowPositioned()) + nextSibling = nextSibling->nextSibling(); + if (nextSibling) + return nextSibling; + // No sibling candidate, jump to the parent and check its siblings. + current = current->parent(); + if (!current || current == &stayWithin || current->isOutOfFlowPositioned()) + return nullptr; + } + return nullptr; +} + RenderObject* RenderMultiColumnFlowThread::processPossibleSpannerDescendant(RenderObject*& subtreeRoot, RenderObject* descendant) { RenderBlockFlow* multicolContainer = multiColumnBlockFlow(); - RenderObject* nextRendererInFlowThread = descendant->nextInPreOrderAfterChildren(this); + RenderObject* nextRendererInFlowThread = spannerPlacehoderCandidate(*descendant, *this); RenderObject* insertBeforeMulticolChild = nullptr; RenderObject* nextDescendant = descendant; -- cgit v1.2.1