You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2003/10/13 22:49:22 UTC

DO NOT REPLY [Bug 23793] New: - dispatchEventToSubtree also dispatches to Siblings of initial Node

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23793>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23793

dispatchEventToSubtree also dispatches to Siblings of initial Node

           Summary: dispatchEventToSubtree also dispatches to Siblings of
                    initial Node
           Product: Xerces2-J
           Version: 2.5.0
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: DOM
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: chris@dni.lu


The dispatching of events with the recursive function dispatchEventToSubtree(..)
in DocumentImpl does also dispatch to the following Siblings of the initial Node
(though they are not in the subtree).

I have quickly fixed it by splitting the function into 2 and adding a boolean to
prevent dispatching to siblings at the first level of recursion. 
(Invitation to everybody to fix this properly:)

Please verify if this is correct.

Thanks,
Regards,
Christian




The following 2 functions replace the original function:

-------------------------------------------

	protected void dispatchEventToSubtree(NodeImpl node, Node n, Event e) {
		dispatchEventToSubtree( node, n,  e,true);
	} 

    protected void dispatchEventToSubtree(NodeImpl node, Node n, Event e,boolean
p_FirstPass) {
        Vector nodeListeners = getEventListeners(node);
        if (nodeListeners == null || n == null)
            return;

        // ***** Recursive implementation. This is excessively expensive,
        // and should be replaced in conjunction with optimization
        // mentioned above.
        ((NodeImpl) n).dispatchEvent(e);
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            NamedNodeMap a = n.getAttributes();
            for (int i = a.getLength() - 1; i >= 0; --i)
                dispatchEventToSubtree(node, a.item(i), e,false);
        }
        dispatchEventToSubtree(node, n.getFirstChild(), e,false);
        if (!p_FirstPass)dispatchEventToSubtree(node, n.getNextSibling(), e,false);
    } 

-------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org