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

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

Issue 10447080: Merge 117865 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 7 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/RenderBlock.h ('k') | Source/WebCore/rendering/RenderInline.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/rendering/RenderBlock.cpp
===================================================================
--- Source/WebCore/rendering/RenderBlock.cpp (revision 118863)
+++ Source/WebCore/rendering/RenderBlock.cpp (working copy)
@@ -852,6 +852,10 @@
}
}
+ // Nothing goes before the intruded run-in.
+ if (beforeChild && beforeChild->isRunIn() && runInIsPlacedIntoSiblingBlock(beforeChild))
+ beforeChild = beforeChild->nextSibling();
+
// Check for a spanning element in columns.
RenderBlock* columnsBlockAncestor = columnsBlockForSpanningElement(newChild);
if (columnsBlockAncestor) {
@@ -933,13 +937,8 @@
RenderBox::addChild(newChild, beforeChild);
- // Handle positioning of run-ins.
- if (newChild->isRunIn())
- moveRunInUnderSiblingBlockIfNeeded(newChild);
- else if (RenderObject* prevSibling = newChild->previousSibling()) {
- if (prevSibling->isRunIn())
- moveRunInUnderSiblingBlockIfNeeded(prevSibling);
- }
+ // Handle placement of run-ins.
+ placeRunInIfNeeded(newChild, DoNotPlaceGeneratedRunIn);
if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isRenderBlock())
toRenderBlock(parent())->removeLeftoverAnonymousBlock(this);
@@ -1046,6 +1045,8 @@
if (!child)
return;
+ deleteLineBoxTree();
+
// Since we are going to have block children, we have to move
// back the run-in to its original place.
if (child->isRunIn()) {
@@ -1053,8 +1054,6 @@
child = firstChild();
}
- deleteLineBoxTree();
-
while (child) {
RenderObject *inlineRunStart, *inlineRunEnd;
getInlineRun(child, insertionPoint, inlineRunStart, inlineRunEnd);
@@ -1768,13 +1767,28 @@
ASSERT(runIn->isRunIn());
ASSERT(!runIn->firstChild());
- // If it is a block run-in, delete its line box tree as well. This is needed as our
- // children got moved and our line box tree is no longer valid.
+ // Delete our line box tree. This is needed as our children got moved
+ // and our line box tree is no longer valid.
if (runIn->isRenderBlock())
toRenderBlock(runIn)->deleteLineBoxTree();
+ else if (runIn->isRenderInline())
+ toRenderInline(runIn)->deleteLineBoxTree();
+ else
+ ASSERT_NOT_REACHED();
+
runIn->destroy();
}
+void RenderBlock::placeRunInIfNeeded(RenderObject* newChild, PlaceGeneratedRunInFlag flag)
+{
+ if (newChild->isRunIn() && (flag == PlaceGeneratedRunIn || !newChild->isBeforeOrAfterContent()))
+ moveRunInUnderSiblingBlockIfNeeded(newChild);
+ else if (RenderObject* prevSibling = newChild->previousSibling()) {
+ if (prevSibling->isRunIn() && (flag == PlaceGeneratedRunIn || !newChild->isBeforeOrAfterContent()))
+ moveRunInUnderSiblingBlockIfNeeded(prevSibling);
+ }
+}
+
RenderBoxModelObject* RenderBlock::createReplacementRunIn(RenderBoxModelObject* runIn)
{
ASSERT(runIn->isRunIn());
@@ -1851,19 +1865,31 @@
// since it handles correct placement of the children, especially where we cannot insert
// anything before the first child. e.g. details tag. See https://bugs.webkit.org/show_bug.cgi?id=58228.
curr->addChild(newRunIn, curr->firstChild());
+
+ // Make sure that |this| get a layout since its run-in child moved.
+ curr->setNeedsLayoutAndPrefWidthsRecalc();
}
-void RenderBlock::moveRunInToOriginalPosition(RenderObject* runIn)
+bool RenderBlock::runInIsPlacedIntoSiblingBlock(RenderObject* runIn)
{
ASSERT(runIn->isRunIn());
- // If we don't have a parent, there is nothing to move. This might
- // happen if |this| got detached from parent after |runIn| run into |this|.
+ // If we don't have a parent, we can't be moved into our sibling block.
if (!parent())
- return;
+ return false;
// An intruded run-in needs to be an inline.
if (!runIn->isRenderInline())
+ return false;
+
+ return true;
+}
+
+void RenderBlock::moveRunInToOriginalPosition(RenderObject* runIn)
+{
+ ASSERT(runIn->isRunIn());
+
+ if (!runInIsPlacedIntoSiblingBlock(runIn))
return;
RenderBoxModelObject* oldRunIn = toRenderBoxModelObject(runIn);
@@ -1872,6 +1898,9 @@
// Add the run-in block as our previous sibling.
parent()->addChild(newRunIn, this);
+
+ // Make sure that the parent holding the new run-in gets layout.
+ parent()->setNeedsLayoutAndPrefWidthsRecalc();
}
LayoutUnit RenderBlock::collapseMargins(RenderBox* child, MarginInfo& marginInfo)
« no previous file with comments | « Source/WebCore/rendering/RenderBlock.h ('k') | Source/WebCore/rendering/RenderInline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698