summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderRuby.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/rendering/RenderRuby.cpp')
-rw-r--r--Source/WebCore/rendering/RenderRuby.cpp69
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