[webkit-changes] cvs commit: WebCore/khtml/xml dom_docimpl.cpp dom_docimpl.h dom_nodeimpl.cpp

Timothy thatcher at opensource.apple.com
Fri Nov 18 15:39:05 PST 2005


thatcher    05/11/18 15:39:05

  Modified:    .        Tag: Safari-1-3-branch ChangeLog
               khtml/xml Tag: Safari-1-3-branch dom_docimpl.cpp
                        dom_docimpl.h dom_nodeimpl.cpp
  Log:
          Merged fix from TOT to Safari-1-3-branch
  
      2005-11-18  David Harrison  <harrison at apple.com>
  
          <http://bugzilla.opendarwin.org/show_bug.cgi?id=5629>
          REGRESSION: appendChild() does not remove nodes from source nodelist when inserting into destination
  
          Enable event dispatch when calling removeChild() in loops.   That it was
          disabled previously was wrong because the DOM is not fragile at that point.
          Makes the event dispatch forbiddance a debug-only check
  
          * khtml/xml/dom_docimpl.cpp:
          (DocumentImpl::createEvent):
          * khtml/xml/dom_docimpl.h:
          * khtml/xml/dom_nodeimpl.cpp:
          (DOM::NodeImpl::dispatchEvent):
          (DOM::NodeImpl::dispatchGenericEvent):
          (DOM::NodeImpl::dispatchHTMLEvent):
          (DOM::NodeImpl::dispatchWindowEvent):
          (DOM::NodeImpl::dispatchMouseEvent):
          (DOM::NodeImpl::dispatchSimulatedMouseEvent):
          (DOM::NodeImpl::dispatchUIEvent):
          (DOM::NodeImpl::dispatchSubtreeModifiedEvent):
          (DOM::NodeImpl::dispatchKeyEvent):
          (DOM::NodeImpl::dispatchWheelEvent):
          (DOM::ContainerNodeImpl::insertBefore):
          (DOM::ContainerNodeImpl::replaceChild):
          (DOM::ContainerNodeImpl::removeChild):
          (DOM::ContainerNodeImpl::removeChildren):
          (DOM::ContainerNodeImpl::appendChild):
          (DOM::ContainerNodeImpl::addChild):
          (DOM::ContainerNodeImpl::dispatchChildInsertedEvents):
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.335.2.30 +35 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.335.2.29
  retrieving revision 1.335.2.30
  diff -u -r1.335.2.29 -r1.335.2.30
  --- ChangeLog	18 Nov 2005 22:46:18 -0000	1.335.2.29
  +++ ChangeLog	18 Nov 2005 23:38:54 -0000	1.335.2.30
  @@ -2,6 +2,41 @@
   
           Merged fix from TOT to Safari-1-3-branch
   
  +    2005-11-18  David Harrison  <harrison at apple.com>
  +
  +        <http://bugzilla.opendarwin.org/show_bug.cgi?id=5629>
  +        REGRESSION: appendChild() does not remove nodes from source nodelist when inserting into destination
  +
  +        Enable event dispatch when calling removeChild() in loops.   That it was
  +        disabled previously was wrong because the DOM is not fragile at that point.
  +        Makes the event dispatch forbiddance a debug-only check
  +                
  +        * khtml/xml/dom_docimpl.cpp:
  +        (DocumentImpl::createEvent):
  +        * khtml/xml/dom_docimpl.h:
  +        * khtml/xml/dom_nodeimpl.cpp:
  +        (DOM::NodeImpl::dispatchEvent):
  +        (DOM::NodeImpl::dispatchGenericEvent):
  +        (DOM::NodeImpl::dispatchHTMLEvent):
  +        (DOM::NodeImpl::dispatchWindowEvent):
  +        (DOM::NodeImpl::dispatchMouseEvent):
  +        (DOM::NodeImpl::dispatchSimulatedMouseEvent):
  +        (DOM::NodeImpl::dispatchUIEvent):
  +        (DOM::NodeImpl::dispatchSubtreeModifiedEvent):
  +        (DOM::NodeImpl::dispatchKeyEvent):
  +        (DOM::NodeImpl::dispatchWheelEvent):
  +        (DOM::ContainerNodeImpl::insertBefore):
  +        (DOM::ContainerNodeImpl::replaceChild):
  +        (DOM::ContainerNodeImpl::removeChild):
  +        (DOM::ContainerNodeImpl::removeChildren):
  +        (DOM::ContainerNodeImpl::appendChild):
  +        (DOM::ContainerNodeImpl::addChild):
  +        (DOM::ContainerNodeImpl::dispatchChildInsertedEvents):
  +
  +2005-11-18  Timothy Hatcher  <timothy at apple.com>
  +
  +        Merged fix from TOT to Safari-1-3-branch
  +
       2005-07-29  David Hyatt  <hyatt at apple.com>
   
   	(1) Fixes khtml-user-select: none to have the following additional behavior (that matches Firefox's implementation of the property as well)
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.211.4.12 +0 -18     WebCore/khtml/xml/dom_docimpl.cpp
  
  Index: dom_docimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
  retrieving revision 1.211.4.11
  retrieving revision 1.211.4.12
  diff -u -r1.211.4.11 -r1.211.4.12
  --- dom_docimpl.cpp	18 Nov 2005 22:46:42 -0000	1.211.4.11
  +++ dom_docimpl.cpp	18 Nov 2005 23:39:00 -0000	1.211.4.12
  @@ -2729,28 +2729,10 @@
       return m_defaultView;
   }
   
  -void DocumentImpl::forbidEventDispatch()
  -{
  -    m_eventDispatchForbidden += 1;
  -}
  -
  -void DocumentImpl::allowEventDispatch()
  -{
  -    ASSERT(m_eventDispatchForbidden > 0);
  -    m_eventDispatchForbidden -= 1;
  -}
  -
  -bool DocumentImpl::eventDispatchForbidden()
  -{
  -    return m_eventDispatchForbidden > 0;
  -}
  -
   EventImpl *DocumentImpl::createEvent(const DOMString &eventType, int &exceptioncode)
   {
       // createEvent ought to be at a time completely separate from DOM modifications that forbidEventDispatch
       // (of course, the event _could_ be sent later, but this seems like a good bottleneck)
  -    ASSERT(!eventDispatchForbidden());
  -    
       if (eventType == "UIEvents")
           return new UIEventImpl();
       else if (eventType == "MouseEvents")
  
  
  
  1.104.4.9 +0 -3      WebCore/khtml/xml/dom_docimpl.h
  
  Index: dom_docimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.h,v
  retrieving revision 1.104.4.8
  retrieving revision 1.104.4.9
  diff -u -r1.104.4.8 -r1.104.4.9
  --- dom_docimpl.h	18 Nov 2005 22:46:43 -0000	1.104.4.8
  +++ dom_docimpl.h	18 Nov 2005 23:39:01 -0000	1.104.4.9
  @@ -442,9 +442,6 @@
       void detachNodeIterator(NodeIteratorImpl *ni);
       void notifyBeforeNodeRemoval(NodeImpl *n);
       AbstractViewImpl *defaultView() const;
  -    void forbidEventDispatch();
  -    void allowEventDispatch();
  -    bool eventDispatchForbidden();
       EventImpl *createEvent(const DOMString &eventType, int &exceptioncode);
   
       // keep track of what types of event listeners are registered, so we don't
  
  
  
  1.140.6.5 +40 -33    WebCore/khtml/xml/dom_nodeimpl.cpp
  
  Index: dom_nodeimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom_nodeimpl.cpp,v
  retrieving revision 1.140.6.4
  retrieving revision 1.140.6.5
  diff -u -r1.140.6.4 -r1.140.6.5
  --- dom_nodeimpl.cpp	18 Nov 2005 22:46:44 -0000	1.140.6.4
  +++ dom_nodeimpl.cpp	18 Nov 2005 23:39:01 -0000	1.140.6.5
  @@ -63,6 +63,18 @@
   #define LOG(channel, formatAndArgs...) ((void)0)
   #endif
   
  +#ifndef NDEBUG
  +static int gEventDispatchForbidden;
  +#define forbidEventDispatch() gEventDispatchForbidden += 1
  +#define allowEventDispatch() assert(gEventDispatchForbidden > 0); gEventDispatchForbidden -= 1
  +#define eventDispatchForbidden() (gEventDispatchForbidden > 0)
  +#else
  +
  +#define forbidEventDispatch()
  +#define allowEventDispatch()
  +#define eventDispatchForbidden()
  +#endif NDEBUG
  +
   using namespace DOM;
   using namespace khtml;
   
  @@ -467,7 +479,7 @@
   
   bool NodeImpl::dispatchEvent(EventImpl *evt, int &exceptioncode, bool tempEvent)
   {
  -    assert(!getDocument()->eventDispatchForbidden());
  +    assert(!eventDispatchForbidden());
       evt->ref();
   
       evt->setTarget(this);
  @@ -506,7 +518,7 @@
   
   bool NodeImpl::dispatchGenericEvent( EventImpl *evt, int &/*exceptioncode */)
   {
  -    assert(!getDocument()->eventDispatchForbidden());
  +    assert(!eventDispatchForbidden());
       evt->ref();
   
       // ### check that type specified
  @@ -591,7 +603,7 @@
   
   bool NodeImpl::dispatchHTMLEvent(int _id, bool canBubbleArg, bool cancelableArg)
   {
  -    assert(!getDocument()->eventDispatchForbidden());
  +    assert(!eventDispatchForbidden());
       int exceptioncode = 0;
       EventImpl *evt = new EventImpl(static_cast<EventImpl::EventId>(_id),canBubbleArg,cancelableArg);
       return dispatchEvent(evt,exceptioncode,true);
  @@ -599,7 +611,7 @@
   
   bool NodeImpl::dispatchWindowEvent(int _id, bool canBubbleArg, bool cancelableArg)
   {
  -    assert(!getDocument()->eventDispatchForbidden());
  +    assert(!eventDispatchForbidden());
       int exceptioncode = 0;
       EventImpl *evt = new EventImpl(static_cast<EventImpl::EventId>(_id),canBubbleArg,cancelableArg);
       evt->setTarget( 0 );
  @@ -640,7 +652,7 @@
   
   bool NodeImpl::dispatchMouseEvent(QMouseEvent *_mouse, int overrideId, int overrideDetail)
   {
  -    assert(!getDocument()->eventDispatchForbidden());
  +    assert(!eventDispatchForbidden());
       bool cancelable = true;
       int detail = overrideDetail; // defaults to 0
       EventImpl::EventId evtId = EventImpl::UNKNOWN_EVENT;
  @@ -792,7 +804,7 @@
   
   bool NodeImpl::dispatchUIEvent(int _id, int detail)
   {
  -    assert(!getDocument()->eventDispatchForbidden());
  +    assert(!eventDispatchForbidden());
       assert (!( (_id != EventImpl::DOMFOCUSIN_EVENT &&
           _id != EventImpl::DOMFOCUSOUT_EVENT &&
                   _id != EventImpl::DOMACTIVATE_EVENT)));
  @@ -849,10 +861,8 @@
   
   bool NodeImpl::dispatchSubtreeModifiedEvent(bool sendChildrenChanged)
   {
  -    // forbidder will send this event later
  -    if (getDocument()->eventDispatchForbidden())
  -        return true;
  -
  +    assert(!eventDispatchForbidden());
  +    
       notifyNodeListsSubtreeModified();
       if (sendChildrenChanged)
           childrenChanged();
  @@ -865,7 +875,7 @@
   
   bool NodeImpl::dispatchKeyEvent(QKeyEvent *key)
   {
  -    assert(!getDocument()->eventDispatchForbidden());
  +    assert(!eventDispatchForbidden());
       int exceptioncode = 0;
       //kdDebug(6010) << "DOM::NodeImpl: dispatching keyboard event" << endl;
       KeyboardEventImpl *keyboardEventImpl = new KeyboardEventImpl(key, getDocument()->defaultView());
  @@ -1676,13 +1686,13 @@
   
           // If child is already present in the tree, first remove it
           NodeImpl *newParent = child->parentNode();
  -        if(newParent)
  +        if (newParent)
               newParent->removeChild( child, exceptioncode );
  -        if ( exceptioncode )
  +        if (exceptioncode)
               return 0;
   
           // Add child in the correct position
  -        getDocument()->forbidEventDispatch();
  +        forbidEventDispatch();
           if (prev)
               prev->setNextSibling(child);
           else
  @@ -1696,7 +1706,7 @@
           // ### should we detach() it first if it's already attached?
           if (attached() && !child->attached())
               child->attach();
  -        getDocument()->allowEventDispatch();
  +        allowEventDispatch();
           
           // Dispatch the mutation events
           dispatchChildInsertedEvents(child,exceptioncode);
  @@ -1744,16 +1754,17 @@
   
       // Add the new child(ren)
       while (child) {
  -        getDocument()->forbidEventDispatch();
           nextChild = isFragment ? child->nextSibling() : 0;
   
           // If child is already present in the tree, first remove it
           NodeImpl *newParent = child->parentNode();
  -        if(newParent)
  +        if (newParent)
               newParent->removeChild( child, exceptioncode );
           if (exceptioncode)
               return 0;
   
  +        forbidEventDispatch();
  +
           // Add child in the correct position
           if (prev) prev->setNextSibling(child);
           if (next) next->setPreviousSibling(child);
  @@ -1767,7 +1778,7 @@
           // ### should we detach() it first if it's already attached?
           if (attached() && !child->attached())
               child->attach();
  -        getDocument()->allowEventDispatch();
  +        allowEventDispatch();
   
           // Dispatch the mutation events
           dispatchChildInsertedEvents(child,exceptioncode);
  @@ -1836,7 +1847,7 @@
       if (exceptioncode)
           return 0;
   
  -    getDocument()->forbidEventDispatch();
  +    forbidEventDispatch();
   
       // Remove from rendering tree
       if (oldChild->attached())
  @@ -1858,7 +1869,7 @@
   
       getDocument()->setDocumentChanged(true);
   
  -    getDocument()->allowEventDispatch();
  +    allowEventDispatch();
   
       // Dispatch post-removal mutation events
       dispatchSubtreeModifiedEvent();
  @@ -1883,7 +1894,7 @@
       for (n = _first; n != 0; n = n->nextSibling())
           willRemoveChild(n);
       
  -    getDocument()->forbidEventDispatch();
  +    forbidEventDispatch();
       while ((n = _first) != 0) {
           NodeImpl *next = n->nextSibling();
           
  @@ -1903,7 +1914,7 @@
           _first = next;
       }
       _last = 0;
  -    getDocument()->allowEventDispatch();
  +    allowEventDispatch();
       
       // Dispatch a single post-removal mutation event denoting a modified subtree.
       dispatchSubtreeModifiedEvent();
  @@ -1936,7 +1947,6 @@
       NodeImpl *child = isFragment ? newChild->firstChild() : newChild;
   
       while (child) {
  -        getDocument()->forbidEventDispatch();
           nextChild = isFragment ? child->nextSibling() : 0;
   
           // If child is already present in the tree, first remove it
  @@ -1947,6 +1957,8 @@
                   return 0;
           }
   
  +        forbidEventDispatch();
  +
           // Append child to the end of the list
           child->setParent(this);
   
  @@ -1955,20 +1967,15 @@
               child->setPreviousSibling(_last);
               _last->setNextSibling(child);
               _last = child;
  -        }
  -        else
  -        {
  +        } else
               _first = _last = child;
  -        }
   
           // Add child to the rendering tree
           // ### should we detach() it first if it's already attached?
           if (attached() && !child->attached())
               child->attach();
           
  -        getDocument()->allowEventDispatch();
  -        if (oldParent)
  -            oldParent->dispatchSubtreeModifiedEvent(true);
  +        allowEventDispatch();
           
           // Dispatch the mutation events
           dispatchChildInsertedEvents(child,exceptioncode);
  @@ -2049,7 +2056,7 @@
           return 0;
       }
   
  -    getDocument()->forbidEventDispatch();
  +    forbidEventDispatch();
   
       // just add it...
       newChild->setParent(this);
  @@ -2069,7 +2076,7 @@
           newChild->insertedIntoDocument();
       childrenChanged();
   
  -    getDocument()->allowEventDispatch();
  +    allowEventDispatch();
       
       if(newChild->nodeType() == Node::ELEMENT_NODE)
           return newChild;
  @@ -2316,7 +2323,7 @@
   
   void NodeBaseImpl::dispatchChildInsertedEvents( NodeImpl *child, int &exceptioncode )
   {
  -    assert(!getDocument()->eventDispatchForbidden());
  +    assert(!eventDispatchForbidden());
       NodeImpl *p = this;
       while (p->parentNode())
           p = p->parentNode();
  
  
  



More information about the webkit-changes mailing list