[webkit-changes] cvs commit: WebCore/khtml/xml dom2_rangeimpl.cpp

Darin darin at opensource.apple.com
Wed Aug 31 08:36:14 PDT 2005


darin       05/08/31 08:36:13

  Modified:    .        ChangeLog
               khtml/html html_elementimpl.cpp html_formimpl.cpp
                        html_tableimpl.cpp
               khtml/xml dom2_rangeimpl.cpp
  Log:
          Reviewed by Maciej.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4766
            many callers of removeChild are leaking the removed node
  
          * khtml/html/html_elementimpl.cpp:
          (HTMLElementImpl::setOuterText): Added ref/deref around removeChild call.
          * khtml/html/html_formimpl.cpp:
          (DOM::HTMLSelectElementImpl::remove): Ditto.
          (DOM::HTMLTextAreaElementImpl::setDefaultValue): Ditto.
          * khtml/html/html_tableimpl.cpp:
          (DOM::HTMLTableElementImpl::deleteTHead): Ditto.
          (DOM::HTMLTableElementImpl::deleteTFoot): Ditto.
          (DOM::HTMLTableElementImpl::deleteCaption): Ditto.
          (DOM::HTMLTableSectionElementImpl::deleteRow): Ditto.
          (DOM::HTMLTableRowElementImpl::deleteCell): Ditto.
          * khtml/xml/dom2_rangeimpl.cpp:
          (DOM::RangeImpl::processContents): Ditto.
          (DOM::RangeImpl::surroundContents): Ditto.
  
  Revision  Changes    Path
  1.55      +22 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- ChangeLog	31 Aug 2005 09:46:51 -0000	1.54
  +++ ChangeLog	31 Aug 2005 15:36:11 -0000	1.55
  @@ -1,3 +1,25 @@
  +2005-08-31  Darin Adler  <darin at apple.com>
  +
  +        Reviewed by Maciej.
  +
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4766
  +          many callers of removeChild are leaking the removed node
  +
  +        * khtml/html/html_elementimpl.cpp:
  +        (HTMLElementImpl::setOuterText): Added ref/deref around removeChild call.
  +        * khtml/html/html_formimpl.cpp:
  +        (DOM::HTMLSelectElementImpl::remove): Ditto.
  +        (DOM::HTMLTextAreaElementImpl::setDefaultValue): Ditto.
  +        * khtml/html/html_tableimpl.cpp:
  +        (DOM::HTMLTableElementImpl::deleteTHead): Ditto.
  +        (DOM::HTMLTableElementImpl::deleteTFoot): Ditto.
  +        (DOM::HTMLTableElementImpl::deleteCaption): Ditto.
  +        (DOM::HTMLTableSectionElementImpl::deleteRow): Ditto.
  +        (DOM::HTMLTableRowElementImpl::deleteCell): Ditto.
  +        * khtml/xml/dom2_rangeimpl.cpp:
  +        (DOM::RangeImpl::processContents): Ditto.
  +        (DOM::RangeImpl::surroundContents): Ditto.
  +
   2005-08-31  Maciej Stachowiak  <mjs at apple.com>
   
           Reviewed by Anders.
  
  
  
  1.103     +2 -0      WebCore/khtml/html/html_elementimpl.cpp
  
  Index: html_elementimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_elementimpl.cpp,v
  retrieving revision 1.102
  retrieving revision 1.103
  diff -u -r1.102 -r1.103
  --- html_elementimpl.cpp	31 Aug 2005 04:38:38 -0000	1.102
  +++ html_elementimpl.cpp	31 Aug 2005 15:36:12 -0000	1.103
  @@ -432,7 +432,9 @@
   	textPrev->appendData(t->data(), exception);
           if (exception)
               return;
  +        t->ref();
   	t->parentNode()->removeChild(t, exception);
  +        t->deref();
           if (exception)
               return;
   	t = textPrev;
  
  
  
  1.190     +8 -2      WebCore/khtml/html/html_formimpl.cpp
  
  Index: html_formimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.cpp,v
  retrieving revision 1.189
  retrieving revision 1.190
  diff -u -r1.189 -r1.190
  --- html_formimpl.cpp	31 Aug 2005 04:38:38 -0000	1.189
  +++ html_formimpl.cpp	31 Aug 2005 15:36:12 -0000	1.190
  @@ -2824,7 +2824,10 @@
       if(listIndex < 0 || index >= int(items.size()))
           return; // ### what should we do ? remove the last item?
   
  -    removeChild(items[listIndex], exceptioncode);
  +    NodeImpl *item = items[listIndex];
  +    item->ref();
  +    removeChild(item, exceptioncode);
  +    item->deref();
       if( !exceptioncode )
           setRecalcListItems();
   }
  @@ -3674,7 +3677,10 @@
       QPtrListIterator<NodeImpl> it(toRemove);
       int exceptioncode = 0;
       for (; it.current(); ++it) {
  -        removeChild(it.current(), exceptioncode);
  +        NodeImpl *n = it.current();
  +        n->ref();
  +        removeChild(n, exceptioncode);
  +        n->deref();
       }
       insertBefore(getDocument()->createTextNode(defaultValue),firstChild(), exceptioncode);
       setValue(defaultValue);
  
  
  
  1.62      +18 -6     WebCore/khtml/html/html_tableimpl.cpp
  
  Index: html_tableimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_tableimpl.cpp,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- html_tableimpl.cpp	29 Aug 2005 17:42:43 -0000	1.61
  +++ html_tableimpl.cpp	31 Aug 2005 15:36:12 -0000	1.62
  @@ -170,7 +170,9 @@
   {
       if(head) {
           int exceptioncode = 0;
  +        head->ref();
           HTMLElementImpl::removeChild(head, exceptioncode);
  +        head->deref();
       }
       head = 0;
   }
  @@ -193,7 +195,9 @@
   {
       if(foot) {
           int exceptioncode = 0;
  +        foot->ref();
           HTMLElementImpl::removeChild(foot, exceptioncode);
  +        foot->deref();
       }
       foot = 0;
   }
  @@ -213,7 +217,9 @@
   {
       if(tCaption) {
           int exceptioncode = 0;
  +        tCaption->ref();
           HTMLElementImpl::removeChild(tCaption, exceptioncode);
  +        tCaption->deref();
       }
       tCaption = 0;
   }
  @@ -834,9 +840,12 @@
       SharedPtr<NodeListImpl> children = childNodes();
       int numRows = children.notNull() ? (int)children->length() : 0;
       if ( index == -1 ) index = numRows - 1;
  -    if( index >= 0 && index < numRows )
  -        HTMLElementImpl::removeChild(children->item(index), exceptioncode);
  -    else
  +    if( index >= 0 && index < numRows ) {
  +        NodeImpl *row = children->item(index);
  +        row->ref();
  +        HTMLElementImpl::removeChild(row, exceptioncode);
  +        row->deref();
  +    } else
           exceptioncode = DOMException::INDEX_SIZE_ERR;
   }
   
  @@ -1002,9 +1011,12 @@
       SharedPtr<NodeListImpl> children = childNodes();
       int numCells = children.notNull() ? children->length() : 0;
       if ( index == -1 ) index = numCells-1;
  -    if( index >= 0 && index < numCells )
  -        HTMLElementImpl::removeChild(children->item(index), exceptioncode);
  -    else
  +    if( index >= 0 && index < numCells ) {
  +        NodeImpl *row = children->item(index);
  +        row->ref();
  +        HTMLElementImpl::removeChild(row, exceptioncode);
  +        row->deref();
  +    } else
           exceptioncode = DOMException::INDEX_SIZE_ERR;
   }
   
  
  
  
  1.43      +28 -8     WebCore/khtml/xml/dom2_rangeimpl.cpp
  
  Index: dom2_rangeimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom2_rangeimpl.cpp,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- dom2_rangeimpl.cpp	25 Aug 2005 17:47:20 -0000	1.42
  +++ dom2_rangeimpl.cpp	31 Aug 2005 15:36:13 -0000	1.43
  @@ -479,8 +479,11 @@
                       fragment->appendChild(n,exceptioncode); // will remove n from it's parent
                   else if (action == CLONE_CONTENTS)
                       fragment->appendChild(n->cloneNode(true),exceptioncode);
  -                else
  +                else {
  +                    n->ref();
                       m_startContainer->removeChild(n,exceptioncode);
  +                    n->deref();
  +                }
                   n = next;
                   i++;
               }
  @@ -540,8 +543,11 @@
                       leftContents->appendChild(n,exceptioncode); // will remove n from m_startContainer
                   else if (action == CLONE_CONTENTS)
                       leftContents->appendChild(n->cloneNode(true),exceptioncode);
  -                else
  +                else {
  +                    n->ref();
                       m_startContainer->removeChild(n,exceptioncode);
  +                    n->deref();
  +                }
                   n = next;
               }
           }
  @@ -562,8 +568,11 @@
                       leftContents->appendChild(n,exceptioncode); // will remove n from leftParent
                   else if (action == CLONE_CONTENTS)
                       leftContents->appendChild(n->cloneNode(true),exceptioncode);
  -                else
  +                else {
  +                    n->ref();
                       leftParent->removeChild(n,exceptioncode);
  +                    n->deref();
  +                }
               }
               n = leftParent->nextSibling();
           }
  @@ -607,8 +616,11 @@
                           rightContents->insertBefore(n,rightContents->firstChild(),exceptioncode); // will remove n from it's parent
                       else if (action == CLONE_CONTENTS)
                           rightContents->insertBefore(n->cloneNode(true),rightContents->firstChild(),exceptioncode);
  -                    else
  +                    else {
  +                        n->ref();
                           m_endContainer->removeChild(n,exceptioncode);
  +                        n->deref();
  +                    }
                   }
               }
           }
  @@ -629,8 +641,11 @@
                       rightContents->insertBefore(n,rightContents->firstChild(),exceptioncode); // will remove n from it's parent
                   else if (action == CLONE_CONTENTS)
                       rightContents->insertBefore(n->cloneNode(true),rightContents->firstChild(),exceptioncode);
  -                else
  +                else {
  +                    n->ref();
                       rightParent->removeChild(n,exceptioncode);
  +                    n->deref();
  +                }
   
               }
               n = rightParent->previousSibling();
  @@ -681,8 +696,11 @@
                   fragment->appendChild(n,exceptioncode); // will remove from cmnRoot
               else if (action == CLONE_CONTENTS)
                   fragment->appendChild(n->cloneNode(true),exceptioncode);
  -            else
  +            else {
  +                n->ref();
                   cmnRoot->removeChild(n,exceptioncode);
  +                n->deref();
  +            }
           }
       }
   
  @@ -1180,8 +1198,10 @@
           }
       }
   
  -    while (newParent->firstChild()) {
  -    	newParent->removeChild(newParent->firstChild(),exceptioncode);
  +    while (NodeImpl *n = newParent->firstChild()) {
  +        n->ref();
  +    	newParent->removeChild(n,exceptioncode);
  +        n->deref();
   	if (exceptioncode)
   	    return;
       }
  
  
  



More information about the webkit-changes mailing list