Changeset 207310 in webkit


Ignore:
Timestamp:
Oct 13, 2016 2:41:01 PM (8 years ago)
Author:
Alan Bujtas
Message:

[Clean RenderTree] LayoutTests/imported/blink/fast/table/crash-bad-child-table-continuation.html fails.
https://bugs.webkit.org/show_bug.cgi?id=163399

Reviewed by David Hyatt.

When we try to insert a renderer before a child whose direct parent is a (anonymus) RenderTable, continuation logic
should dismiss the RenderTable as the parent and find a more appropriate ancestor.
RenderTables assumes a certain descendant tree structure which might not be available in the continuation.

Will be testable with webkit.org/b/162834

  • rendering/RenderInline.cpp:

(WebCore::canUseAsParentForContinuation):
(WebCore::RenderInline::addChildToContinuation):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207305 r207310  
     12016-10-13  Zalan Bujtas  <zalan@apple.com>
     2
     3        [Clean RenderTree] LayoutTests/imported/blink/fast/table/crash-bad-child-table-continuation.html fails.
     4        https://bugs.webkit.org/show_bug.cgi?id=163399
     5
     6        Reviewed by David Hyatt.
     7
     8        When we try to insert a renderer before a child whose direct parent is a (anonymus) RenderTable, continuation logic
     9        should dismiss the RenderTable as the parent and find a more appropriate ancestor.
     10        RenderTables assumes a certain descendant tree structure which might not be available in the continuation.
     11
     12        Will be testable with webkit.org/b/162834
     13
     14        * rendering/RenderInline.cpp:
     15        (WebCore::canUseAsParentForContinuation):
     16        (WebCore::RenderInline::addChildToContinuation):
     17
    1182016-10-13  Alex Christensen  <achristensen@webkit.org>
    219
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r206538 r207310  
    4141#include "RenderListMarker.h"
    4242#include "RenderNamedFlowThread.h"
     43#include "RenderTable.h"
    4344#include "RenderTheme.h"
    4445#include "RenderView.h"
     
    602603}
    603604
     605static bool canUseAsParentForContinuation(const RenderObject* renderer)
     606{
     607    if (!renderer)
     608        return false;
     609    if (!is<RenderBlock>(renderer) && renderer->isAnonymous())
     610        return false;
     611    if (is<RenderTable>(renderer))
     612        return false;
     613    return true;
     614}
     615
    604616void RenderInline::addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild)
    605617{
    606     RenderBoxModelObject* flow = continuationBefore(beforeChild);
     618    auto* flow = continuationBefore(beforeChild);
    607619    // It may or may not be the direct parent of the beforeChild.
    608620    RenderBoxModelObject* beforeChildAncestor = nullptr;
    609     // In case of anonymous wrappers, the parent of the beforeChild is mostly irrelevant. What we need is
    610     // the topmost wrapper.
    611     if (beforeChild && !is<RenderBlock>(beforeChild->parent()) && beforeChild->parent()->isAnonymous()) {
    612         RenderElement* anonymousParent = beforeChild->parent();
    613         while (anonymousParent && anonymousParent->parent() && anonymousParent->parent()->isAnonymous())
    614             anonymousParent = anonymousParent->parent();
    615         ASSERT(anonymousParent && anonymousParent->parent());
    616         beforeChildAncestor = downcast<RenderBoxModelObject>(anonymousParent->parent());
    617     } else {
    618         ASSERT(!beforeChild || is<RenderBlock>(*beforeChild->parent()) || is<RenderInline>(*beforeChild->parent()));
    619         if (beforeChild)
    620             beforeChildAncestor = downcast<RenderBoxModelObject>(beforeChild->parent());
    621         else {
    622             if (RenderBoxModelObject* continuation = nextContinuation(flow))
    623                 beforeChildAncestor = continuation;
    624             else
    625                 beforeChildAncestor = flow;
    626         }
    627     }
     621    // In case of anonymous wrappers, the parent of the beforeChild is mostly irrelevant. What we need is the topmost wrapper.
     622    if (!beforeChild) {
     623        auto* continuation = nextContinuation(flow);
     624        beforeChildAncestor = continuation ? continuation : flow;
     625    } else if (canUseAsParentForContinuation(beforeChild->parent()))
     626        beforeChildAncestor = downcast<RenderBoxModelObject>(beforeChild->parent());
     627    else if (beforeChild->parent()) {
     628        auto* parent = beforeChild->parent();
     629        while (parent && parent->parent() && parent->parent()->isAnonymous())
     630            parent = parent->parent();
     631        ASSERT(parent && parent->parent());
     632        beforeChildAncestor = downcast<RenderBoxModelObject>(parent->parent());
     633    } else
     634        ASSERT_NOT_REACHED();
    628635
    629636    if (newChild->isFloatingOrOutOfFlowPositioned())
Note: See TracChangeset for help on using the changeset viewer.