Skip to content

Commit

Permalink
Cherry-pick 260286.14@webkit-2023.2-embargoed (0888aab). https://bugs…
Browse files Browse the repository at this point in the history
….webkit.org/show_bug.cgi?id=245374

    Improve isInsideMulticolumnFlow lambda for top-layer elements
    https://bugs.webkit.org/show_bug.cgi?id=245374

    Reviewed by Alan Baradlay.

    Improve isInsideMulticolumnFlow lambda for top-layer elements.
    Top-layer elements can skip many ancestors since the containing
    block is the RenderView. So instead of checking the fragmentedFlowRoot
    boundary, check the containing block fragmented flow state.

    * Source/WebCore/rendering/RenderObject.cpp:
    (WebCore::RenderObject::setFragmentedFlowStateIncludingDescendants):
    (WebCore::RenderObject::initializeFragmentedFlowStateOnInsertion):
    (WebCore::RenderObject::resetFragmentedFlowStateOnRemoval):
    * Source/WebCore/rendering/RenderObject.h:

    Canonical link: https://commits.webkit.org/260286.14@webkit-2023.2-embargoed

Canonical link: https://commits.webkit.org/263022.6@webkit-2023.4-embargoed
  • Loading branch information
rwlbuis authored and JonWBedard committed Apr 17, 2023
1 parent dc79809 commit 8efd98e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions Source/WebCore/rendering/RenderObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ bool RenderObject::isBlockContainer() const
|| display == DisplayType::TableCaption) && !isRenderReplaced();
}

void RenderObject::setFragmentedFlowStateIncludingDescendants(FragmentedFlowState state, const RenderElement* fragmentedFlowRoot, SkipDescendentFragmentedFlow skipDescendentFragmentedFlow)
void RenderObject::setFragmentedFlowStateIncludingDescendants(FragmentedFlowState state, SkipDescendentFragmentedFlow skipDescendentFragmentedFlow)
{
setFragmentedFlowState(state);

Expand All @@ -234,22 +234,21 @@ void RenderObject::setFragmentedFlowStateIncludingDescendants(FragmentedFlowStat
// If the child is a fragmentation context it already updated the descendants flag accordingly.
if (child.isRenderFragmentedFlow() && skipDescendentFragmentedFlow == SkipDescendentFragmentedFlow::Yes)
continue;
if (fragmentedFlowRoot && child.isOutOfFlowPositioned()) {
if (child.isOutOfFlowPositioned()) {
// Fragmented status propagation stops at out-of-flow boundary.
auto isInsideMulticolumnFlow = [&] {
auto* containingBlock = child.containingBlock();
if (!containingBlock) {
ASSERT_NOT_REACHED();
return false;
}
// It's ok to only check the first level containing block (as opposed to the containing block chain) as setFragmentedFlowStateIncludingDescendants is top to down.
return containingBlock->isDescendantOf(fragmentedFlowRoot);
return containingBlock->fragmentedFlowState() == InsideInFragmentedFlow;
};
if (!isInsideMulticolumnFlow())
continue;
}
ASSERT(skipDescendentFragmentedFlow == SkipDescendentFragmentedFlow::No || state != child.fragmentedFlowState());
child.setFragmentedFlowStateIncludingDescendants(state, fragmentedFlowRoot, skipDescendentFragmentedFlow);
child.setFragmentedFlowStateIncludingDescendants(state, skipDescendentFragmentedFlow);
}
}

Expand Down Expand Up @@ -291,8 +290,7 @@ void RenderObject::initializeFragmentedFlowStateOnInsertion()
if (fragmentedFlowState() == computedState)
return;

auto* enclosingFragmentedFlow = locateEnclosingFragmentedFlow();
setFragmentedFlowStateIncludingDescendants(computedState, enclosingFragmentedFlow ? enclosingFragmentedFlow->parent() : nullptr, SkipDescendentFragmentedFlow::No);
setFragmentedFlowStateIncludingDescendants(computedState, SkipDescendentFragmentedFlow::No);
}

void RenderObject::resetFragmentedFlowStateOnRemoval()
Expand All @@ -309,8 +307,7 @@ void RenderObject::resetFragmentedFlowStateOnRemoval()
if (isRenderFragmentedFlow())
return;

auto* enclosingFragmentedFlow = this->enclosingFragmentedFlow();
setFragmentedFlowStateIncludingDescendants(NotInsideFragmentedFlow, enclosingFragmentedFlow ? enclosingFragmentedFlow->parent() : nullptr);
setFragmentedFlowStateIncludingDescendants(NotInsideFragmentedFlow);
}

void RenderObject::setParent(RenderElement* parent)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class RenderObject : public CachedImageClient {
};

enum class SkipDescendentFragmentedFlow { No, Yes };
void setFragmentedFlowStateIncludingDescendants(FragmentedFlowState, const RenderElement* fragmentedFlowRoot, SkipDescendentFragmentedFlow = SkipDescendentFragmentedFlow::Yes);
void setFragmentedFlowStateIncludingDescendants(FragmentedFlowState, SkipDescendentFragmentedFlow = SkipDescendentFragmentedFlow::Yes);

FragmentedFlowState fragmentedFlowState() const { return m_bitfields.fragmentedFlowState(); }
void setFragmentedFlowState(FragmentedFlowState state) { m_bitfields.setFragmentedFlowState(state); }
Expand Down

0 comments on commit 8efd98e

Please sign in to comment.