diff options
author | Steve Block <steveblock@google.com> | 2011-09-02 10:16:42 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-09-02 10:17:36 +0100 |
commit | 3c901e39b23f30a49e22128cfce7bab417116016 (patch) | |
tree | 475c65fd16cbdfbea76a02f1e7c7facb6558d31e /Source | |
parent | 7652cdf8bd83fd2bbda3e5696ead6e041946c43f (diff) | |
download | external_webkit-3c901e39b23f30a49e22128cfce7bab417116016.zip external_webkit-3c901e39b23f30a49e22128cfce7bab417116016.tar.gz external_webkit-3c901e39b23f30a49e22128cfce7bab417116016.tar.bz2 |
Incorrect handling of 'display:' property within nested <ruby> tags
This is a cherry-pick of
http://trac.webkit.org/changeset/89987
Bug: 5244760
Change-Id: Iebbac8a93d6aabd0f8d568c9b1ace6f9316a6b6c
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebCore/rendering/RenderRuby.cpp | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/Source/WebCore/rendering/RenderRuby.cpp b/Source/WebCore/rendering/RenderRuby.cpp index 16b0a76..e0137de 100644 --- a/Source/WebCore/rendering/RenderRuby.cpp +++ b/Source/WebCore/rendering/RenderRuby.cpp @@ -40,33 +40,53 @@ namespace WebCore { //=== generic helper functions to avoid excessive code duplication === -static inline bool isAnonymousRubyInlineBlock(RenderObject* object) +static inline bool isAnonymousRubyInlineBlock(const RenderObject* object) { - ASSERT(!object->parent()->isRuby() + ASSERT(!object + || !object->parent()->isRuby() || object->isRubyRun() || (object->isInline() && (object->isBeforeContent() || object->isAfterContent())) || (object->isAnonymous() && object->isRenderBlock() && object->style()->display() == INLINE_BLOCK)); - return object->parent()->isRuby() && object->isRenderBlock() && !object->isRubyRun(); + + return object + && object->parent()->isRuby() + && object->isRenderBlock() + && !object->isRubyRun(); +} + +static inline bool isRubyBeforeBlock(const RenderObject* object) +{ + return isAnonymousRubyInlineBlock(object) + && !object->previousSibling() + && object->firstChild() + && object->firstChild()->style()->styleType() == BEFORE; +} + +static inline bool isRubyAfterBlock(const RenderObject* object) +{ + return isAnonymousRubyInlineBlock(object) + && !object->nextSibling() + && object->firstChild() + && object->firstChild()->style()->styleType() == AFTER; } static inline RenderBlock* rubyBeforeBlock(const RenderObject* ruby) { RenderObject* child = ruby->firstChild(); - return child && !child->isRubyRun() && child->isRenderBlock() && child->style()->styleType() == BEFORE ? toRenderBlock(child) : 0; + return isRubyBeforeBlock(child) ? static_cast<RenderBlock*>(child) : 0; } static inline RenderBlock* rubyAfterBlock(const RenderObject* ruby) { RenderObject* child = ruby->lastChild(); - return child && !child->isRubyRun() && child->isRenderBlock() && child->style()->styleType() == AFTER ? toRenderBlock(child) : 0; + return isRubyAfterBlock(child) ? static_cast<RenderBlock*>(child) : 0; } -static RenderBlock* createAnonymousRubyInlineBlock(RenderObject* ruby, PseudoId styleType) +static RenderBlock* createAnonymousRubyInlineBlock(RenderObject* ruby) { RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyle(ruby->style()); newStyle->setDisplay(INLINE_BLOCK); - newStyle->setStyleType(styleType); - + RenderBlock* newBlock = new (ruby->renderArena()) RenderBlock(ruby->document() /* anonymous box */); newBlock->setStyle(newStyle.release()); return newBlock; @@ -78,14 +98,14 @@ static RenderRubyRun* lastRubyRun(const RenderObject* ruby) if (child && !child->isRubyRun()) child = child->previousSibling(); ASSERT(!child || child->isRubyRun() || child->isBeforeContent() || child == rubyBeforeBlock(ruby)); - return child && child->isRubyRun() ? toRenderRubyRun(child) : 0; + return child && child->isRubyRun() ? static_cast<RenderRubyRun*>(child) : 0; } static inline RenderRubyRun* findRubyRunParent(RenderObject* child) { while (child && !child->isRubyRun()) child = child->parent(); - return toRenderRubyRun(child); + return static_cast<RenderRubyRun*>(child); } //=== ruby as inline object === @@ -110,7 +130,7 @@ void RenderRubyAsInline::addChild(RenderObject* child, RenderObject* beforeChild // Wrap non-inline content with an anonymous inline-block. RenderBlock* beforeBlock = rubyBeforeBlock(this); if (!beforeBlock) { - beforeBlock = createAnonymousRubyInlineBlock(this, BEFORE); + beforeBlock = createAnonymousRubyInlineBlock(this); RenderInline::addChild(beforeBlock, firstChild()); } beforeBlock->addChild(child); @@ -125,7 +145,7 @@ void RenderRubyAsInline::addChild(RenderObject* child, RenderObject* beforeChild // Wrap non-inline content with an anonymous inline-block. RenderBlock* afterBlock = rubyAfterBlock(this); if (!afterBlock) { - afterBlock = createAnonymousRubyInlineBlock(this, AFTER); + afterBlock = createAnonymousRubyInlineBlock(this); RenderInline::addChild(afterBlock); } afterBlock->addChild(child); @@ -211,7 +231,7 @@ void RenderRubyAsBlock::addChild(RenderObject* child, RenderObject* beforeChild) // Wrap non-inline content with an anonymous inline-block. RenderBlock* beforeBlock = rubyBeforeBlock(this); if (!beforeBlock) { - beforeBlock = createAnonymousRubyInlineBlock(this, BEFORE); + beforeBlock = createAnonymousRubyInlineBlock(this); RenderBlock::addChild(beforeBlock, firstChild()); } beforeBlock->addChild(child); @@ -226,7 +246,7 @@ void RenderRubyAsBlock::addChild(RenderObject* child, RenderObject* beforeChild) // Wrap non-inline content with an anonymous inline-block. RenderBlock* afterBlock = rubyAfterBlock(this); if (!afterBlock) { - afterBlock = createAnonymousRubyInlineBlock(this, AFTER); + afterBlock = createAnonymousRubyInlineBlock(this); RenderBlock::addChild(afterBlock); } afterBlock->addChild(child); |