diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderRuby.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/rendering/RenderRuby.cpp')
-rw-r--r-- | Source/WebCore/rendering/RenderRuby.cpp | 69 |
1 files changed, 43 insertions, 26 deletions
diff --git a/Source/WebCore/rendering/RenderRuby.cpp b/Source/WebCore/rendering/RenderRuby.cpp index f0344ca6a..fea0f578e 100644 --- a/Source/WebCore/rendering/RenderRuby.cpp +++ b/Source/WebCore/rendering/RenderRuby.cpp @@ -45,48 +45,60 @@ namespace WebCore { static inline bool isAnonymousRubyInlineBlock(const RenderObject* object) { ASSERT(!object - || !object->parent()->isRuby() - || object->isRubyRun() + || !isRuby(object->parent()) + || is<RenderRubyRun>(*object) || (object->isInline() && (object->isBeforeContent() || object->isAfterContent())) - || (object->isAnonymous() && object->isRenderBlock() && object->style().display() == INLINE_BLOCK)); + || (object->isAnonymous() && is<RenderBlock>(*object) && object->style().display() == INLINE_BLOCK)); return object - && object->parent()->isRuby() - && object->isRenderBlock() - && !object->isRubyRun(); + && isRuby(object->parent()) + && is<RenderBlock>(*object) + && !is<RenderRubyRun>(*object); } static inline bool isRubyBeforeBlock(const RenderObject* object) { return isAnonymousRubyInlineBlock(object) && !object->previousSibling() - && object->firstChildSlow() - && object->firstChildSlow()->style().styleType() == BEFORE; + && downcast<RenderBlock>(*object).firstChild() + && downcast<RenderBlock>(*object).firstChild()->style().styleType() == BEFORE; } static inline bool isRubyAfterBlock(const RenderObject* object) { return isAnonymousRubyInlineBlock(object) && !object->nextSibling() - && object->firstChildSlow() - && object->firstChildSlow()->style().styleType() == AFTER; + && downcast<RenderBlock>(*object).firstChild() + && downcast<RenderBlock>(*object).firstChild()->style().styleType() == AFTER; } +#ifndef ASSERT_DISABLED +static inline bool isRubyChildForNormalRemoval(const RenderObject& object) +{ + return object.isRubyRun() + || object.isBeforeContent() + || object.isAfterContent() + || object.isRenderMultiColumnFlowThread() + || object.isRenderMultiColumnSet() + || isAnonymousRubyInlineBlock(&object); +} +#endif + static inline RenderBlock* rubyBeforeBlock(const RenderElement* ruby) { RenderObject* child = ruby->firstChild(); - return isRubyBeforeBlock(child) ? toRenderBlock(child) : 0; + return isRubyBeforeBlock(child) ? downcast<RenderBlock>(child) : nullptr; } static inline RenderBlock* rubyAfterBlock(const RenderElement* ruby) { RenderObject* child = ruby->lastChild(); - return isRubyAfterBlock(child) ? toRenderBlock(child) : 0; + return isRubyAfterBlock(child) ? downcast<RenderBlock>(child) : nullptr; } static RenderBlock* createAnonymousRubyInlineBlock(RenderObject& ruby) { - RenderBlock* newBlock = new RenderBlockFlow(ruby.document(), RenderStyle::createAnonymousStyleWithDisplay(&ruby.style(), INLINE_BLOCK)); + RenderBlock* newBlock = new RenderBlockFlow(ruby.document(), RenderStyle::createAnonymousStyleWithDisplay(ruby.style(), INLINE_BLOCK)); newBlock->initializeStyle(); return newBlock; } @@ -94,10 +106,13 @@ static RenderBlock* createAnonymousRubyInlineBlock(RenderObject& ruby) static RenderRubyRun* lastRubyRun(const RenderElement* ruby) { RenderObject* child = ruby->lastChild(); - if (child && !child->isRubyRun()) + if (child && !is<RenderRubyRun>(*child)) child = child->previousSibling(); - ASSERT(!child || child->isRubyRun() || child->isBeforeContent() || child == rubyBeforeBlock(ruby)); - return child && child->isRubyRun() ? toRenderRubyRun(child) : 0; + if (!is<RenderRubyRun>(child)) { + ASSERT(!child || child->isBeforeContent() || child == rubyBeforeBlock(ruby)); + return nullptr; + } + return downcast<RenderRubyRun>(child); } static inline RenderRubyRun& findRubyRunParent(RenderObject& child) @@ -107,8 +122,8 @@ static inline RenderRubyRun& findRubyRunParent(RenderObject& child) //=== ruby as inline object === -RenderRubyAsInline::RenderRubyAsInline(Element& element, PassRef<RenderStyle> style) - : RenderInline(element, std::move(style)) +RenderRubyAsInline::RenderRubyAsInline(Element& element, RenderStyle&& style) + : RenderInline(element, WTFMove(style)) { } @@ -192,7 +207,9 @@ void RenderRubyAsInline::removeChild(RenderObject& child) // If the child's parent is *this (must be a ruby run or generated content or anonymous block), // just use the normal remove method. if (child.parent() == this) { - ASSERT(child.isRubyRun() || child.isBeforeContent() || child.isAfterContent() || isAnonymousRubyInlineBlock(&child)); +#ifndef ASSERT_DISABLED + ASSERT(isRubyChildForNormalRemoval(child)); +#endif RenderInline::removeChild(child); return; } @@ -206,14 +223,13 @@ void RenderRubyAsInline::removeChild(RenderObject& child) } // Otherwise find the containing run and remove it from there. - RenderRubyRun& run = findRubyRunParent(child); - run.removeChild(child); + findRubyRunParent(child).removeChild(child); } //=== ruby as block object === -RenderRubyAsBlock::RenderRubyAsBlock(Element& element, PassRef<RenderStyle> style) - : RenderBlockFlow(element, std::move(style)) +RenderRubyAsBlock::RenderRubyAsBlock(Element& element, RenderStyle&& style) + : RenderBlockFlow(element, WTFMove(style)) { } @@ -297,7 +313,9 @@ void RenderRubyAsBlock::removeChild(RenderObject& child) // If the child's parent is *this (must be a ruby run or generated content or anonymous block), // just use the normal remove method. if (child.parent() == this) { - ASSERT(child.isRubyRun() || child.isBeforeContent() || child.isAfterContent() || isAnonymousRubyInlineBlock(&child)); +#ifndef ASSERT_DISABLED + ASSERT(isRubyChildForNormalRemoval(child)); +#endif RenderBlockFlow::removeChild(child); return; } @@ -311,8 +329,7 @@ void RenderRubyAsBlock::removeChild(RenderObject& child) } // Otherwise find the containing run and remove it from there. - RenderRubyRun& run = findRubyRunParent(child); - run.removeChild(child); + findRubyRunParent(child).removeChild(child); } } // namespace WebCore |