Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Unified Diff: Source/WebCore/rendering/RenderRubyBase.cpp

Issue 8041046: Merge 95924 - Source/WebCore: Issues with merging block children of a ruby (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/rendering/RenderRubyBase.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/rendering/RenderRubyBase.cpp
===================================================================
--- Source/WebCore/rendering/RenderRubyBase.cpp (revision 96017)
+++ Source/WebCore/rendering/RenderRubyBase.cpp (working copy)
@@ -53,23 +53,11 @@
return child->isInline();
}
-bool RenderRubyBase::hasOnlyWrappedInlineChildren(RenderObject* beforeChild) const
-{
- // Tests whether all children in the base before beforeChild are either floated/positioned,
- // or inline objects wrapped in anonymous blocks.
- // Note that beforeChild may be 0, in which case all children are looked at.
- for (RenderObject* child = firstChild(); child != beforeChild; child = child->nextSibling()) {
- if (!child->isFloatingOrPositioned() && !(child->isAnonymousBlock() && child->childrenInline()))
- return false;
- }
- return true;
-}
-
void RenderRubyBase::moveChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
{
// This function removes all children that are before (!) beforeChild
// and appends them to toBase.
- ASSERT(toBase);
+ ASSERT_ARG(toBase, toBase);
// First make sure that beforeChild (if set) is indeed a direct child of this.
// Inline children might be wrapped in an anonymous block if there's a continuation.
@@ -89,8 +77,13 @@
void RenderRubyBase::moveInlineChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
{
- RenderBlock* toBlock;
+ ASSERT(childrenInline());
+ ASSERT_ARG(toBase, toBase);
+ if (!firstChild())
+ return;
+
+ RenderBlock* toBlock;
if (toBase->childrenInline()) {
// The standard and easy case: move the children into the target base
toBlock = toBase;
@@ -111,66 +104,15 @@
void RenderRubyBase::moveBlockChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
{
- if (toBase->childrenInline()) {
- // First check whether we move only wrapped inline objects.
- if (hasOnlyWrappedInlineChildren(beforeChild)) {
- // The reason why the base is in block flow must be after beforeChild.
- // We therefore can extract the inline objects and move them to toBase.
- for (RenderObject* child = firstChild(); child != beforeChild; child = firstChild()) {
- if (child->isAnonymousBlock()) {
- RenderBlock* anonBlock = toRenderBlock(child);
- ASSERT(anonBlock->childrenInline());
- ASSERT(!anonBlock->inlineElementContinuation());
- anonBlock->moveAllChildrenTo(toBase, toBase->children());
- anonBlock->deleteLineBoxTree();
- anonBlock->destroy();
- } else {
- ASSERT(child->isFloatingOrPositioned());
- moveChildTo(toBase, child);
- }
- }
- } else {
- // Moving block children -> have to set toBase as block flow
- toBase->makeChildrenNonInline();
- // Move children, potentially collapsing anonymous block wrappers.
- mergeBlockChildren(toBase, beforeChild);
-
- // Now we need to check if the leftover children are all inline.
- // If so, make this base inline again.
- if (hasOnlyWrappedInlineChildren()) {
- RenderObject* next = 0;
- for (RenderObject* child = firstChild(); child; child = next) {
- next = child->nextSibling();
- if (child->isFloatingOrPositioned())
- continue;
- ASSERT(child->isAnonymousBlock());
-
- RenderBlock* anonBlock = toRenderBlock(child);
- ASSERT(anonBlock->childrenInline());
- ASSERT(!anonBlock->inlineElementContinuation());
- // Move inline children out of anonymous block.
- anonBlock->moveAllChildrenTo(this, anonBlock);
- anonBlock->deleteLineBoxTree();
- anonBlock->destroy();
- }
- setChildrenInline(true);
- }
- }
- } else
- mergeBlockChildren(toBase, beforeChild);
-}
-
-void RenderRubyBase::mergeBlockChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
-{
- // This function removes all children that are before beforeChild and appends them to toBase.
ASSERT(!childrenInline());
- ASSERT(toBase);
- ASSERT(!toBase->childrenInline());
+ ASSERT_ARG(toBase, toBase);
- // Quick check whether we have anything to do, to simplify the following code.
if (!firstChild())
return;
+ if (toBase->childrenInline())
+ toBase->makeChildrenNonInline();
+
// If an anonymous block would be put next to another such block, then merge those.
RenderObject* firstChildHere = firstChild();
RenderObject* lastChildThere = toBase->lastChild();
« no previous file with comments | « Source/WebCore/rendering/RenderRubyBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698