Reviewed by Hyatt.
[WebKit-https.git] / WebCore / rendering / RenderBlock.cpp
index 86a445944dae23dd8c982b83dd47a07f5233e879..4ba0948a73247e9d60a44672d74f4bfc6d802ab5 100644 (file)
@@ -269,6 +269,18 @@ static void getInlineRun(RenderObject* start, RenderObject* boundary,
     } while (!sawInline);
 }
 
     } while (!sawInline);
 }
 
+void RenderBlock::deleteLineBoxTree()
+{
+    InlineFlowBox* line = m_firstLineBox;
+    InlineFlowBox* nextLine;
+    while (line) {
+        nextLine = line->nextFlowBox();
+        line->deleteLine(renderArena());
+        line = nextLine;
+    }
+    m_firstLineBox = m_lastLineBox = 0;
+}
+
 void RenderBlock::makeChildrenNonInline(RenderObject *insertionPoint)
 {    
     // makeChildrenNonInline takes a block whose children are *all* inline and it
 void RenderBlock::makeChildrenNonInline(RenderObject *insertionPoint)
 {    
     // makeChildrenNonInline takes a block whose children are *all* inline and it
@@ -283,14 +295,7 @@ void RenderBlock::makeChildrenNonInline(RenderObject *insertionPoint)
 
     m_childrenInline = false;
 
 
     m_childrenInline = false;
 
-    InlineFlowBox* line = m_firstLineBox;
-    InlineFlowBox* nextLine;
-    while (line) {
-        nextLine = line->nextFlowBox();
-        line->deleteLine(renderArena());
-        line = nextLine;
-    }
-    m_firstLineBox = m_lastLineBox = 0;
+    deleteLineBoxTree();
 
     RenderObject *child = firstChild();
 
 
     RenderObject *child = firstChild();
 
@@ -343,25 +348,9 @@ void RenderBlock::removeChild(RenderObject *oldChild)
             prev->appendChildNode(next->removeChildNode(no));
             no->setNeedsLayoutAndMinMaxRecalc();
         }
             prev->appendChildNode(next->removeChildNode(no));
             no->setNeedsLayoutAndMinMaxRecalc();
         }
-        
-        // Do the same with line boxes.
-        RenderBlock* prevBlock = static_cast<RenderBlock*>(prev);
         RenderBlock* nextBlock = static_cast<RenderBlock*>(next);
         RenderBlock* nextBlock = static_cast<RenderBlock*>(next);
-        if (RootInlineBox* box = nextBlock->firstRootBox()) {
-            if (prevBlock->lastRootBox()) {
-                prevBlock->lastRootBox()->setNextLineBox(box);
-                box->setPreviousLineBox(prevBlock->lastRootBox());
-            } else
-                prevBlock->m_firstLineBox = box;
-
-            while (box) {
-                prevBlock->m_lastLineBox = box;
-                box->m_object = prevBlock;
-                box = box->nextRootBox();
-            }
-            nextBlock->m_firstLineBox = 0;
-            nextBlock->m_lastLineBox = 0;
-        }
+        nextBlock->deleteLineBoxTree();
         
         // Nuke the now-empty block.
         next->destroy();
         
         // Nuke the now-empty block.
         next->destroy();
@@ -385,18 +374,8 @@ void RenderBlock::removeChild(RenderObject *oldChild)
             no->setNeedsLayoutAndMinMaxRecalc();
         }
 
             no->setNeedsLayoutAndMinMaxRecalc();
         }
 
-        // Take over the anonymous child's line boxes.
-        RootInlineBox* box = anonBlock->firstRootBox();
-        m_firstLineBox = box;
-        while (box) {
-            m_lastLineBox = box;
-            box->m_object = this;
-            box = box->nextRootBox();
-        }
-        anonBlock->m_firstLineBox = 0;
-        anonBlock->m_lastLineBox = 0;
-
-        // Nuke the now-empty block.
+        // Delete the now-empty block's lines and nuke it.
+        anonBlock->deleteLineBoxTree();
         anonBlock->destroy();
     }
 }
         anonBlock->destroy();
     }
 }