You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2005/10/18 13:41:14 UTC

svn commit: r326091 - in /xmlgraphics/batik/trunk/sources/org/apache/batik: bridge/svg12/DefaultXBLManager.java dom/svg12/XBLEventSupport.java

Author: cam
Date: Tue Oct 18 04:41:05 2005
New Revision: 326091

URL: http://svn.apache.org/viewcvs?rev=326091&view=rev
Log:
1. More fixes for xblChildNodes not updating.

Modified:
    xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/DefaultXBLManager.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg12/XBLEventSupport.java

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/DefaultXBLManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/DefaultXBLManager.java?rev=326091&r1=326090&r2=326091&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/DefaultXBLManager.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/DefaultXBLManager.java Tue Oct 18 04:41:05 2005
@@ -184,18 +184,18 @@
         // Add document listeners.
         AbstractDocument doc = (AbstractDocument) document;
         XBLEventSupport es = (XBLEventSupport) doc.initializeEventSupport();
-        es.addEventListenerNS
+        es.addImplementationEventListenerNS
             (XMLConstants.XML_EVENTS_NAMESPACE_URI,
              "DOMNodeRemoved",
-             docRemovedListener, true, null);
-        es.addEventListenerNS
+             docRemovedListener, true);
+        es.addImplementationEventListenerNS
             (XMLConstants.XML_EVENTS_NAMESPACE_URI,
              "DOMNodeInserted",
-             docInsertedListener, true, null);
-        es.addEventListenerNS
+             docInsertedListener, true);
+        es.addImplementationEventListenerNS
             (XMLConstants.XML_EVENTS_NAMESPACE_URI,
              "DOMSubtreeModified",
-             docSubtreeListener, true, null);
+             docSubtreeListener, true);
 
         // Add definitions.
         for (int i = 0; i < defs.length; i++) {
@@ -231,15 +231,15 @@
         // Remove document listeners.
         AbstractDocument doc = (AbstractDocument) document;
         XBLEventSupport es = (XBLEventSupport) doc.initializeEventSupport();
-        es.removeEventListenerNS
+        es.removeImplementationEventListenerNS
             (XMLConstants.XML_EVENTS_NAMESPACE_URI,
              "DOMNodeRemoved",
              docRemovedListener, true);
-        es.removeEventListenerNS
+        es.removeImplementationEventListenerNS
             (XMLConstants.XML_EVENTS_NAMESPACE_URI,
              "DOMNodeInserted",
              docInsertedListener, true);
-        es.removeEventListenerNS
+        es.removeImplementationEventListenerNS
             (XMLConstants.XML_EVENTS_NAMESPACE_URI,
              "DOMSubtreeModified",
              docSubtreeListener, true);
@@ -698,8 +698,8 @@
      */
     protected void setXblShadowTree(BindableElement elt,
                                     XBLOMShadowTreeElement newShadow) {
-        XBLShadowTreeElement oldShadow
-            = (XBLShadowTreeElement) getXblShadowTree(elt);
+        XBLOMShadowTreeElement oldShadow
+            = (XBLOMShadowTreeElement) getXblShadowTree(elt);
         if (oldShadow != null) {
             fireShadowTreeEvent(elt, XBL_UNBINDING_EVENT_TYPE, oldShadow);
             ContentManager cm = getContentManager(oldShadow);
@@ -709,8 +709,16 @@
             elt.setShadowTree(null);
             XBLRecord rec = getRecord(oldShadow);
             rec.boundElement = null;
+            oldShadow.removeEventListenerNS
+                (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+                 "DOMSubtreeModified",
+                 docSubtreeListener, false);
         }
         if (newShadow != null) {
+            newShadow.addEventListenerNS
+                (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+                 "DOMSubtreeModified",
+                 docSubtreeListener, false, null);
             fireShadowTreeEvent(elt, XBL_PREBIND_EVENT_TYPE, newShadow);
             elt.setShadowTree(newShadow);
             XBLRecord rec = getRecord(newShadow);
@@ -1452,10 +1460,18 @@
             } else {
                 evt = XBLEventSupport.getUltimateOriginalEvent(evt);
                 target = evt.getTarget();
+                Node parent = getXblParentNode((Node) target);
+                if (parent != null) {
+                    invalidateChildNodes(parent);
+                }
                 if (target instanceof BindableElement) {
-                    // only bind it if it's not the child of a bound element
-                    Node n = getXblParentNode((Node) target);
-                    while (n != null) {
+                    // Only bind it if it's not the descendent of a bound
+                    // element.  If it is, and this new element will be
+                    // selected by an xbl:content element in the shadow tree,
+                    // the ContentManager will bind it.
+                    for (Node n = ((Node) target).getParentNode();
+                            n != null;
+                            n = n.getParentNode()) {
                         if (n instanceof BindableElement
                                 && getRecord(n).definitionElement != null) {
                             return;
@@ -1483,6 +1499,11 @@
         protected LinkedList importsToBeRemoved = new LinkedList();
 
         /**
+         * List of nodes to have their XBL child lists invalidated.
+         */
+        protected LinkedList nodesToBeInvalidated = new LinkedList();
+
+        /**
          * Handles the event.
          */
         public void handleEvent(Event evt) {
@@ -1498,6 +1519,11 @@
                     importsToBeRemoved.add(target);
                 }
             }
+
+            Node parent = getXblParentNode((Node) target);
+            if (parent != null) {
+                nodesToBeInvalidated.add(parent);
+            }
         }
     }
 
@@ -1527,6 +1553,12 @@
             docRemovedListener.importsToBeRemoved.clear();
             for (int i = 0; i < imps.length; i++) {
                 removeImport((Element) imps[i]);
+            }
+
+            Object[] nodes = docRemovedListener.nodesToBeInvalidated.toArray();
+            docRemovedListener.nodesToBeInvalidated.clear();
+            for (int i = 0; i < nodes.length; i++) {
+                invalidateChildNodes((Node) nodes[i]);
             }
         }
     }

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg12/XBLEventSupport.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg12/XBLEventSupport.java?rev=326091&r1=326090&r2=326091&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg12/XBLEventSupport.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg12/XBLEventSupport.java Tue Oct 18 04:41:05 2005
@@ -300,7 +300,7 @@
         HashSet toBeStoppedGroups = new HashSet();
         for (int i = 0; i < minAncestor; i++) {
             NodeEventTarget node = ancestors[i];
-//             System.err.println("\t--   CAPTURE  " + ((Node) node).getNodeName());
+//             System.err.println("\t--   CAPTURING " + e.getType() + "  " + ((Node) node).getNodeName());
             if (isCustom) {
                 ces[i].setDispatchState(node, Event.CAPTURING_PHASE);
                 fireImplementationEventListeners(node, ces[i], true, true);
@@ -312,7 +312,7 @@
         }
         for (int i = minAncestor; i < ancestors.length; i++) {
             NodeEventTarget node = ancestors[i];
-//             System.err.println("\t-- * CAPTURING " + ((Node) node).getNodeName());
+//             System.err.println("\t-- * CAPTURING " + e.getType() + "  " + ((Node) node).getNodeName());
             if (isCustom) {
                 ces[i].setDispatchState(node, Event.CAPTURING_PHASE);
                 fireImplementationEventListeners(node, ces[i], true, true);
@@ -337,32 +337,30 @@
             toBeStoppedGroups.clear();
         }
         // AT_TARGET : fire local event listeners
-        if (someEvents) {
-//             System.err.println("\t-- * AT_TARGET " + ((Node) target).getNodeName());
-            if (isCustom) {
-                ce.setDispatchState(target, Event.AT_TARGET);
-            } else {
-                setEventPhase(aevt, Event.AT_TARGET);
-                setCurrentTarget(aevt, target);
-            }
-            fireImplementationEventListeners(target, e, false, isCustom);
-            fireEventListeners(target, e, false,
-                               stoppedGroups, toBeStoppedGroups, isCustom);
-            fireHandlerGroupEventListeners
-                (node, e, false, stoppedGroups, toBeStoppedGroups, isCustom);
-            stoppedGroups.addAll(toBeStoppedGroups);
-            toBeStoppedGroups.clear();
-            if (isCustom) {
-                preventDefault = preventDefault || ce.isDefaultPrevented();
-            } else {
-                preventDefault = preventDefault || aevt.isDefaultPrevented();
-            }
+//             System.err.println("\t-- * AT_TARGET " + e.getType() + "  " + ((Node) target).getNodeName());
+        if (isCustom) {
+            ce.setDispatchState(target, Event.AT_TARGET);
+        } else {
+            setEventPhase(aevt, Event.AT_TARGET);
+            setCurrentTarget(aevt, target);
+        }
+        fireImplementationEventListeners(target, e, false, isCustom);
+        fireEventListeners(target, e, false,
+                           stoppedGroups, toBeStoppedGroups, isCustom);
+        fireHandlerGroupEventListeners
+            (node, e, false, stoppedGroups, toBeStoppedGroups, isCustom);
+        stoppedGroups.addAll(toBeStoppedGroups);
+        toBeStoppedGroups.clear();
+        if (isCustom) {
+            preventDefault = preventDefault || ce.isDefaultPrevented();
+        } else {
+            preventDefault = preventDefault || aevt.isDefaultPrevented();
         }
         // BUBBLING_PHASE : fire event listeners from target to top
         if (e.getBubbles()) {
             for (int i = ancestors.length - 1; i >= minAncestor; i--) {
                 NodeEventTarget node = ancestors[i];
-//                 System.err.println("\t-- * BUBBLING  " + ((Node) node).getNodeName());
+//                 System.err.println("\t-- * BUBBLING  " + e.getType() + "  " + ((Node) node).getNodeName());
                 if (isCustom) {
                     ces[i].setDispatchState(node, Event.BUBBLING_PHASE);
                     fireImplementationEventListeners(node, ces[i], false, true);
@@ -393,7 +391,7 @@
             }
             for (int i = minAncestor - 1; i >= 0; i--) {
                 NodeEventTarget node = ancestors[i];
-//                 System.err.println("\t--   BUBBLING  " + ((Node) node).getNodeName());
+//                 System.err.println("\t--   BUBBLING  " + e.getType() + "  " + ((Node) node).getNodeName());
                 if (isCustom) {
                     ces[i].setDispatchState(node, Event.BUBBLING_PHASE);
                     fireImplementationEventListeners