[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:16:41 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 35355e5d5a246cfb8835dae4050deb1cef46d1fc
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Dec 20 09:19:00 2002 +0000

            Reviewed by Dave.
    
    	- fixed 3129129 -- leak of 820 RenderStyle objects each time we run cvs-base
    
    	The RenderStyle objects were the tip of an iceberg.
    
            I fixed a lot of leaks, but there are still some remaining.
    
    	Note that these changes will make Development builds slower because they disable
    	the arena allocator in favor of assertions that check we are using it correctly.
    	But the changes make Deployment builds slightly faster.
    
            * khtml/html/html_baseimpl.cpp: (HTMLFrameSetElementImpl::attach):
    	Fix a leak in the !isStyleAvailable() case by ref'ing and deref'ing the style.
    
            * khtml/html/html_formimpl.cpp:
            (HTMLFormElementImpl::attach): Fix a leak by getting the style from the render
    	object instead of calling styleForElement again, which makes a new one.
            (HTMLFormElementImpl::parseAttribute): Ditto.
            (HTMLInputElementImpl::attach): Fix a leak by using the style in the local
    	variable rather than calling styleForElement again.
    
            * khtml/html/html_imageimpl.cpp:
            (HTMLImageElementImpl::parseAttribute): Fix a leak by getting the style from the render
    	object instead of calling styleForElement again, which makes a new one.
            (HTMLImageElementImpl::attach): Fix a leak by using the style in the local
    	variable rather than calling styleForElement again.
    
            * khtml/html/html_inlineimpl.cpp: (HTMLBRElementImpl::attach):
    	Fix a leak in the display() == NONE case by ref'ing and deref'ing the style.
    
            * khtml/html/html_objectimpl.cpp: (HTMLObjectElementImpl::attach): Fix a leak by using
    	the style in the local variable rather than calling styleForElement again.
    
            * khtml/rendering/bidi.cpp:
            (BidiIterator::detach): Added debugging code to detect if someone does a delete directly,
    	which will not deallocate the object because it won't run the correct arena code.
            (BidiIterator::operator delete): Ditto.
            (appendRunsForObject): Fix a leak by detaching bidi iterators when they are removed from
    	the list. The list can't delete them because it doesn't have the arena pointer.
            (deleteMidpoints): Fix a leak by not removing the items from the list until done iterating.
    	The old code would fail to delete half the items.
    
            * khtml/rendering/render_container.cpp:
            (RenderContainer::detach): Detach the continuation here. Before we removed it but did not
    	detach it, which led to a leak.
            (RenderContainer::removeChild): Do not remove the continuation here. If we do, then we can't
    	detach successfully. No one depends on this removing the continuation.
            (RenderContainer::removeLeftoverAnonymousBoxes): Detach the child, don't just delete it.
    	This fixes a leak.
    
            * khtml/rendering/render_flow.cpp: (RenderFlow::removeChild): Detach the child, don't just
    	delete it. This fixes a leak.
    
            * khtml/rendering/render_object.h: Added arenaDelete.
            * khtml/rendering/render_object.cpp:
            (RenderObject::operator delete): Added debugging code to detect if someone does a delete directly,
    	which will not deallocate the object because it won't run the correct arena code.
            (RenderObject::detach): Ditto.
            (RenderObject::arenaDelete): Put the low-level delete here, so that subclasses (RenderWidget)
    	can call it.
    
            * khtml/rendering/render_replaced.h: Add arenaDeref and make deref private so derived classes
    	won't use it by accident.
            * khtml/rendering/render_replaced.cpp:
            (RenderWidget::detach): Use the new arenaDeref instead of deref, since we need to pass the
    	arena pointer in to delete.
            (RenderWidget::resizeWidget): Ditto. Store the arena before calling back, since we can't get it
    	once it's detached from its parent.
            (RenderWidget::eventFilter): Ditto.
            (RenderWidget::arenaDeref): Added. Calls RenderObject's arenaDelete.
    
    	- other changes
    
            * khtml/rendering/render_arena.cpp:
            (RenderArena::allocate): Added debugging code that stores a signature, arena pointer, and size,
    	and uses malloc rather than the arena.
            (RenderArena::free): Check the signature, arena pointer, and size, and use free.
    
            * khtml/rendering/render_layer.cpp:
            (RenderLayer::operator delete): Added debugging code to detect if someone does a delete directly,
    	which will not deallocate the object because it won't run the correct arena code.
            (RenderLayer::detach): Ditto.
            (RenderLayer::RenderLayerElement::operator delete): Ditto.
            (RenderLayer::RenderLayerElement::detach): Ditto.
            (RenderLayer::RenderZTreeNode::operator delete): Ditto.
            (RenderLayer::RenderZTreeNode::detach): Ditto.
    
            * khtml/rendering/render_text.cpp:
            (TextSlave::detach): Added debugging code to detect if someone does a delete directly,
    	which will not deallocate the object because it won't run the correct arena code.
            (TextSlave::operator delete): Ditto.
    
            * khtml/html/html_elementimpl.cpp: (HTMLElementImpl::createContextualFragment):
    	Save one new/delete by using a stack-based HTMLTokenizer and add FIXMEs about
    	some possible leaks I spotted here.
    
            * khtml/rendering/render_list.cpp: (RenderListItem::setStyle): Took out APPLE_CHANGES from around
    	a generally useful bug fix.
    
            * WebCore.pbproj/project.pbxproj: Let Electron be Electron.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3147 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 35ed9fa..bc39ee1 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,107 @@
+2002-12-20  Darin Adler  <darin at apple.com>
+
+        Reviewed by Dave.
+
+	- fixed 3129129 -- leak of 820 RenderStyle objects each time we run cvs-base
+
+	The RenderStyle objects were the tip of an iceberg.
+        
+        I fixed a lot of leaks, but there are still some remaining.
+
+	Note that these changes will make Development builds slower because they disable
+	the arena allocator in favor of assertions that check we are using it correctly.
+	But the changes make Deployment builds slightly faster.
+
+        * khtml/html/html_baseimpl.cpp: (HTMLFrameSetElementImpl::attach):
+	Fix a leak in the !isStyleAvailable() case by ref'ing and deref'ing the style.
+
+        * khtml/html/html_formimpl.cpp:
+        (HTMLFormElementImpl::attach): Fix a leak by getting the style from the render
+	object instead of calling styleForElement again, which makes a new one.
+        (HTMLFormElementImpl::parseAttribute): Ditto.
+        (HTMLInputElementImpl::attach): Fix a leak by using the style in the local
+	variable rather than calling styleForElement again.
+
+        * khtml/html/html_imageimpl.cpp:
+        (HTMLImageElementImpl::parseAttribute): Fix a leak by getting the style from the render
+	object instead of calling styleForElement again, which makes a new one.
+        (HTMLImageElementImpl::attach): Fix a leak by using the style in the local
+	variable rather than calling styleForElement again.
+
+        * khtml/html/html_inlineimpl.cpp: (HTMLBRElementImpl::attach):
+	Fix a leak in the display() == NONE case by ref'ing and deref'ing the style.
+
+        * khtml/html/html_objectimpl.cpp: (HTMLObjectElementImpl::attach): Fix a leak by using
+	the style in the local variable rather than calling styleForElement again.
+
+        * khtml/rendering/bidi.cpp:
+        (BidiIterator::detach): Added debugging code to detect if someone does a delete directly,
+	which will not deallocate the object because it won't run the correct arena code.
+        (BidiIterator::operator delete): Ditto.
+        (appendRunsForObject): Fix a leak by detaching bidi iterators when they are removed from
+	the list. The list can't delete them because it doesn't have the arena pointer.
+        (deleteMidpoints): Fix a leak by not removing the items from the list until done iterating.
+	The old code would fail to delete half the items.
+
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::detach): Detach the continuation here. Before we removed it but did not
+	detach it, which led to a leak.
+        (RenderContainer::removeChild): Do not remove the continuation here. If we do, then we can't
+	detach successfully. No one depends on this removing the continuation.
+        (RenderContainer::removeLeftoverAnonymousBoxes): Detach the child, don't just delete it.
+	This fixes a leak.
+
+        * khtml/rendering/render_flow.cpp: (RenderFlow::removeChild): Detach the child, don't just
+	delete it. This fixes a leak.
+
+        * khtml/rendering/render_object.h: Added arenaDelete.
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::operator delete): Added debugging code to detect if someone does a delete directly,
+	which will not deallocate the object because it won't run the correct arena code.
+        (RenderObject::detach): Ditto.
+        (RenderObject::arenaDelete): Put the low-level delete here, so that subclasses (RenderWidget)
+	can call it.
+
+        * khtml/rendering/render_replaced.h: Add arenaDeref and make deref private so derived classes
+	won't use it by accident.
+        * khtml/rendering/render_replaced.cpp:
+        (RenderWidget::detach): Use the new arenaDeref instead of deref, since we need to pass the
+	arena pointer in to delete.
+        (RenderWidget::resizeWidget): Ditto. Store the arena before calling back, since we can't get it
+	once it's detached from its parent.
+        (RenderWidget::eventFilter): Ditto.
+        (RenderWidget::arenaDeref): Added. Calls RenderObject's arenaDelete.
+
+	- other changes
+
+        * khtml/rendering/render_arena.cpp:
+        (RenderArena::allocate): Added debugging code that stores a signature, arena pointer, and size,
+	and uses malloc rather than the arena.
+        (RenderArena::free): Check the signature, arena pointer, and size, and use free.
+
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::operator delete): Added debugging code to detect if someone does a delete directly,
+	which will not deallocate the object because it won't run the correct arena code.
+        (RenderLayer::detach): Ditto.
+        (RenderLayer::RenderLayerElement::operator delete): Ditto.
+        (RenderLayer::RenderLayerElement::detach): Ditto.
+        (RenderLayer::RenderZTreeNode::operator delete): Ditto.
+        (RenderLayer::RenderZTreeNode::detach): Ditto.
+
+        * khtml/rendering/render_text.cpp:
+        (TextSlave::detach): Added debugging code to detect if someone does a delete directly,
+	which will not deallocate the object because it won't run the correct arena code.
+        (TextSlave::operator delete): Ditto.
+
+        * khtml/html/html_elementimpl.cpp: (HTMLElementImpl::createContextualFragment):
+	Save one new/delete by using a stack-based HTMLTokenizer and add FIXMEs about
+	some possible leaks I spotted here.
+
+        * khtml/rendering/render_list.cpp: (RenderListItem::setStyle): Took out APPLE_CHANGES from around
+	a generally useful bug fix.
+
+        * WebCore.pbproj/project.pbxproj: Let Electron be Electron. 
+
 === Alexander-42 ===
 
 2002-12-19  David Hyatt  <hyatt at apple.com>
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 35ed9fa..bc39ee1 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,107 @@
+2002-12-20  Darin Adler  <darin at apple.com>
+
+        Reviewed by Dave.
+
+	- fixed 3129129 -- leak of 820 RenderStyle objects each time we run cvs-base
+
+	The RenderStyle objects were the tip of an iceberg.
+        
+        I fixed a lot of leaks, but there are still some remaining.
+
+	Note that these changes will make Development builds slower because they disable
+	the arena allocator in favor of assertions that check we are using it correctly.
+	But the changes make Deployment builds slightly faster.
+
+        * khtml/html/html_baseimpl.cpp: (HTMLFrameSetElementImpl::attach):
+	Fix a leak in the !isStyleAvailable() case by ref'ing and deref'ing the style.
+
+        * khtml/html/html_formimpl.cpp:
+        (HTMLFormElementImpl::attach): Fix a leak by getting the style from the render
+	object instead of calling styleForElement again, which makes a new one.
+        (HTMLFormElementImpl::parseAttribute): Ditto.
+        (HTMLInputElementImpl::attach): Fix a leak by using the style in the local
+	variable rather than calling styleForElement again.
+
+        * khtml/html/html_imageimpl.cpp:
+        (HTMLImageElementImpl::parseAttribute): Fix a leak by getting the style from the render
+	object instead of calling styleForElement again, which makes a new one.
+        (HTMLImageElementImpl::attach): Fix a leak by using the style in the local
+	variable rather than calling styleForElement again.
+
+        * khtml/html/html_inlineimpl.cpp: (HTMLBRElementImpl::attach):
+	Fix a leak in the display() == NONE case by ref'ing and deref'ing the style.
+
+        * khtml/html/html_objectimpl.cpp: (HTMLObjectElementImpl::attach): Fix a leak by using
+	the style in the local variable rather than calling styleForElement again.
+
+        * khtml/rendering/bidi.cpp:
+        (BidiIterator::detach): Added debugging code to detect if someone does a delete directly,
+	which will not deallocate the object because it won't run the correct arena code.
+        (BidiIterator::operator delete): Ditto.
+        (appendRunsForObject): Fix a leak by detaching bidi iterators when they are removed from
+	the list. The list can't delete them because it doesn't have the arena pointer.
+        (deleteMidpoints): Fix a leak by not removing the items from the list until done iterating.
+	The old code would fail to delete half the items.
+
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::detach): Detach the continuation here. Before we removed it but did not
+	detach it, which led to a leak.
+        (RenderContainer::removeChild): Do not remove the continuation here. If we do, then we can't
+	detach successfully. No one depends on this removing the continuation.
+        (RenderContainer::removeLeftoverAnonymousBoxes): Detach the child, don't just delete it.
+	This fixes a leak.
+
+        * khtml/rendering/render_flow.cpp: (RenderFlow::removeChild): Detach the child, don't just
+	delete it. This fixes a leak.
+
+        * khtml/rendering/render_object.h: Added arenaDelete.
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::operator delete): Added debugging code to detect if someone does a delete directly,
+	which will not deallocate the object because it won't run the correct arena code.
+        (RenderObject::detach): Ditto.
+        (RenderObject::arenaDelete): Put the low-level delete here, so that subclasses (RenderWidget)
+	can call it.
+
+        * khtml/rendering/render_replaced.h: Add arenaDeref and make deref private so derived classes
+	won't use it by accident.
+        * khtml/rendering/render_replaced.cpp:
+        (RenderWidget::detach): Use the new arenaDeref instead of deref, since we need to pass the
+	arena pointer in to delete.
+        (RenderWidget::resizeWidget): Ditto. Store the arena before calling back, since we can't get it
+	once it's detached from its parent.
+        (RenderWidget::eventFilter): Ditto.
+        (RenderWidget::arenaDeref): Added. Calls RenderObject's arenaDelete.
+
+	- other changes
+
+        * khtml/rendering/render_arena.cpp:
+        (RenderArena::allocate): Added debugging code that stores a signature, arena pointer, and size,
+	and uses malloc rather than the arena.
+        (RenderArena::free): Check the signature, arena pointer, and size, and use free.
+
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::operator delete): Added debugging code to detect if someone does a delete directly,
+	which will not deallocate the object because it won't run the correct arena code.
+        (RenderLayer::detach): Ditto.
+        (RenderLayer::RenderLayerElement::operator delete): Ditto.
+        (RenderLayer::RenderLayerElement::detach): Ditto.
+        (RenderLayer::RenderZTreeNode::operator delete): Ditto.
+        (RenderLayer::RenderZTreeNode::detach): Ditto.
+
+        * khtml/rendering/render_text.cpp:
+        (TextSlave::detach): Added debugging code to detect if someone does a delete directly,
+	which will not deallocate the object because it won't run the correct arena code.
+        (TextSlave::operator delete): Ditto.
+
+        * khtml/html/html_elementimpl.cpp: (HTMLElementImpl::createContextualFragment):
+	Save one new/delete by using a stack-based HTMLTokenizer and add FIXMEs about
+	some possible leaks I spotted here.
+
+        * khtml/rendering/render_list.cpp: (RenderListItem::setStyle): Took out APPLE_CHANGES from around
+	a generally useful bug fix.
+
+        * WebCore.pbproj/project.pbxproj: Let Electron be Electron. 
+
 === Alexander-42 ===
 
 2002-12-19  David Hyatt  <hyatt at apple.com>
diff --git a/WebCore/WebCore.pbproj/project.pbxproj b/WebCore/WebCore.pbproj/project.pbxproj
index 444d3ef..3d79d19 100644
--- a/WebCore/WebCore.pbproj/project.pbxproj
+++ b/WebCore/WebCore.pbproj/project.pbxproj
@@ -66,6 +66,7 @@
 				F58C8A07025BD3BC018635CA,
 				F531DDEC02F0C34D018635CA,
 			);
+			hasScannedForEncodings = 1;
 			isa = PBXProject;
 			knownRegions = (
 				English,
@@ -182,7 +183,6 @@
 </dict>
 </plist>
 ";
-			shouldUseHeadermap = 0;
 		};
 		0867D69DFE84028FC02AAC07 = {
 			buildActionMask = 2147483647;
diff --git a/WebCore/khtml/html/html_baseimpl.cpp b/WebCore/khtml/html/html_baseimpl.cpp
index 6963ec4..95c934c 100644
--- a/WebCore/khtml/html/html_baseimpl.cpp
+++ b/WebCore/khtml/html/html_baseimpl.cpp
@@ -504,11 +504,13 @@ void HTMLFrameSetElementImpl::attach()
     // ignore display: none but do pay attention if a stylesheet has caused us to delay
     // our loading.
     RenderStyle* style = getDocument()->styleSelector()->styleForElement(this);
+    style->ref();
     if (style->isStyleAvailable()) {
         m_render = new (getDocument()->renderArena()) RenderFrameSet(this);
         m_render->setStyle(style);
         parentNode()->renderer()->addChild(m_render, nextRenderer());
     }
+    style->deref();
     
     NodeBaseImpl::attach();
 }
diff --git a/WebCore/khtml/html/html_elementimpl.cpp b/WebCore/khtml/html/html_elementimpl.cpp
index add1fa5..c7642b1 100644
--- a/WebCore/khtml/html/html_elementimpl.cpp
+++ b/WebCore/khtml/html/html_elementimpl.cpp
@@ -316,11 +316,12 @@ DocumentFragmentImpl *HTMLElementImpl::createContextualFragment( const DOMString
         return NULL;
 
     DocumentFragmentImpl *fragment = new DocumentFragmentImpl( docPtr() );
-    HTMLTokenizer *tok = new HTMLTokenizer( docPtr(), fragment );
-    tok->begin();
-    tok->write( html.string(), true );
-    tok->end();
-    delete tok;
+    {
+        HTMLTokenizer tok( docPtr(), fragment );
+        tok.begin();
+        tok.write( html.string(), true );
+        tok.end();
+    }
 
     // Exceptions are ignored because none ought to happen here.
     int ignoredExceptionCode;
@@ -336,20 +337,24 @@ DocumentFragmentImpl *HTMLElementImpl::createContextualFragment( const DOMString
 	    NodeImpl *child = firstChild; 
 	    while (child != NULL) {
 		NodeImpl *nextChild = child->nextSibling();
-		fragment->insertBefore (child, node, ignoredExceptionCode);
+		fragment->insertBefore(child, node, ignoredExceptionCode);
+                // FIXME: Does node leak here?
 		child = nextChild;
 	    }
 	    if (firstChild == NULL) {
 		NodeImpl *nextNode = node->nextSibling();
 		fragment->removeChild(node, ignoredExceptionCode);
-		node = nextNode;
+                // FIXME: Does node leak here?
+                node = nextNode;
 	    } else {
 		fragment->removeChild(node, ignoredExceptionCode);
+                // FIXME: Does node leak here?
 		node = firstChild;
 	    }
 	} else if (node->id() == ID_HEAD) {
 	    NodeImpl *nextNode = node->nextSibling();
 	    fragment->removeChild(node, ignoredExceptionCode);
+            // FIXME: Does node leak here?
 	    node = nextNode;
 	} else {
 	    node = node->nextSibling();
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index d815177..d8ffc48 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -92,15 +92,13 @@ NodeImpl::Id HTMLFormElementImpl::id() const
 
 void HTMLFormElementImpl::attach()
 {
-    RenderStyle* style = getDocument()->styleSelector()->styleForElement(this);
+    HTMLElementImpl::attach();
 
-    if (style->display() != NONE && getDocument()->isHTMLDocument()) {
+    if (m_render && getDocument()->isHTMLDocument()) {
 	HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
 	document->addNamedImageOrForm(oldNameAttr);
 	document->addNamedImageOrForm(oldIdAttr);
     }
-
-    HTMLElementImpl::attach();
 }
 
 void HTMLFormElementImpl::detach()
@@ -533,11 +531,7 @@ void HTMLFormElementImpl::parseAttribute(AttributeImpl *attr)
     case ATTR_NAME:
 	{
 	    QString newNameAttr = attr->value().string();
-	    
-	    if (attached() && 
-		getDocument()->isHTMLDocument() &&
-		getDocument()->styleSelector()->styleForElement(this)->display() != NONE) {
-		
+	    if (m_render && getDocument()->isHTMLDocument()) {
 		HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
 		document->removeNamedImageOrForm(oldNameAttr);
 		document->addNamedImageOrForm(newNameAttr);
@@ -548,11 +542,7 @@ void HTMLFormElementImpl::parseAttribute(AttributeImpl *attr)
     case ATTR_ID:
 	{
 	    QString newIdAttr = attr->value().string();
-	    
-	    if (attached() && 
-		getDocument()->isHTMLDocument() &&
-		getDocument()->styleSelector()->styleForElement(this)->display() != NONE) {
-		
+	    if (m_render && getDocument()->isHTMLDocument()) {
 		HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
 		document->removeNamedImageOrForm(oldIdAttr);
 		document->addNamedImageOrForm(newIdAttr);
@@ -1243,26 +1233,26 @@ void HTMLInputElementImpl::attach()
         {
         case TEXT:
         case PASSWORD:
-        case ISINDEX:      m_render = new (arena) RenderLineEdit(this);   break;
-        case CHECKBOX:  m_render = new (arena) RenderCheckBox(this); break;
-        case RADIO:        m_render = new (arena) RenderRadioButton(this); break;
-        case SUBMIT:      m_render = new (arena) RenderSubmitButton(this); break;
+        case ISINDEX:  m_render = new (arena) RenderLineEdit(this);     break;
+        case CHECKBOX: m_render = new (arena) RenderCheckBox(this);     break;
+        case RADIO:    m_render = new (arena) RenderRadioButton(this);  break;
+        case SUBMIT:   m_render = new (arena) RenderSubmitButton(this); break;
         case IMAGE: {
              DOMString width = getAttribute( ATTR_WIDTH );
              if (!width.isEmpty()) {
                 addCSSLength(CSS_PROP_WIDTH, width);
              }
              m_render =  new (arena) RenderImageButton(this);
-             m_render->setStyle(getDocument()->styleSelector()->styleForElement(this));
+             m_render->setStyle(_style);
              parentNode()->renderer()->addChild(m_render, nextRenderer());
              m_render->updateFromElement();
              NodeBaseImpl::attach();
              _style->deref();
              return;
         }
-        case RESET:      m_render = new (arena) RenderResetButton(this);   break;
-        case FILE:         m_render =  new (arena) RenderFileButton(this);    break;
-        case BUTTON:  m_render = new (arena) RenderPushButton(this);
+        case RESET:    m_render = new (arena) RenderResetButton(this);  break;
+        case FILE:     m_render = new (arena) RenderFileButton(this);   break;
+        case BUTTON:   m_render = new (arena) RenderPushButton(this);   break;
         case HIDDEN:   break;
         }
     }
diff --git a/WebCore/khtml/html/html_imageimpl.cpp b/WebCore/khtml/html/html_imageimpl.cpp
index 74f434d..b4fc098 100644
--- a/WebCore/khtml/html/html_imageimpl.cpp
+++ b/WebCore/khtml/html/html_imageimpl.cpp
@@ -138,27 +138,18 @@ void HTMLImageElementImpl::parseAttribute(AttributeImpl *attr)
     case ATTR_NAME:
 	{
 	    QString newNameAttr = attr->value().string();
-	    
-	    if (attached() && 
-		getDocument()->isHTMLDocument() &&
-		getDocument()->styleSelector()->styleForElement(this)->display() != NONE) {
-		
+	    if (m_render && getDocument()->isHTMLDocument()) {
 		HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
 		document->removeNamedImageOrForm(oldNameAttr);
 		document->addNamedImageOrForm(newNameAttr);
 	    }
-	    
 	    oldNameAttr = newNameAttr;
 	}
 	break;
     case ATTR_ID:
 	{
 	    QString newIdAttr = attr->value().string();
-	    
-	    if (attached() && 
-		getDocument()->isHTMLDocument() &&
-		getDocument()->styleSelector()->styleForElement(this)->display() != NONE) {
-		
+	    if (m_render && getDocument()->isHTMLDocument()) {
 		HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
 		document->removeNamedImageOrForm(oldIdAttr);
 		document->addNamedImageOrForm(newIdAttr);
@@ -201,9 +192,10 @@ void HTMLImageElementImpl::attach()
 
     RenderStyle* _style = getDocument()->styleSelector()->styleForElement(this);
     _style->ref();
+
     if (parentNode()->renderer() && _style->display() != NONE) {
         m_render = new (getDocument()->renderArena()) RenderImage(this);
-        m_render->setStyle(getDocument()->styleSelector()->styleForElement(this));
+        m_render->setStyle(_style);
         parentNode()->renderer()->addChild(m_render, nextRenderer());
         m_render->updateFromElement();
     }
@@ -213,6 +205,7 @@ void HTMLImageElementImpl::attach()
 	document->addNamedImageOrForm(oldIdAttr);
 	document->addNamedImageOrForm(oldNameAttr);
     }
+
     _style->deref();
 
     NodeBaseImpl::attach();
diff --git a/WebCore/khtml/html/html_inlineimpl.cpp b/WebCore/khtml/html/html_inlineimpl.cpp
index d96e4a3..3055234 100644
--- a/WebCore/khtml/html/html_inlineimpl.cpp
+++ b/WebCore/khtml/html/html_inlineimpl.cpp
@@ -223,11 +223,13 @@ void HTMLBRElementImpl::attach()
     RenderObject *parentRenderer = parentNode()->renderer();
     if (parentRenderer) {
         RenderStyle *style = getDocument()->styleSelector()->styleForElement(this);
+        style->ref();
         if (style->display() != NONE) {
             m_render = new (getDocument()->renderArena()) RenderBR(this);
             m_render->setStyle(style);
             parentRenderer->addChild(m_render, nextRenderer());
         }
+        style->deref();
     }
     
     NodeImpl::attach();
diff --git a/WebCore/khtml/html/html_objectimpl.cpp b/WebCore/khtml/html/html_objectimpl.cpp
index 4f1323a..a1bae96 100644
--- a/WebCore/khtml/html/html_objectimpl.cpp
+++ b/WebCore/khtml/html/html_objectimpl.cpp
@@ -343,7 +343,7 @@ void HTMLObjectElementImpl::attach()
     
     if(serviceType.startsWith("image/") && parentNode()->renderer() && _style->display() != NONE){
         m_render = new (getDocument()->renderArena()) RenderImage(this);
-        m_render->setStyle(getDocument()->styleSelector()->styleForElement(this));
+        m_render->setStyle(_style);
         parentNode()->renderer()->addChild(m_render, nextRenderer());
         m_render->updateFromElement();
         loadplugin = false;
diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp
index 1ca0279..984699a 100644
--- a/WebCore/khtml/rendering/bidi.cpp
+++ b/WebCore/khtml/rendering/bidi.cpp
@@ -55,13 +55,22 @@ static int numSpaces;
 static void embed( QChar::Direction d );
 static void appendRun();
 
+#ifndef NDEBUG
+static bool inBidiIteratorDetach;
+#endif
+
 void BidiIterator::detach(RenderArena* renderArena)
 {
+#ifndef NDEBUG
+    inBidiIteratorDetach = true;
+#endif
     delete this;
+#ifndef NDEBUG
+    inBidiIteratorDetach = false;
+#endif
     
-    // Now perform the destroy.
-    size_t* sz = (size_t*)this;
-    renderArena->free(*sz, (void*)this);
+    // Recover the size left there for us by operator delete and free the memory.
+    renderArena->free(*(size_t *)this, this);
 }
 
 void* BidiIterator::operator new(size_t sz, RenderArena* renderArena) throw()
@@ -69,9 +78,12 @@ void* BidiIterator::operator new(size_t sz, RenderArena* renderArena) throw()
     return renderArena->allocate(sz);
 }
 
-void BidiIterator::operator delete(void* ptr, size_t sz) {
-    size_t* szPtr = (size_t*)ptr;
-    *szPtr = sz;
+void BidiIterator::operator delete(void* ptr, size_t sz)
+{
+    assert(inBidiIteratorDetach);
+
+    // Stash size where detach can find it.
+    *(size_t*)ptr = sz;
 }
 
 // ---------------------------------------------------------------------
@@ -264,6 +276,7 @@ static void appendRunsForObject(int start, int end, RenderObject* obj)
         betweenMidpoints = false;
         start = nextMidpoint->pos;
         smidpoints->removeFirst(); // Delete the midpoint.
+        nextMidpoint->detach(obj->renderArena());
         if (start < end)
             return appendRunsForObject(start, end, obj);
     }
@@ -280,6 +293,7 @@ static void appendRunsForObject(int start, int end, RenderObject* obj)
             betweenMidpoints = true;
             int nextPos = nextMidpoint->pos+1;
             smidpoints->removeFirst();
+            nextMidpoint->detach(obj->renderArena());
             return appendRunsForObject(nextPos, end, obj);
         }
         else
@@ -985,8 +999,8 @@ static void deleteMidpoints(RenderArena* arena, QPtrList<BidiIterator>* midpoint
         BidiIterator* s = midpoints->at(i);
         if (s)
             s->detach(arena);
-        midpoints->remove(i);
     }
+    midpoints->clear();
 }
 
 void RenderFlow::layoutInlineChildren(bool relayoutChildren)
diff --git a/WebCore/khtml/rendering/render_arena.cpp b/WebCore/khtml/rendering/render_arena.cpp
index 5059918..0f503f9 100644
--- a/WebCore/khtml/rendering/render_arena.cpp
+++ b/WebCore/khtml/rendering/render_arena.cpp
@@ -34,6 +34,18 @@
 
 #include "render_arena.h"
 
+#ifndef NDEBUG
+
+const int signature = 0xDBA00AEA;
+
+typedef struct {
+    RenderArena *arena;
+    size_t size;
+    int signature;
+} RenderArenaDebugHeader;
+
+#endif
+
 RenderArena::RenderArena(unsigned int arenaSize)
 {
     // Initialize the arena pool
@@ -51,6 +63,15 @@ RenderArena::~RenderArena()
 
 void* RenderArena::allocate(size_t size)
 {
+#ifndef NDEBUG
+    // Use standard malloc so that memory debugging tools work.
+    void *block = ::malloc(sizeof(RenderArenaDebugHeader) + size);
+    RenderArenaDebugHeader *header = (RenderArenaDebugHeader *)block;
+    header->arena = this;
+    header->size = size;
+    header->signature = signature;
+    return header + 1;
+#else
     void* result = 0;
 
     // Ensure we have correct alignment for pointers.  Important for Tru64
@@ -74,18 +95,19 @@ void* RenderArena::allocate(size_t size)
     }
 
     return result;
+#endif
 }
 
 void RenderArena::free(size_t size, void* ptr)
 {
-#if APPLE_CHANGES
 #ifndef NDEBUG
-    // Mark the memory with 0xdd in DEBUG builds so that there will be
-    // problems if someone tries to access memory that they've freed.
-    memset(ptr, 0xdd, size);
-#endif
-#endif
-
+    // Use standard free so that memory debugging tools work.
+    RenderArenaDebugHeader *header = (RenderArenaDebugHeader *)ptr - 1;
+    assert(header->signature == signature);
+    assert(header->size == size);
+    assert(header->arena == this);
+    ::free(header);
+#else
     // Ensure we have correct alignment for pointers.  Important for Tru64
     size = ROUNDUP(size, sizeof(void*));
 
@@ -96,4 +118,5 @@ void RenderArena::free(size_t size, void* ptr)
         m_recyclers[index] = ptr;
         *((void**)ptr) = currentTop;
     }
+#endif
 }
diff --git a/WebCore/khtml/rendering/render_container.cpp b/WebCore/khtml/rendering/render_container.cpp
index 73f5059..ceffc89 100644
--- a/WebCore/khtml/rendering/render_container.cpp
+++ b/WebCore/khtml/rendering/render_container.cpp
@@ -50,6 +50,9 @@ RenderContainer::~RenderContainer()
 
 void RenderContainer::detach(RenderArena* renderArena)
 {
+    if (continuation())
+        continuation()->detach(renderArena);
+    
     RenderObject* next;
     for(RenderObject* n = m_first; n; n = next ) {
         n->removeFromSpecialObjects();
@@ -191,9 +194,6 @@ RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild)
 
 void RenderContainer::removeChild(RenderObject *oldChild)
 {
-    if (oldChild->continuation())
-        oldChild->continuation()->parent()->removeChild(oldChild->continuation());
-    
     removeChildNode(oldChild);
     setLayouted(false);
 }
@@ -355,7 +355,7 @@ void RenderContainer::removeLeftoverAnonymousBoxes()
 		c->m_first = 0;
 		c->m_next = 0;
 	    }
-	    delete child;
+	    child->detach(renderArena());
 	}
 	child = next;
     }
diff --git a/WebCore/khtml/rendering/render_flow.cpp b/WebCore/khtml/rendering/render_flow.cpp
index f6d647d..b91cd0f 100644
--- a/WebCore/khtml/rendering/render_flow.cpp
+++ b/WebCore/khtml/rendering/render_flow.cpp
@@ -2238,7 +2238,7 @@ void RenderFlow::removeChild(RenderObject *oldChild)
         prev->setMinMaxKnown(false);
         
         // Nuke the now-empty block.
-        removeChild(next);
+        next->detach(renderArena());
         
         mergedBlocks = true;
     }
diff --git a/WebCore/khtml/rendering/render_layer.cpp b/WebCore/khtml/rendering/render_layer.cpp
index b9faf75..fbf48aa 100644
--- a/WebCore/khtml/rendering/render_layer.cpp
+++ b/WebCore/khtml/rendering/render_layer.cpp
@@ -52,6 +52,12 @@
 using namespace DOM;
 using namespace khtml;
 
+#ifndef NDEBUG
+static bool inRenderLayerDetach;
+static bool inRenderLayerElementDetach;
+static bool inRenderZTreeNodeDetach;
+#endif
+
 RenderLayer::RenderLayer(RenderObject* object)
 : m_object( object ),
 m_parent( 0 ),
@@ -116,19 +122,26 @@ void* RenderLayer::operator new(size_t sz, RenderArena* renderArena) throw()
     return renderArena->allocate(sz);
 }
 
-void RenderLayer::operator delete(void* ptr, size_t sz) {
-    size_t* szPtr = (size_t*)ptr;
-    *szPtr = sz;
+void RenderLayer::operator delete(void* ptr, size_t sz)
+{
+    assert(inRenderLayerDetach);
+    
+    // Stash size where detach can find it.
+    *(size_t *)ptr = sz;
 }
 
 void RenderLayer::detach(RenderArena* renderArena)
 {
+#ifndef NDEBUG
+    inRenderLayerDetach = true;
+#endif
     delete this;
+#ifndef NDEBUG
+    inRenderLayerDetach = false;
+#endif
     
-    
-    // Now perform the destroy.
-    size_t* sz = (size_t*)this;
-    renderArena->free(*sz, (void*)this);
+    // Recover the size left there for us by operator delete and free the memory.
+    renderArena->free(*(size_t *)this, this);
 }
 
 void RenderLayer::addChild(RenderLayer *child)
@@ -598,18 +611,26 @@ void* RenderLayer::RenderLayerElement::operator new(size_t sz, RenderArena* rend
     return result;
 }
 
-void RenderLayer::RenderLayerElement::operator delete(void* ptr, size_t sz) {
-    size_t* szPtr = (size_t*)ptr;
-    *szPtr = sz;
+void RenderLayer::RenderLayerElement::operator delete(void* ptr, size_t sz)
+{
+    assert(inRenderLayerElementDetach);
+    
+    // Stash size where detach can find it.
+    *(size_t *)ptr = sz;
 }
 
 void RenderLayer::RenderLayerElement::detach(RenderArena* renderArena)
 {
+#ifndef NDEBUG
+    inRenderLayerElementDetach = true;
+#endif
     delete this;
+#ifndef NDEBUG
+    inRenderLayerElementDetach = false;
+#endif
     
-    // Now perform the destroy.
-    size_t* sz = (size_t*)this;
-    renderArena->free(*sz, (void*)this);
+    // Recover the size left there for us by operator delete and free the memory.
+    renderArena->free(*(size_t *)this, this);
 }
 
 void* RenderLayer::RenderZTreeNode::operator new(size_t sz, RenderArena* renderArena) throw()
@@ -620,9 +641,12 @@ void* RenderLayer::RenderZTreeNode::operator new(size_t sz, RenderArena* renderA
     return result;
 }
 
-void RenderLayer::RenderZTreeNode::operator delete(void* ptr, size_t sz) {
-    size_t* szPtr = (size_t*)ptr;
-    *szPtr = sz;
+void RenderLayer::RenderZTreeNode::operator delete(void* ptr, size_t sz)
+{
+    assert(inRenderZTreeNodeDetach);
+    
+    // Stash size where detach can find it.
+    *(size_t *)ptr = sz;
 }
 
 void RenderLayer::RenderZTreeNode::detach(RenderArena* renderArena)
@@ -634,10 +658,15 @@ void RenderLayer::RenderZTreeNode::detach(RenderArena* renderArena)
     if (layerElement)
         layerElement->detach(renderArena);
 
+#ifndef NDEBUG
+    inRenderZTreeNodeDetach = true;
+#endif
     delete this;
+#ifndef NDEBUG
+    inRenderZTreeNodeDetach = false;
+#endif
     
-    // Now perform the destroy.
-    size_t* sz = (size_t*)this;
-    renderArena->free(*sz, (void*)this);
+    // Recover the size left there for us by operator delete and free the memory.
+    renderArena->free(*(size_t *)this, this);
 }
 
diff --git a/WebCore/khtml/rendering/render_list.cpp b/WebCore/khtml/rendering/render_list.cpp
index a4451c0..ddd26c0 100644
--- a/WebCore/khtml/rendering/render_list.cpp
+++ b/WebCore/khtml/rendering/render_list.cpp
@@ -135,10 +135,7 @@ void RenderListItem::setStyle(RenderStyle *_style)
     RenderFlow::setStyle(_style);
 
     RenderStyle *newStyle = new RenderStyle();
-    
-#if APPLE_CHANGES
     newStyle->ref();
-#endif
     
     newStyle->inheritFrom(style());
    
@@ -154,9 +151,7 @@ void RenderListItem::setStyle(RenderStyle *_style)
         m_marker->setStyle(newStyle);
     }
 
-#if APPLE_CHANGES
     newStyle->deref();
-#endif
 }
 
 RenderListItem::~RenderListItem()
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index 090f229..1975ba4 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -39,14 +39,21 @@
 using namespace DOM;
 using namespace khtml;
 
+#ifndef NDEBUG
+static void *baseOfRenderObjectBeingDeleted;
+#endif
+
 void* RenderObject::operator new(size_t sz, RenderArena* renderArena) throw()
 {
     return renderArena->allocate(sz);
 }
 
-void RenderObject::operator delete(void* ptr, size_t sz) {
-    size_t* szPtr = (size_t*)ptr;
-    *szPtr = sz;
+void RenderObject::operator delete(void* ptr, size_t sz)
+{
+    assert(baseOfRenderObjectBeingDeleted == ptr);
+    
+    // Stash size where detach can find it.
+    *(size_t *)ptr = sz;
 }
 
 RenderObject *RenderObject::createObject(DOM::NodeImpl* node,  RenderStyle* style)
@@ -981,11 +988,27 @@ void RenderObject::detach(RenderArena* renderArena)
     m_next = m_previous = 0;
     
     // by default no refcounting
+    arenaDelete(renderArena, this);
+}
+
+void RenderObject::arenaDelete(RenderArena *arena, void *base)
+{
+#ifndef NDEBUG
+    void *savedBase = baseOfRenderObjectBeingDeleted;
+    baseOfRenderObjectBeingDeleted = base;
+#endif
     delete this;
+#ifndef NDEBUG
+    baseOfRenderObjectBeingDeleted = savedBase;
+#endif
     
-    // Now perform the destroy.
-    size_t* sz = (size_t*)this;
-    renderArena->free(*sz, (void*)this);
+    // Recover the size left there for us by operator delete and free the memory.
+    arena->free(*(size_t *)base, base);
+}
+
+void RenderObject::arenaDelete(RenderArena *arena)
+{
+    arenaDelete(arena, dynamic_cast<void *>(this));
 }
 
 FindSelectionResult RenderObject::checkSelectionPoint( const khtml::MouseEvent *event, int _tx, int _ty, DOM::NodeImpl*& node, int & offset )
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index 4d8d12b..91d35bc 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -544,6 +544,8 @@ protected:
 
     virtual void removeLeftoverAnonymousBoxes();
     
+    void arenaDelete(RenderArena *arena);
+
 private:
     RenderStyle* m_style;
     DOM::NodeImpl* m_node;
@@ -574,6 +576,8 @@ private:
     bool m_hasFirstLine              : 1;
     bool m_isSelectionBorder          : 1;
 
+    void arenaDelete(RenderArena *arena, void *objectBase);
+
     // note: do not add unnecessary bitflags, we have 32 bit already!
     friend class RenderListItem;
     friend class RenderContainer;
diff --git a/WebCore/khtml/rendering/render_replaced.cpp b/WebCore/khtml/rendering/render_replaced.cpp
index 02ef07d..80a8f29 100644
--- a/WebCore/khtml/rendering/render_replaced.cpp
+++ b/WebCore/khtml/rendering/render_replaced.cpp
@@ -145,7 +145,7 @@ void RenderWidget::detach(RenderArena* renderArena)
         m_widget->setMouseTracking( false );
     }
     
-    deref();
+    arenaDeref(renderArena);
 }
 
 RenderWidget::~RenderWidget()
@@ -164,11 +164,12 @@ void  RenderWidget::resizeWidget( QWidget *widget, int w, int h )
 #endif
 
     if (widget->width() != w || widget->height() != h) {
+        RenderArena *arena = renderArena();
         ref();
         element()->ref();
         widget->resize( w, h );
         element()->deref();
-        deref();
+        arenaDeref(arena);
     }
 }
 
@@ -299,6 +300,7 @@ bool RenderWidget::eventFilter(QObject* /*o*/, QEvent* e)
 {
     if ( !element() ) return true;
 
+    RenderArena *arena = renderArena();
     ref();
     element()->ref();
 
@@ -394,11 +396,16 @@ bool RenderWidget::eventFilter(QObject* /*o*/, QEvent* e)
     // stop processing if the widget gets deleted, but continue in all other cases
     if (hasOneRef())
         filtered = true;
-    deref();
+    arenaDeref(arena);
 
     return filtered;
 }
 
+void RenderWidget::arenaDeref(RenderArena *arena)
+{
+    if (_ref) _ref--; 
+    if (!_ref)
+        arenaDelete(arena);
+}
 
 #include "render_replaced.moc"
-
diff --git a/WebCore/khtml/rendering/render_replaced.h b/WebCore/khtml/rendering/render_replaced.h
index a67857a..5083177 100644
--- a/WebCore/khtml/rendering/render_replaced.h
+++ b/WebCore/khtml/rendering/render_replaced.h
@@ -82,6 +82,7 @@ public:
     QWidget *widget() const { return m_widget; }
     KHTMLView* view() const { return m_view; }
 
+    void arenaDeref(RenderArena *arena);
 
 public slots:
     void slotWidgetDestructed();
@@ -93,6 +94,9 @@ protected:
 
     QWidget *m_widget;
     KHTMLView* m_view;
+
+private:
+    using khtml::Shared<RenderWidget>::deref;
 };
 
 };
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index 621a9ff..500ad22 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -41,13 +41,22 @@
 using namespace khtml;
 using namespace DOM;
 
+#ifndef NDEBUG
+static bool inTextSlaveDetach;
+#endif
+
 void TextSlave::detach(RenderArena* renderArena)
 {
+#ifndef NDEBUG
+    inTextSlaveDetach = true;
+#endif
     delete this;
+#ifndef NDEBUG
+    inTextSlaveDetach = false;
+#endif
     
-    // Now perform the destroy.
-    size_t* sz = (size_t*)this;
-    renderArena->free(*sz, (void*)this);
+    // Recover the size left there for us by operator delete and free the memory.
+    renderArena->free(*(size_t *)this, this);
 }
 
 void* TextSlave::operator new(size_t sz, RenderArena* renderArena) throw()
@@ -55,9 +64,12 @@ void* TextSlave::operator new(size_t sz, RenderArena* renderArena) throw()
     return renderArena->allocate(sz);
 }
 
-void TextSlave::operator delete(void* ptr, size_t sz) {
-    size_t* szPtr = (size_t*)ptr;
-    *szPtr = sz;
+void TextSlave::operator delete(void* ptr, size_t sz)
+{
+    assert(inTextSlaveDetach);
+    
+    // Stash size where detach can find it.
+    *(size_t *)ptr = sz;
 }
 
 void TextSlave::paintSelection(const Font *f, RenderText *text, QPainter *p, RenderStyle* style, int tx, int ty, int startPos, int endPos)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list