Changeset 288280 in webkit


Ignore:
Timestamp:
Jan 20, 2022 5:35:50 AM (2 years ago)
Author:
Adrian Perez de Castro
Message:

Merge r286866 - nullptr deref in ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::updateOffsetIfNeeded
https://bugs.webkit.org/show_bug.cgi?id=234018

Patch by Gabriel Nava Marino <gnavamarino@apple.com> on 2021-12-10
Reviewed by Alan Bujtas.

Source/WebCore:

Test: fast/rendering/floating-object-renderer-crash.html

When destroying a given renderer, we first remove floats and out-of-flow positioned objects
from their containing block before detaching the renderer from the tree. We do this by obtaining
the renderer’s outermost block containing a floating object and recursively marking all siblings
and descendants for layout.

The criteria for continuing down the list of children require the current block to contain floats
or be able to shrink to avoid floats. However, we can have a scenario where the current child block
doesn’t have a float, but one of its descendants does. In this case, although we should continue to
that descendant and remove the float, we do not.

The proposal in this patch will instead check whether the child block contains a float, or any of its descendants do.
If so we should continue traversing towards that descendant.

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::subtreeContainsFloat const):
(WebCore::RenderBlockFlow::subtreeContainsFloats const):
(WebCore::RenderBlockFlow::markAllDescendantsWithFloatsForLayout):

  • rendering/RenderBlockFlow.h:

LayoutTests:

  • fast/rendering/floating-object-renderer-crash-expected.txt: Added.
  • fast/rendering/floating-object-renderer-crash.html: Added.
Location:
releases/WebKitGTK/webkit-2.34
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.34/LayoutTests/ChangeLog

    r288279 r288280  
     12021-12-10  Gabriel Nava Marino  <gnavamarino@apple.com>
     2
     3        nullptr deref in ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::updateOffsetIfNeeded
     4        https://bugs.webkit.org/show_bug.cgi?id=234018
     5
     6        Reviewed by Alan Bujtas.
     7
     8        * fast/rendering/floating-object-renderer-crash-expected.txt: Added.
     9        * fast/rendering/floating-object-renderer-crash.html: Added.
     10
    1112021-12-09  Cathie Chen  <cathiechen@igalia.com>
    212
  • releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog

    r288279 r288280  
     12021-12-10  Gabriel Nava Marino  <gnavamarino@apple.com>
     2
     3        nullptr deref in ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::updateOffsetIfNeeded
     4        https://bugs.webkit.org/show_bug.cgi?id=234018
     5
     6        Reviewed by Alan Bujtas.
     7
     8        Test: fast/rendering/floating-object-renderer-crash.html
     9
     10        When destroying a given renderer, we first remove floats and out-of-flow positioned objects
     11        from their containing block before detaching the renderer from the tree. We do this by obtaining
     12        the renderer’s outermost block containing a floating object and recursively marking all siblings
     13        and descendants for layout.
     14
     15        The criteria for continuing down the list of children require the current block to contain floats
     16        or be able to shrink to avoid floats. However, we can have a scenario where the current child block
     17        doesn’t have a float, but one of its descendants does. In this case, although we should continue to
     18        that descendant and remove the float, we do not.
     19
     20        The proposal in this patch will instead check whether the child block contains a float, or any of its descendants do.
     21        If so we should continue traversing towards that descendant.
     22
     23        * rendering/RenderBlockFlow.cpp:
     24        (WebCore::RenderBlockFlow::subtreeContainsFloat const):
     25        (WebCore::RenderBlockFlow::subtreeContainsFloats const):
     26        (WebCore::RenderBlockFlow::markAllDescendantsWithFloatsForLayout):
     27        * rendering/RenderBlockFlow.h:
     28
    1292021-12-09  Cathie Chen  <cathiechen@igalia.com>
    230
  • releases/WebKitGTK/webkit-2.34/Source/WebCore/rendering/RenderBlockFlow.cpp

    r281357 r288280  
    21002100}
    21012101
     2102bool RenderBlockFlow::subtreeContainsFloat(RenderBox& renderer) const
     2103{
     2104    bool contains = m_floatingObjects && m_floatingObjects->set().contains<FloatingObjectHashTranslator>(renderer);
     2105    for (auto& block : childrenOfType<RenderBlock>(*this)) {
     2106        if (!is<RenderBlockFlow>(block))
     2107            continue;
     2108        auto& blockFlow = downcast<RenderBlockFlow>(block);
     2109        contains |= blockFlow.subtreeContainsFloat(renderer);
     2110    }
     2111    return contains;
     2112}
     2113
     2114bool RenderBlockFlow::subtreeContainsFloats() const
     2115{
     2116    bool contains = m_floatingObjects && !m_floatingObjects->set().isEmpty();
     2117    for (auto& block : childrenOfType<RenderBlock>(*this)) {
     2118        if (!is<RenderBlockFlow>(block))
     2119            continue;
     2120        auto& blockFlow = downcast<RenderBlockFlow>(block);
     2121        contains |= blockFlow.subtreeContainsFloats();
     2122    }
     2123    return contains;
     2124}
     2125
    21022126void RenderBlockFlow::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
    21032127{
     
    28692893        }
    28702894        auto& blockFlow = downcast<RenderBlockFlow>(block);
    2871         if ((floatToRemove ? blockFlow.containsFloat(*floatToRemove) : blockFlow.containsFloats()) || blockFlow.shrinkToAvoidFloats())
     2895        if ((floatToRemove ? blockFlow.subtreeContainsFloat(*floatToRemove) : blockFlow.subtreeContainsFloats()) || blockFlow.shrinkToAvoidFloats())
    28722896            blockFlow.markAllDescendantsWithFloatsForLayout(floatToRemove, inLayout);
    28732897    }
  • releases/WebKitGTK/webkit-2.34/Source/WebCore/rendering/RenderBlockFlow.h

    r279918 r288280  
    279279    bool containsFloats() const override { return m_floatingObjects && !m_floatingObjects->set().isEmpty(); }
    280280    bool containsFloat(RenderBox&) const;
     281    bool subtreeContainsFloats() const;
     282    bool subtreeContainsFloat(RenderBox&) const;
    281283
    282284    void deleteLines() override;
Note: See TracChangeset for help on using the changeset viewer.