summaryrefslogtreecommitdiff
blob: 003446d595ee9abd9cc440c9a87c3a778ba71a5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
--- khtml/rendering/render_container.cpp.orig	2008-05-03 09:22:01.000000000 +0200
+++ khtml/rendering/render_container.cpp	2008-05-03 09:22:47.000000000 +0200
@@ -79,6 +79,8 @@
     kdDebug( 6040 ) << this << ": " <<  renderName() << "(RenderObject)::addChild( " << newChild << ": " <<
         newChild->renderName() << ", " << (beforeChild ? beforeChild->renderName() : "0") << " )" << endl;
 #endif
+    // protect ourselves from deletion
+    setDoNotDelete(true);
 
     bool needsTable = false;
 
@@ -159,6 +161,8 @@
             static_cast<RenderText*>(newChild)->setText(textToTransform, true);
     }
     newChild->attach();
+    
+    setDoNotDelete(false);
 }
 
 RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild)
@@ -545,7 +549,7 @@
 	RenderObject *next = child->nextSibling();
 
 	if ( child->isRenderBlock() && child->isAnonymousBlock() && !child->continuation() &&
-             !child->childrenInline() && !child->isTableCell() ) {
+             !child->childrenInline() && !child->isTableCell() && !child->doNotDelete()) {
 	    RenderObject *firstAnChild = child->firstChild();
 	    RenderObject *lastAnChild = child->lastChild();
 	    if ( firstAnChild ) {
@@ -560,17 +564,21 @@
 		    child->previousSibling()->setNextSibling( firstAnChild );
 		if ( child->nextSibling() )
 		    child->nextSibling()->setPreviousSibling( lastAnChild );
+                if ( child == firstChild() )
+                    m_first = firstAnChild;
+                if ( child == lastChild() )
+                    m_last = lastAnChild;
 	    } else {
 		if ( child->previousSibling() )
 		    child->previousSibling()->setNextSibling( child->nextSibling() );
 		if ( child->nextSibling() )
 		    child->nextSibling()->setPreviousSibling( child->previousSibling() );
-
-	    }
 	    if ( child == firstChild() )
-		m_first = firstAnChild;
+                    m_first = child->nextSibling();
 	    if ( child == lastChild() )
-		m_last = lastAnChild;
+                    m_last = child->previousSibling();
+            }
+
 	    child->setParent( 0 );
 	    child->setPreviousSibling( 0 );
 	    child->setNextSibling( 0 );
--- khtml/rendering/render_object.cpp.orig	2008-05-03 09:22:40.000000000 +0200
+++ khtml/rendering/render_object.cpp	2008-05-03 09:22:47.000000000 +0200
@@ -178,7 +178,8 @@
       m_isRoot( false ),
       m_afterPageBreak( false ),
       m_needsPageClear( false ),
-      m_containsPageBreak( false )
+      m_containsPageBreak( false ),
+      m_doNotDelete(false)
 {
   assert( node );
   if (node->getDocument()->documentElement() == node) setIsRoot(true);
--- khtml/rendering/render_object.h.orig	2008-05-03 09:22:04.000000000 +0200
+++ khtml/rendering/render_object.h	2008-05-03 09:22:47.000000000 +0200
@@ -754,6 +754,9 @@
     virtual void deleteInlineBoxes(RenderArena* arena=0) {(void)arena;}
     virtual void detach( );
 
+    void setDoNotDelete(bool b) { m_doNotDelete = b; }
+    bool doNotDelete() const { return m_doNotDelete; }
+
     const QFont &font(bool firstLine) const {
 	return style( firstLine )->font();
     }
@@ -835,7 +838,9 @@
     bool m_needsPageClear            : 1;
     bool m_containsPageBreak         : 1;
 
-    // ### we have 16 + 24 bits. Cut 8 and save 32
+    bool m_doNotDelete               : 1; // This object should not be auto-deleted
+
+    // ### we have 16 + 27 bits.
 
 
     void arenaDelete(RenderArena *arena, void *objectBase);