Changeset 228339 in webkit


Ignore:
Timestamp:
Feb 9, 2018 3:23:02 PM (6 years ago)
Author:
Alan Bujtas
Message:

[RenderTreeBuilder] Move RenderRubyAsInline/AsBlock::takeChild mutation to a RenderTreeBuilder
https://bugs.webkit.org/show_bug.cgi?id=182651
<rdar://problem/37405042>

Reviewed by Antti Koivisto.

No change in functionality.

  • rendering/RenderRuby.cpp:

(WebCore::RenderRubyAsInline::takeChild):
(WebCore::RenderRubyAsBlock::takeChild):
(WebCore::isAnonymousRubyInlineBlock): Deleted.
(WebCore::isRubyChildForNormalRemoval): Deleted.
(WebCore::findRubyRunParent): Deleted.

  • rendering/updating/RenderTreeBuilder.cpp:

(WebCore::RenderTreeBuilder::takeChildFromRenderRubyAsInline):
(WebCore::RenderTreeBuilder::takeChildFromRenderRubyAsBlock):

  • rendering/updating/RenderTreeBuilder.h:
  • rendering/updating/RenderTreeBuilderRuby.cpp:

(WebCore::findRubyRunParent):
(WebCore::RenderTreeBuilder::Ruby::takeChild):

  • rendering/updating/RenderTreeBuilderRuby.h:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r228338 r228339  
     12018-02-09  Zalan Bujtas  <zalan@apple.com>
     2
     3        [RenderTreeBuilder] Move RenderRubyAsInline/AsBlock::takeChild mutation to a RenderTreeBuilder
     4        https://bugs.webkit.org/show_bug.cgi?id=182651
     5        <rdar://problem/37405042>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        No change in functionality.
     10
     11        * rendering/RenderRuby.cpp:
     12        (WebCore::RenderRubyAsInline::takeChild):
     13        (WebCore::RenderRubyAsBlock::takeChild):
     14        (WebCore::isAnonymousRubyInlineBlock): Deleted.
     15        (WebCore::isRubyChildForNormalRemoval): Deleted.
     16        (WebCore::findRubyRunParent): Deleted.
     17        * rendering/updating/RenderTreeBuilder.cpp:
     18        (WebCore::RenderTreeBuilder::takeChildFromRenderRubyAsInline):
     19        (WebCore::RenderTreeBuilder::takeChildFromRenderRubyAsBlock):
     20        * rendering/updating/RenderTreeBuilder.h:
     21        * rendering/updating/RenderTreeBuilderRuby.cpp:
     22        (WebCore::findRubyRunParent):
     23        (WebCore::RenderTreeBuilder::Ruby::takeChild):
     24        * rendering/updating/RenderTreeBuilderRuby.h:
     25
    1262018-02-09  Per Arne Vollan  <pvollan@apple.com>
    227
  • trunk/Source/WebCore/rendering/RenderRuby.cpp

    r228337 r228339  
    4646WTF_MAKE_ISO_ALLOCATED_IMPL(RenderRubyAsBlock);
    4747
    48 //=== generic helper functions to avoid excessive code duplication ===
    49 
    50 static inline bool isAnonymousRubyInlineBlock(const RenderObject* object)
    51 {
    52     ASSERT(!object
    53         || !isRuby(object->parent())
    54         || is<RenderRubyRun>(*object)
    55         || (object->isInline() && (object->isBeforeContent() || object->isAfterContent()))
    56         || (object->isAnonymous() && is<RenderBlock>(*object) && object->style().display() == INLINE_BLOCK));
    57 
    58     return object
    59         && isRuby(object->parent())
    60         && is<RenderBlock>(*object)
    61         && !is<RenderRubyRun>(*object);
    62 }
    63 
    64 #ifndef ASSERT_DISABLED
    65 static inline bool isRubyChildForNormalRemoval(const RenderObject& object)
    66 {
    67     return object.isRubyRun()
    68     || object.isBeforeContent()
    69     || object.isAfterContent()
    70     || object.isRenderMultiColumnFlow()
    71     || object.isRenderMultiColumnSet()
    72     || isAnonymousRubyInlineBlock(&object);
    73 }
    74 #endif
    75 
    76 static inline RenderRubyRun& findRubyRunParent(RenderObject& child)
    77 {
    78     return *lineageOfType<RenderRubyRun>(child).first();
    79 }
    80 
    8148//=== ruby as inline object ===
    8249
     
    9663RenderPtr<RenderObject> RenderRubyAsInline::takeChild(RenderTreeBuilder& builder, RenderObject& child)
    9764{
    98     // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
    99     // just use the normal remove method.
    100     if (child.parent() == this) {
    101 #ifndef ASSERT_DISABLED
    102         ASSERT(isRubyChildForNormalRemoval(child));
    103 #endif
    104         return RenderInline::takeChild(builder, child);
    105     }
    106     // If the child's parent is an anoymous block (must be generated :before/:after content)
    107     // just use the block's remove method.
    108     if (isAnonymousRubyInlineBlock(child.parent())) {
    109         ASSERT(child.isBeforeContent() || child.isAfterContent());
    110         auto& parent = *child.parent();
    111         auto takenChild = parent.takeChild(builder, child);
    112         parent.removeFromParentAndDestroy(builder);
    113         return takenChild;
    114     }
    115 
    116     // Otherwise find the containing run and remove it from there.
    117     return findRubyRunParent(child).takeChild(builder, child);
     65    return builder.takeChildFromRenderRubyAsInline(*this, child);
    11866}
    11967
     
    13583RenderPtr<RenderObject> RenderRubyAsBlock::takeChild(RenderTreeBuilder& builder, RenderObject& child)
    13684{
    137     // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
    138     // just use the normal remove method.
    139     if (child.parent() == this) {
    140 #ifndef ASSERT_DISABLED
    141         ASSERT(isRubyChildForNormalRemoval(child));
    142 #endif
    143         return RenderBlockFlow::takeChild(builder, child);
    144     }
    145     // If the child's parent is an anoymous block (must be generated :before/:after content)
    146     // just use the block's remove method.
    147     if (isAnonymousRubyInlineBlock(child.parent())) {
    148         ASSERT(child.isBeforeContent() || child.isAfterContent());
    149         auto& parent = *child.parent();
    150         auto takenChild = parent.takeChild(builder, child);
    151         parent.removeFromParentAndDestroy(builder);
    152         return takenChild;
    153     }
    154 
    155     // Otherwise find the containing run and remove it from there.
    156     return findRubyRunParent(child).takeChild(builder, child);
     85    return builder.takeChildFromRenderRubyAsBlock(*this, child);
    15786}
    15887
  • trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp

    r228337 r228339  
    471471}
    472472
     473RenderPtr<RenderObject> RenderTreeBuilder::takeChildFromRenderRubyAsInline(RenderRubyAsInline& parent, RenderObject& child)
     474{
     475    return rubyBuilder().takeChild(parent, child);
     476}
     477
     478RenderPtr<RenderObject> RenderTreeBuilder::takeChildFromRenderRubyAsBlock(RenderRubyAsBlock& parent, RenderObject& child)
     479{
     480    return rubyBuilder().takeChild(parent, child);
     481}
     482
    473483void RenderTreeBuilder::updateAfterDescendants(RenderElement& renderer)
    474484{
  • trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h

    r228327 r228339  
    3131
    3232class RenderMathMLFenced;
     33class RenderRubyAsBlock;
     34class RenderRubyAsInline;
    3335class RenderRubyBase;
    3436class RenderRubyRun;
     
    7173    void insertChildToRenderTableRow(RenderTableRow& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr);
    7274    void insertChildToRenderMathMLFenced(RenderMathMLFenced& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr);
     75
     76    RenderPtr<RenderObject> takeChildFromRenderRubyAsInline(RenderRubyAsInline& parent, RenderObject& child);
     77    RenderPtr<RenderObject> takeChildFromRenderRubyAsBlock(RenderRubyAsBlock& parent, RenderObject& child);
    7378
    7479    bool childRequiresTable(const RenderElement& parent, const RenderObject& child);
  • trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp

    r228337 r228339  
    3434namespace WebCore {
    3535
     36static inline RenderRubyRun& findRubyRunParent(RenderObject& child)
     37{
     38    return *lineageOfType<RenderRubyRun>(child).first();
     39}
     40
    3641static inline bool isAnonymousRubyInlineBlock(const RenderObject* object)
    3742{
     
    368373}
    369374
    370 }
     375RenderPtr<RenderObject> RenderTreeBuilder::Ruby::takeChild(RenderRubyAsInline& parent, RenderObject& child)
     376{
     377    // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
     378    // just use the normal remove method.
     379    if (child.parent() == &parent) {
     380#ifndef ASSERT_DISABLED
     381        ASSERT(isRubyChildForNormalRemoval(child));
     382#endif
     383        return parent.RenderInline::takeChild(m_builder, child);
     384    }
     385    // If the child's parent is an anoymous block (must be generated :before/:after content)
     386    // just use the block's remove method.
     387    if (isAnonymousRubyInlineBlock(child.parent())) {
     388        ASSERT(child.isBeforeContent() || child.isAfterContent());
     389        auto& parent = *child.parent();
     390        auto takenChild = parent.takeChild(m_builder, child);
     391        parent.removeFromParentAndDestroy(m_builder);
     392        return takenChild;
     393    }
     394
     395    // Otherwise find the containing run and remove it from there.
     396    return findRubyRunParent(child).takeChild(m_builder, child);
     397}
     398
     399RenderPtr<RenderObject> RenderTreeBuilder::Ruby::takeChild(RenderRubyAsBlock& parent, RenderObject& child)
     400{
     401    // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
     402    // just use the normal remove method.
     403    if (child.parent() == &parent) {
     404#ifndef ASSERT_DISABLED
     405        ASSERT(isRubyChildForNormalRemoval(child));
     406#endif
     407        return parent.RenderBlockFlow::takeChild(m_builder, child);
     408    }
     409    // If the child's parent is an anoymous block (must be generated :before/:after content)
     410    // just use the block's remove method.
     411    if (isAnonymousRubyInlineBlock(child.parent())) {
     412        ASSERT(child.isBeforeContent() || child.isAfterContent());
     413        auto& parent = *child.parent();
     414        auto takenChild = parent.takeChild(m_builder, child);
     415        parent.removeFromParentAndDestroy(m_builder);
     416        return takenChild;
     417    }
     418
     419    // Otherwise find the containing run and remove it from there.
     420    return findRubyRunParent(child).takeChild(m_builder, child);
     421}
     422
     423}
  • trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h

    r227980 r228339  
    4343
    4444    void insertChild(RenderRubyRun& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
     45    RenderPtr<RenderObject> takeChild(RenderRubyAsInline& parent, RenderObject& child);
     46    RenderPtr<RenderObject> takeChild(RenderRubyAsBlock& parent, RenderObject& child);
     47
    4548    RenderElement& findOrCreateParentForChild(RenderRubyAsBlock& parent, const RenderObject& child, RenderObject*& beforeChild);
    4649    RenderElement& findOrCreateParentForChild(RenderRubyAsInline& parent, const RenderObject& child, RenderObject*& beforeChild);
Note: See TracChangeset for help on using the changeset viewer.