Changeset 228339 in webkit
- Timestamp:
- Feb 9, 2018 3:23:02 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r228338 r228339 1 2018-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 1 26 2018-02-09 Per Arne Vollan <pvollan@apple.com> 2 27 -
trunk/Source/WebCore/rendering/RenderRuby.cpp
r228337 r228339 46 46 WTF_MAKE_ISO_ALLOCATED_IMPL(RenderRubyAsBlock); 47 47 48 //=== generic helper functions to avoid excessive code duplication ===49 50 static inline bool isAnonymousRubyInlineBlock(const RenderObject* object)51 {52 ASSERT(!object53 || !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 object59 && isRuby(object->parent())60 && is<RenderBlock>(*object)61 && !is<RenderRubyRun>(*object);62 }63 64 #ifndef ASSERT_DISABLED65 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 #endif75 76 static inline RenderRubyRun& findRubyRunParent(RenderObject& child)77 {78 return *lineageOfType<RenderRubyRun>(child).first();79 }80 81 48 //=== ruby as inline object === 82 49 … … 96 63 RenderPtr<RenderObject> RenderRubyAsInline::takeChild(RenderTreeBuilder& builder, RenderObject& child) 97 64 { 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); 118 66 } 119 67 … … 135 83 RenderPtr<RenderObject> RenderRubyAsBlock::takeChild(RenderTreeBuilder& builder, RenderObject& child) 136 84 { 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); 157 86 } 158 87 -
trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp
r228337 r228339 471 471 } 472 472 473 RenderPtr<RenderObject> RenderTreeBuilder::takeChildFromRenderRubyAsInline(RenderRubyAsInline& parent, RenderObject& child) 474 { 475 return rubyBuilder().takeChild(parent, child); 476 } 477 478 RenderPtr<RenderObject> RenderTreeBuilder::takeChildFromRenderRubyAsBlock(RenderRubyAsBlock& parent, RenderObject& child) 479 { 480 return rubyBuilder().takeChild(parent, child); 481 } 482 473 483 void RenderTreeBuilder::updateAfterDescendants(RenderElement& renderer) 474 484 { -
trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h
r228327 r228339 31 31 32 32 class RenderMathMLFenced; 33 class RenderRubyAsBlock; 34 class RenderRubyAsInline; 33 35 class RenderRubyBase; 34 36 class RenderRubyRun; … … 71 73 void insertChildToRenderTableRow(RenderTableRow& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr); 72 74 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); 73 78 74 79 bool childRequiresTable(const RenderElement& parent, const RenderObject& child); -
trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp
r228337 r228339 34 34 namespace WebCore { 35 35 36 static inline RenderRubyRun& findRubyRunParent(RenderObject& child) 37 { 38 return *lineageOfType<RenderRubyRun>(child).first(); 39 } 40 36 41 static inline bool isAnonymousRubyInlineBlock(const RenderObject* object) 37 42 { … … 368 373 } 369 374 370 } 375 RenderPtr<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 399 RenderPtr<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 43 43 44 44 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 45 48 RenderElement& findOrCreateParentForChild(RenderRubyAsBlock& parent, const RenderObject& child, RenderObject*& beforeChild); 46 49 RenderElement& findOrCreateParentForChild(RenderRubyAsInline& parent, const RenderObject& child, RenderObject*& beforeChild);
Note: See TracChangeset
for help on using the changeset viewer.