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

Side by Side Diff: Source/core/rendering/RenderBlock.cpp

Issue 23463021: Avoid collapsing anonymous block children already being destroyed (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 return false; 1102 return false;
1103 1103
1104 if (!prev || !next) 1104 if (!prev || !next)
1105 return true; 1105 return true;
1106 1106
1107 // Make sure the types of the anonymous blocks match up. 1107 // Make sure the types of the anonymous blocks match up.
1108 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock() 1108 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock()
1109 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock(); 1109 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock();
1110 } 1110 }
1111 1111
1112 void RenderBlock::collapseAnonymousBoxChild(RenderBlock* parent, RenderObject* c hild) 1112 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child)
1113 { 1113 {
1114 // It's possible that this block's destruction may have been triggered by th e
1115 // child's removal. Just bail if the anonymous child block is already being
1116 // destroyed. See crbug.com/282088
1117 if (child->beingDestroyed())
1118 return;
1114 parent->setNeedsLayoutAndPrefWidthsRecalc(); 1119 parent->setNeedsLayoutAndPrefWidthsRecalc();
1115 parent->setChildrenInline(child->childrenInline()); 1120 parent->setChildrenInline(child->childrenInline());
1116 RenderObject* nextSibling = child->nextSibling(); 1121 RenderObject* nextSibling = child->nextSibling();
1117 1122
1118 RenderFlowThread* childFlowThread = child->flowThreadContainingBlock(); 1123 RenderFlowThread* childFlowThread = child->flowThreadContainingBlock();
1119 CurrentRenderFlowThreadMaintainer flowThreadMaintainer(childFlowThread); 1124 CurrentRenderFlowThreadMaintainer flowThreadMaintainer(childFlowThread);
1120 1125
1121 RenderBlock* anonBlock = toRenderBlock(parent->children()->removeChildNode(p arent, child, child->hasLayer())); 1126 parent->children()->removeChildNode(parent, child, child->hasLayer());
1122 anonBlock->moveAllChildrenTo(parent, nextSibling, child->hasLayer()); 1127 child->moveAllChildrenTo(parent, nextSibling, child->hasLayer());
1123 // Delete the now-empty block's lines and nuke it. 1128 // Explicitly delete the child's line box tree, or the special anonymous
1124 anonBlock->deleteLineBoxTree(); 1129 // block handling in willBeDestroyed will cause problems.
1130 child->deleteLineBoxTree();
1125 if (childFlowThread && childFlowThread->isRenderNamedFlowThread()) 1131 if (childFlowThread && childFlowThread->isRenderNamedFlowThread())
1126 toRenderNamedFlowThread(childFlowThread)->removeFlowChildInfo(anonBlock) ; 1132 toRenderNamedFlowThread(childFlowThread)->removeFlowChildInfo(child);
1127 anonBlock->destroy(); 1133 child->destroy();
1128 } 1134 }
1129 1135
1130 void RenderBlock::moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, bool fu llRemoveInsert) 1136 void RenderBlock::moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, bool fu llRemoveInsert)
1131 { 1137 {
1132 moveAllChildrenTo(toBlock, fullRemoveInsert); 1138 moveAllChildrenTo(toBlock, fullRemoveInsert);
1133 1139
1134 // When a portion of the render tree is being detached, anonymous blocks 1140 // When a portion of the render tree is being detached, anonymous blocks
1135 // will be combined as their children are deleted. In this process, the 1141 // will be combined as their children are deleted. In this process, the
1136 // anonymous block later in the tree is merged into the one preceeding it. 1142 // anonymous block later in the tree is merged into the one preceeding it.
1137 // It can happen that the later block (this) contains floats that the 1143 // It can happen that the later block (this) contains floats that the
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 } 1235 }
1230 } 1236 }
1231 1237
1232 RenderBox::removeChild(oldChild); 1238 RenderBox::removeChild(oldChild);
1233 1239
1234 RenderObject* child = prev ? prev : next; 1240 RenderObject* child = prev ? prev : next;
1235 if (canMergeAnonymousBlocks && child && !child->previousSibling() && !child- >nextSibling() && canCollapseAnonymousBlockChild()) { 1241 if (canMergeAnonymousBlocks && child && !child->previousSibling() && !child- >nextSibling() && canCollapseAnonymousBlockChild()) {
1236 // The removal has knocked us down to containing only a single anonymous 1242 // The removal has knocked us down to containing only a single anonymous
1237 // box. We can go ahead and pull the content right back up into our 1243 // box. We can go ahead and pull the content right back up into our
1238 // box. 1244 // box.
1239 collapseAnonymousBoxChild(this, child); 1245 collapseAnonymousBlockChild(this, toRenderBlock(child));
1240 } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymous Block())) && canCollapseAnonymousBlockChild()) { 1246 } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymous Block())) && canCollapseAnonymousBlockChild()) {
1241 // It's possible that the removal has knocked us down to a single anonym ous 1247 // It's possible that the removal has knocked us down to a single anonym ous
1242 // block with pseudo-style element siblings (e.g. first-letter). If thes e 1248 // block with pseudo-style element siblings (e.g. first-letter). If thes e
1243 // are floating, then we need to pull the content up also. 1249 // are floating, then we need to pull the content up also.
1244 RenderBlock* anonBlock = toRenderBlock((prev && prev->isAnonymousBlock() ) ? prev : next); 1250 RenderBlock* anonymousBlock = toRenderBlock((prev && prev->isAnonymousBl ock()) ? prev : next);
1245 if ((anonBlock->previousSibling() || anonBlock->nextSibling()) 1251 if ((anonymousBlock->previousSibling() || anonymousBlock->nextSibling())
1246 && (!anonBlock->previousSibling() || (anonBlock->previousSibling()-> style()->styleType() != NOPSEUDO && anonBlock->previousSibling()->isFloating() & & !anonBlock->previousSibling()->previousSibling())) 1252 && (!anonymousBlock->previousSibling() || (anonymousBlock->previousS ibling()->style()->styleType() != NOPSEUDO && anonymousBlock->previousSibling()- >isFloating() && !anonymousBlock->previousSibling()->previousSibling()))
1247 && (!anonBlock->nextSibling() || (anonBlock->nextSibling()->style()- >styleType() != NOPSEUDO && anonBlock->nextSibling()->isFloating() && !anonBlock ->nextSibling()->nextSibling()))) { 1253 && (!anonymousBlock->nextSibling() || (anonymousBlock->nextSibling() ->style()->styleType() != NOPSEUDO && anonymousBlock->nextSibling()->isFloating( ) && !anonymousBlock->nextSibling()->nextSibling()))) {
1248 collapseAnonymousBoxChild(this, anonBlock); 1254 collapseAnonymousBlockChild(this, anonymousBlock);
1249 } 1255 }
1250 } 1256 }
1251 1257
1252 if (!firstChild()) { 1258 if (!firstChild()) {
1253 // If this was our last child be sure to clear out our line boxes. 1259 // If this was our last child be sure to clear out our line boxes.
1254 if (childrenInline()) 1260 if (childrenInline())
1255 deleteLineBoxTree(); 1261 deleteLineBoxTree();
1256 1262
1257 // If we are an empty anonymous block in the continuation chain, 1263 // If we are an empty anonymous block in the continuation chain,
1258 // we need to remove ourself and fix the continuation chain. 1264 // we need to remove ourself and fix the continuation chain.
(...skipping 6767 matching lines...) Expand 10 before | Expand all | Expand 10 after
8026 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 8032 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
8027 { 8033 {
8028 showRenderObject(); 8034 showRenderObject();
8029 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 8035 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
8030 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 8036 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
8031 } 8037 }
8032 8038
8033 #endif 8039 #endif
8034 8040
8035 } // namespace WebCore 8041 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698