You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/10/08 16:03:22 UTC

[07/62] [abbrv] [partial] Merged Apache Flex 4.9.0 release branch

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgentAdapter.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgentAdapter.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgentAdapter.java
index d09dc2a..508c3a4 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgentAdapter.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgentAdapter.java
@@ -1,10 +1,11 @@
 /*
 
-   Copyright 2001-2004  The Apache Software Foundation 
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE-2.0
 
@@ -29,32 +30,44 @@ import java.util.Set;
 import org.apache.flex.forks.batik.gvt.event.EventDispatcher;
 import org.apache.flex.forks.batik.gvt.text.Mark;
 import org.apache.flex.forks.batik.util.ParsedURL;
-import org.apache.flex.forks.batik.util.SVGConstants;
+import org.apache.flex.forks.batik.util.SVGFeatureStrings;
 import org.apache.flex.forks.batik.util.XMLResourceDescriptor;
+
 import org.w3c.dom.Element;
-import org.w3c.flex.forks.dom.svg.SVGAElement;
+import org.w3c.dom.svg.SVGAElement;
+import org.w3c.dom.svg.SVGDocument;
 
 /**
  * An abstract user agent adaptor implementation.  It exists to simply
  * the creation of UserAgent instances.
  *
  * @author <a href="mailto:thomas.deweese@kodak.com">Thomas DeWeese</a>
- * @version $Id: UserAgentAdapter.java,v 1.20 2005/03/27 08:58:30 cam Exp $
+ * @version $Id: UserAgentAdapter.java 599691 2007-11-30 03:37:58Z cam $
  */
 public class UserAgentAdapter implements UserAgent {
     protected Set FEATURES   = new HashSet();
     protected Set extensions = new HashSet();
 
-    public UserAgentAdapter() {
+    /**
+     * The BridgeContext to use for error information.
+     */
+    protected BridgeContext ctx;
+
+    /**
+     * Sets the BridgeContext to be used for error information.
+     */
+    public void setBridgeContext(BridgeContext ctx) {
+        this.ctx = ctx;
     }
 
+    /**
+     * Adds the standard SVG feature strings to the set of features supported
+     * by this user agent.
+     */
     public void addStdFeatures() {
-        FEATURES.add(SVGConstants.SVG_ORG_W3C_SVG_FEATURE);
-        FEATURES.add(SVGConstants.SVG_ORG_W3C_SVG_LANG_FEATURE);
-        FEATURES.add(SVGConstants.SVG_ORG_W3C_SVG_STATIC_FEATURE);
+        SVGFeatureStrings.addSupportedFeatureStrings(FEATURES);
     }
 
-
     /**
      * Returns the default size of this user agent (400x400).
      */
@@ -422,5 +435,18 @@ public class UserAgentAdapter implements UserAgent {
         }
     }
 
+    /**
+     * This Implementation simply throws a BridgeException.
+     *
+     * @param e   The &lt;image> element that can't be loaded.
+     * @param url The resolved url that can't be loaded.
+     * @param message As best as can be determined the reason it can't be
+     *                loaded (not available, corrupt, unknown format,...).
+     */
+    public SVGDocument getBrokenLinkDocument(Element e, 
+                                             String url, 
+                                             String message) {
+        throw new BridgeException(ctx, e, ErrorConstants.ERR_URI_IMAGE_BROKEN,
+                                  new Object[] {url, message });
+    }
 }
-

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgentViewport.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgentViewport.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgentViewport.java
index 7ab60b0..37a1fa4 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgentViewport.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgentViewport.java
@@ -1,10 +1,11 @@
 /*
 
-   Copyright 2000-2001,2003  The Apache Software Foundation 
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE-2.0
 
@@ -21,7 +22,7 @@ package org.apache.flex.forks.batik.bridge;
  * Defines a viewport for a <tt>UserAgent</tt>.
  *
  * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: UserAgentViewport.java,v 1.5 2004/08/18 07:12:37 vhardy Exp $
+ * @version $Id: UserAgentViewport.java 475477 2006-11-15 22:44:28Z cam $
  */
 public class UserAgentViewport implements Viewport {
 

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ViewBox.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ViewBox.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ViewBox.java
index 2c9f0cd..95de140 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ViewBox.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ViewBox.java
@@ -1,10 +1,11 @@
 /*
 
-   Copyright 2001-2003  The Apache Software Foundation 
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE-2.0
 
@@ -20,22 +21,28 @@ package org.apache.flex.forks.batik.bridge;
 import java.awt.geom.AffineTransform;
 import java.util.StringTokenizer;
 
+import org.apache.flex.forks.batik.dom.svg.LiveAttributeException;
+import org.apache.flex.forks.batik.dom.svg.SVGOMAnimatedRect;
 import org.apache.flex.forks.batik.parser.AWTTransformProducer;
 import org.apache.flex.forks.batik.parser.FragmentIdentifierHandler;
 import org.apache.flex.forks.batik.parser.FragmentIdentifierParser;
 import org.apache.flex.forks.batik.parser.ParseException;
 import org.apache.flex.forks.batik.parser.PreserveAspectRatioParser;
 import org.apache.flex.forks.batik.util.SVGConstants;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.flex.forks.dom.svg.SVGPreserveAspectRatio;
+import org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio;
+import org.w3c.dom.svg.SVGAnimatedRect;
+import org.w3c.dom.svg.SVGPreserveAspectRatio;
+import org.w3c.dom.svg.SVGRect;
 
 /**
  * This class provides convenient methods to handle viewport.
  *
  * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: ViewBox.java,v 1.13 2005/03/27 08:58:30 cam Exp $
+ * @version $Id: ViewBox.java 579487 2007-09-26 06:40:16Z cam $
  */
 public abstract class ViewBox implements SVGConstants, ErrorConstants {
 
@@ -53,17 +60,19 @@ public abstract class ViewBox implements SVGConstants, ErrorConstants {
      * @param e the element interested in its view transform
      * @param w the width of the effective viewport
      * @param h The height of the effective viewport
+     * @param ctx The BridgeContext to use for error information
      * @exception BridgeException if an error occured while computing the
      *            preserveAspectRatio transform
      */
     public static AffineTransform getViewTransform(String ref,
                                                    Element e,
                                                    float w,
-                                                   float h) {
+                                                   float h,
+                                                   BridgeContext ctx) {
 
         // no reference has been specified, no extra viewBox is defined
         if (ref == null || ref.length() == 0) {
-            return getPreserveAspectRatioTransform(e, w, h);
+            return getPreserveAspectRatioTransform(e, w, h, ctx);
         }
 
         ViewHandler vh = new ViewHandler();
@@ -77,7 +86,7 @@ public abstract class ViewBox implements SVGConstants, ErrorConstants {
             attrDefElement = document.getElementById(vh.id);
         }
         if (attrDefElement == null) {
-            throw new BridgeException(e, ERR_URI_MALFORMED,
+            throw new BridgeException(ctx, e, ERR_URI_MALFORMED,
                                       new Object[] {ref});
         }
         // if the referenced element is not a view, the attribute
@@ -94,7 +103,7 @@ public abstract class ViewBox implements SVGConstants, ErrorConstants {
         } else {
             String viewBoxStr = attrDefElement.getAttributeNS
                 (null, SVG_VIEW_BOX_ATTRIBUTE);
-            vb = parseViewBoxAttribute(attrDefElement, viewBoxStr);
+            vb = parseViewBoxAttribute(attrDefElement, viewBoxStr, ctx);
         }
 
         // 'preserveAspectRatio'
@@ -111,11 +120,11 @@ public abstract class ViewBox implements SVGConstants, ErrorConstants {
             pp.setPreserveAspectRatioHandler(ph);
             try {
                 pp.parse(aspectRatio);
-            } catch (ParseException ex) {
+            } catch (ParseException pEx ) {
                 throw new BridgeException
-                    (attrDefElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
+                    (ctx, attrDefElement, pEx, ERR_ATTRIBUTE_VALUE_MALFORMED,
                      new Object[] {SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE,
-                                       aspectRatio, ex});
+                                       aspectRatio, pEx });
             }
             align = ph.align;
             meet = ph.meet;
@@ -152,20 +161,38 @@ public abstract class ViewBox implements SVGConstants, ErrorConstants {
      * Returns the transformation matrix to apply to initalize a viewport or
      * null if the specified viewBox disables the rendering of the element.
      *
+     * @deprecated Replaced by {@link
+     *     #getPreserveAspectRatioTransform(Element,float,float,BridgeContext)},
+     *     which has more accurate error reporting.
      * @param e the element with a viewbox
      * @param w the width of the effective viewport
-     * @param h The height of the effective viewport 
+     * @param h The height of the effective viewport
      */
     public static AffineTransform getPreserveAspectRatioTransform(Element e,
                                                                   float w,
                                                                   float h) {
+        return getPreserveAspectRatioTransform(e, w, h, null);
+    }
+
+    /**
+     * Returns the transformation matrix to apply to initalize a viewport or
+     * null if the specified viewBox disables the rendering of the element.
+     *
+     * @param e the element with a viewbox
+     * @param w the width of the effective viewport
+     * @param h The height of the effective viewport
+     * @param ctx The BridgeContext to use for error information
+     */
+    public static AffineTransform getPreserveAspectRatioTransform
+            (Element e, float w, float h, BridgeContext ctx) {
         String viewBox
             = e.getAttributeNS(null, SVG_VIEW_BOX_ATTRIBUTE);
 
         String aspectRatio
             = e.getAttributeNS(null, SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE);
 
-        return getPreserveAspectRatioTransform(e, viewBox, aspectRatio, w, h);
+        return getPreserveAspectRatioTransform(e, viewBox, aspectRatio, w, h,
+                                               ctx);
     }
 
     /**
@@ -175,20 +202,22 @@ public abstract class ViewBox implements SVGConstants, ErrorConstants {
      * @param e the element with a viewbox
      * @param viewBox the viewBox definition
      * @param w the width of the effective viewport
-     * @param h The height of the effective viewport 
+     * @param h The height of the effective viewport
+     * @param ctx The BridgeContext to use for error information
      */
     public static
         AffineTransform getPreserveAspectRatioTransform(Element e,
                                                         String viewBox,
                                                         String aspectRatio,
                                                         float w,
-                                                        float h) {
+                                                        float h,
+                                                        BridgeContext ctx) {
 
         // no viewBox specified
         if (viewBox.length() == 0) {
             return new AffineTransform();
         }
-        float[] vb = parseViewBoxAttribute(e, viewBox);
+        float[] vb = parseViewBoxAttribute(e, viewBox, ctx);
 
         // 'preserveAspectRatio' attribute
         PreserveAspectRatioParser p = new PreserveAspectRatioParser();
@@ -196,11 +225,11 @@ public abstract class ViewBox implements SVGConstants, ErrorConstants {
         p.setPreserveAspectRatioHandler(ph);
         try {
             p.parse(aspectRatio);
-        } catch (ParseException ex) {
+        } catch (ParseException pEx ) {
             throw new BridgeException
-                (e, ERR_ATTRIBUTE_VALUE_MALFORMED,
+                (ctx, e, pEx, ERR_ATTRIBUTE_VALUE_MALFORMED,
                  new Object[] {SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE,
-                                   aspectRatio, ex});
+                                   aspectRatio, pEx });
         }
 
         return getPreserveAspectRatioTransform(vb, ph.align, ph.meet, w, h);
@@ -213,13 +242,15 @@ public abstract class ViewBox implements SVGConstants, ErrorConstants {
      * @param e the element with a viewbox
      * @param vb the viewBox definition as float
      * @param w the width of the effective viewport
-     * @param h The height of the effective viewport 
+     * @param h The height of the effective viewport
+     * @param ctx The BridgeContext to use for error information
      */
     public static
         AffineTransform getPreserveAspectRatioTransform(Element e,
-							float [] vb,
-							float w,
-							float h) {
+                                                        float[] vb,
+                                                        float w,
+                                                        float h,
+                                                        BridgeContext ctx) {
 
         String aspectRatio
             = e.getAttributeNS(null, SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE);
@@ -230,23 +261,80 @@ public abstract class ViewBox implements SVGConstants, ErrorConstants {
         p.setPreserveAspectRatioHandler(ph);
         try {
             p.parse(aspectRatio);
-        } catch (ParseException ex) {
+        } catch (ParseException pEx ) {
             throw new BridgeException
-                (e, ERR_ATTRIBUTE_VALUE_MALFORMED,
+                (ctx, e, pEx, ERR_ATTRIBUTE_VALUE_MALFORMED,
                  new Object[] {SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE,
-                                   aspectRatio, ex});
+                                   aspectRatio, pEx });
         }
 
         return getPreserveAspectRatioTransform(vb, ph.align, ph.meet, w, h);
     }
 
     /**
+     * Returns the transformation matrix to apply to initalize a viewport or
+     * null if the specified viewBox disables the rendering of the element.
+     *
+     * @param e the element with a viewbox
+     * @param vb the viewBox definition as float
+     * @param w the width of the effective viewport
+     * @param h The height of the effective viewport
+     * @param aPAR The animated preserveAspectRatio value
+     * @param ctx The BridgeContext to use for error information
+     */
+    public static AffineTransform getPreserveAspectRatioTransform
+            (Element e, float[] vb, float w, float h,
+             SVGAnimatedPreserveAspectRatio aPAR, BridgeContext ctx) {
+
+        // 'preserveAspectRatio' attribute
+        try {
+            SVGPreserveAspectRatio pAR = aPAR.getAnimVal();
+            short align = pAR.getAlign();
+            boolean meet = pAR.getMeetOrSlice() ==
+                SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
+            return getPreserveAspectRatioTransform(vb, align, meet, w, h);
+        } catch (LiveAttributeException ex) {
+            throw new BridgeException(ctx, ex);
+        }
+    }
+
+    /**
+     * Returns the transformation matrix to apply to initialize a viewport or
+     * null if the specified viewBox disables the rendering of the element.
+     *
+     * @param e the element with a viewbox
+     * @param aViewBox the viewBox definition
+     * @param aPAR the preserveAspectRatio definition
+     * @param w the width of the effective viewport
+     * @param h the height of the effective viewport
+     * @param ctx the BridgeContext to use for error information
+     */
+    public static AffineTransform getPreserveAspectRatioTransform
+            (Element e, SVGAnimatedRect aViewBox,
+             SVGAnimatedPreserveAspectRatio aPAR,
+             float w, float h, BridgeContext ctx) {
+
+        if (!((SVGOMAnimatedRect) aViewBox).isSpecified()) {
+            // no viewBox specified
+            return new AffineTransform();
+        }
+        SVGRect viewBox = aViewBox.getAnimVal();
+        float[] vb = new float[] { viewBox.getX(), viewBox.getY(),
+                                   viewBox.getWidth(), viewBox.getHeight() };
+
+        return getPreserveAspectRatioTransform(e, vb, w, h, aPAR, ctx);
+    }
+
+    /**
      * Parses a viewBox attribute.
      *
+     * @param e the element whose viewBox attribute value is being parsed
      * @param value the viewBox
+     * @param ctx the BridgeContext to use for error information
      * @return The 4 viewbox components or null.
      */
-    public static float[] parseViewBoxAttribute(Element e, String value) {
+    public static float[] parseViewBoxAttribute(Element e, String value,
+                                                BridgeContext ctx) {
         if (value.length() == 0) {
             return null;
         }
@@ -258,20 +346,20 @@ public abstract class ViewBox implements SVGConstants, ErrorConstants {
                 vb[i] = Float.parseFloat(st.nextToken());
                 i++;
             }
-        } catch (NumberFormatException ex) {
+        } catch (NumberFormatException nfEx ) {
             throw new BridgeException
-                (e, ERR_ATTRIBUTE_VALUE_MALFORMED,
-                 new Object[] {SVG_VIEW_BOX_ATTRIBUTE, value, ex});
+                (ctx, e, nfEx, ERR_ATTRIBUTE_VALUE_MALFORMED,
+                 new Object[] {SVG_VIEW_BOX_ATTRIBUTE, value, nfEx });
         }
         if (i != 4) {
             throw new BridgeException
-                (e, ERR_ATTRIBUTE_VALUE_MALFORMED,
+                (ctx, e, ERR_ATTRIBUTE_VALUE_MALFORMED,
                  new Object[] {SVG_VIEW_BOX_ATTRIBUTE, value});
         }
         // A negative value for <width> or <height> is an error
         if (vb[2] < 0 || vb[3] < 0) {
             throw new BridgeException
-                (e, ERR_ATTRIBUTE_VALUE_MALFORMED,
+                (ctx, e, ERR_ATTRIBUTE_VALUE_MALFORMED,
                  new Object[] {SVG_VIEW_BOX_ATTRIBUTE, value});
         }
         // A value of zero for width or height disables rendering of the element

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/Viewport.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/Viewport.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/Viewport.java
index ec0092d..9a7d1df 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/Viewport.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/Viewport.java
@@ -1,10 +1,11 @@
 /*
 
-   Copyright 1999-2003  The Apache Software Foundation 
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE-2.0
 
@@ -22,18 +23,18 @@ package org.apache.flex.forks.batik.bridge;
  * Defines a viewport.
  *
  * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: Viewport.java,v 1.3 2004/10/30 18:38:04 deweese Exp $
+ * @version $Id: Viewport.java 478160 2006-11-22 13:35:06Z dvholten $
  */
 public interface Viewport {
 
     /**
      * Returns the width of this viewport.
      */
-    public float getWidth();
+    float getWidth();
 
     /**
      * Returns the height of this viewport.
      */
-    public float getHeight();
+    float getHeight();
 
 }

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/AbstractContentSelector.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/AbstractContentSelector.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/AbstractContentSelector.java
new file mode 100644
index 0000000..f3b0e9c
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/AbstractContentSelector.java
@@ -0,0 +1,169 @@
+/*
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.flex.forks.batik.bridge.svg12;
+
+import java.util.HashMap;
+
+import org.apache.flex.forks.batik.dom.svg12.XBLOMContentElement;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A base class for handlers of different XBL content element includes
+ * attribute syntaxes.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AbstractContentSelector.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public abstract class AbstractContentSelector {
+
+    /**
+     * The ContentManager object that owns this selector.
+     */
+    protected ContentManager contentManager;
+
+    /**
+     * The XBL content element.
+     */
+    protected XBLOMContentElement contentElement;
+
+    /**
+     * The bound element.
+     */
+    protected Element boundElement;
+
+    /**
+     * Creates a new AbstractContentSelector object.
+     */
+    public AbstractContentSelector(ContentManager cm,
+                                   XBLOMContentElement content,
+                                   Element bound) {
+        contentManager = cm;
+        contentElement = content;
+        boundElement = bound;
+    }
+
+    /**
+     * Returns a list of nodes that were matched by this selector.
+     */
+    public abstract NodeList getSelectedContent();
+
+    /**
+     * Forces this selector to update its selected nodes list.
+     * Returns true if the selected node list needed updating.
+     * This assumes that the previous content elements in this
+     * shadow tree (in document order) have up-to-date selectedContent
+     * lists.
+     */
+    abstract boolean update();
+
+    /**
+     * Returns true if the given node has already been selected
+     * by a content element.
+     */
+    protected boolean isSelected(Node n) {
+        return contentManager.getContentElement(n) != null;
+    }
+
+    /**
+     * Map of selector languages to factories.
+     */
+    protected static HashMap selectorFactories = new HashMap();
+    static {
+        ContentSelectorFactory f1 = new XPathPatternContentSelectorFactory();
+        ContentSelectorFactory f2 = new XPathSubsetContentSelectorFactory();
+        selectorFactories.put(null, f1);
+        selectorFactories.put("XPathPattern", f1);
+        selectorFactories.put("XPathSubset", f2);
+    }
+
+    /**
+     * Creates a new selector object.
+     * @param content The content element using this selector.
+     * @param bound The bound element whose children will be selected.
+     * @param selector The selector string.
+     */
+    public static AbstractContentSelector createSelector
+            (String selectorLanguage,
+             ContentManager cm,
+             XBLOMContentElement content,
+             Element bound,
+             String selector) {
+
+        ContentSelectorFactory f =
+            (ContentSelectorFactory) selectorFactories.get(selectorLanguage);
+        if (f == null) {
+            throw new RuntimeException
+                ("Invalid XBL content selector language '"
+                 + selectorLanguage
+                 + "'");
+        }
+        return f.createSelector(cm, content, bound, selector);
+    }
+
+    /**
+     * An interface for content selector factories.
+     */
+    protected static interface ContentSelectorFactory {
+
+        /**
+         * Creates a new selector object.
+         */
+        AbstractContentSelector createSelector(ContentManager cm,
+                                               XBLOMContentElement content,
+                                               Element bound,
+                                               String selector);
+    }
+
+    /**
+     * A factory for XPathSubsetContentSelector objects.
+     */
+    protected static class XPathSubsetContentSelectorFactory
+            implements ContentSelectorFactory {
+
+        /**
+         * Creates a new XPathSubsetContentSelector object.
+         */
+        public AbstractContentSelector createSelector(ContentManager cm,
+                                                      XBLOMContentElement content,
+                                                      Element bound,
+                                                      String selector) {
+            return new XPathSubsetContentSelector(cm, content, bound, selector);
+        }
+    }
+
+    /**
+     * A factory for XPathPatternContentSelector objects.
+     */
+    protected static class XPathPatternContentSelectorFactory
+            implements ContentSelectorFactory {
+
+        /**
+         * Creates a new XPathPatternContentSelector object.
+         */
+        public AbstractContentSelector createSelector(ContentManager cm,
+                                                      XBLOMContentElement content,
+                                                      Element bound,
+                                                      String selector) {
+            return new XPathPatternContentSelector(cm, content, bound, selector);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/BindableElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/BindableElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/BindableElementBridge.java
new file mode 100644
index 0000000..a297779
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/BindableElementBridge.java
@@ -0,0 +1,262 @@
+/*
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.flex.forks.batik.bridge.svg12;
+
+import org.apache.flex.forks.batik.bridge.AbstractGraphicsNodeBridge;
+import org.apache.flex.forks.batik.bridge.Bridge;
+import org.apache.flex.forks.batik.bridge.BridgeContext;
+import org.apache.flex.forks.batik.bridge.GVTBuilder;
+import org.apache.flex.forks.batik.bridge.SVGUtilities;
+import org.apache.flex.forks.batik.bridge.ScriptingEnvironment;
+import org.apache.flex.forks.batik.bridge.UpdateManager;
+import org.apache.flex.forks.batik.dom.svg12.BindableElement;
+import org.apache.flex.forks.batik.gvt.CompositeGraphicsNode;
+import org.apache.flex.forks.batik.gvt.GraphicsNode;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.events.MutationEvent;
+
+/**
+ * Bridge class for foreign namespace elements that can be bound with sXBL.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: BindableElementBridge.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class BindableElementBridge
+        extends AbstractGraphicsNodeBridge
+        implements SVG12BridgeUpdateHandler {
+
+    /**
+     * Constructs a new bridge for custom elements.
+     */
+    public BindableElementBridge() {
+    }
+
+    /**
+     * Returns "*" to indicate a default bridge.
+     */
+    public String getNamespaceURI() {
+        return "*";
+    }
+
+    /**
+     * Returns "*" to indicate a default bridge.
+     */
+    public String getLocalName() {
+        return "*";
+    }
+
+    /**
+     * Returns a new instance of this bridge.
+     */
+    public Bridge getInstance() {
+        return new BindableElementBridge();
+    }
+
+    /**
+     * Creates a <tt>GraphicsNode</tt> according to the specified parameters.
+     *
+     * @param ctx the bridge context to use
+     * @param e the element that describes the graphics node to build
+     * @return a graphics node that represents the specified element
+     */
+    public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
+        // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
+        if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
+            return null;
+        }
+
+        CompositeGraphicsNode gn = buildCompositeGraphicsNode(ctx, e, null);
+
+        return gn;
+    }
+
+    /**
+     * Creates a <tt>GraphicsNode</tt> from the input element and
+     * populates the input <tt>CompositeGraphicsNode</tt>
+     *
+     * @param ctx the bridge context to use
+     * @param e the element that describes the graphics node to build
+     * @param gn the CompositeGraphicsNode where the use graphical 
+     *        content will be appended. The composite node is emptied
+     *        before appending new content.
+     */
+    public CompositeGraphicsNode
+            buildCompositeGraphicsNode(BridgeContext ctx, 
+                                       Element e,
+                                       CompositeGraphicsNode gn) {
+
+        BindableElement be = (BindableElement) e;
+        Element shadowTree = be.getXblShadowTree();
+
+        UpdateManager um = ctx.getUpdateManager();
+        ScriptingEnvironment se = um == null ? null
+                                             : um.getScriptingEnvironment();
+
+        if (se != null && shadowTree != null) {
+            se.addScriptingListeners(shadowTree);
+        }
+
+        if (gn == null) {
+            gn = new CompositeGraphicsNode();
+            associateSVGContext(ctx, e, gn);
+        } else {
+            int s = gn.size();
+            for (int i = 0; i < s; i++) {
+                gn.remove(0);
+            }
+        }
+
+        GVTBuilder builder = ctx.getGVTBuilder();
+
+        if (shadowTree != null) {
+            GraphicsNode shadowNode = builder.build(ctx, shadowTree);
+            if (shadowNode != null) {
+                gn.add(shadowNode);
+            }
+        } else {
+            for (Node m = e.getFirstChild(); m != null; m = m.getNextSibling()) {
+                if (m.getNodeType() == Node.ELEMENT_NODE) {
+                    GraphicsNode n = builder.build(ctx, (Element) m);
+                    if (n != null) {
+                        gn.add(n);
+                    }
+                }
+            }
+        }
+
+        return gn;
+    }
+
+    public void dispose() {
+        BindableElement be = (BindableElement) e;
+        if (be != null && be.getCSSFirstChild() != null) {
+            disposeTree(be.getCSSFirstChild());
+        }
+
+        super.dispose();
+    }
+
+    /**
+     * Creates the GraphicsNode depending on the GraphicsNodeBridge
+     * implementation.
+     */
+    protected GraphicsNode instantiateGraphicsNode() {
+        return null; // nothing to do, createGraphicsNode is fully overriden
+    }
+
+    /**
+     * Returns false as the custom element is a not container.
+     */
+    public boolean isComposite() {
+        return false;
+    }
+
+    /**
+     * Builds using the specified BridgeContext and element, the
+     * specified graphics node.
+     *
+     * @param ctx the bridge context to use
+     * @param e the element that describes the graphics node to build
+     * @param node the graphics node to build
+     */
+    public void buildGraphicsNode(BridgeContext ctx,
+                                  Element e,
+                                  GraphicsNode node) {
+
+        initializeDynamicSupport(ctx, e, node);
+    }
+
+    // BridgeUpdateHandler implementation //////////////////////////////////
+
+    /**
+     * Invoked when an MutationEvent of type 'DOMNodeInserted' is fired.
+     */
+    public void handleDOMNodeInsertedEvent(MutationEvent evt) {
+        // Only rebuild the graphics tree if this custom element is not bound.
+        BindableElement be = (BindableElement) e;
+        Element shadowTree = be.getXblShadowTree();
+
+        if (shadowTree == null && evt.getTarget() instanceof Element) {
+            handleElementAdded((CompositeGraphicsNode) node, 
+                               e, 
+                               (Element) evt.getTarget());
+        }
+    }
+
+    /**
+     * Invoked when a bindable element's binding has changed.
+     */
+    public void handleBindingEvent(Element bindableElement,
+                                   Element shadowTree) {
+        CompositeGraphicsNode gn = node.getParent();
+        gn.remove(node);
+        disposeTree(e);
+
+        handleElementAdded(gn, e.getParentNode(), e);
+    }
+
+    /**
+     * Invoked when the xblChildNodes property has changed because a
+     * descendant xbl:content element has updated its selected nodes.
+     */
+    public void handleContentSelectionChangedEvent
+            (ContentSelectionChangedEvent csce) {
+    }
+
+    /**
+     * Rebuild the graphics tree.
+     */
+    protected void handleElementAdded(CompositeGraphicsNode gn, 
+                                      Node parent, 
+                                      Element childElt) {
+        // build the graphics node
+        GVTBuilder builder = ctx.getGVTBuilder();
+        GraphicsNode childNode = builder.build(ctx, childElt);
+        if (childNode == null) {
+            return; // the added element is not a graphic element
+        }
+        
+        // Find the index where the GraphicsNode should be added
+        int idx = -1;
+        for(Node ps = childElt.getPreviousSibling(); ps != null;
+            ps = ps.getPreviousSibling()) {
+            if (ps.getNodeType() != Node.ELEMENT_NODE)
+                continue;
+            Element pse = (Element)ps;
+            GraphicsNode psgn = ctx.getGraphicsNode(pse);
+            while ((psgn != null) && (psgn.getParent() != gn)) {
+                // In some cases the GN linked is
+                // a child (in particular for images).
+                psgn = psgn.getParent();
+            }
+            if (psgn == null)
+                continue;
+            idx = gn.indexOf(psgn);
+            if (idx == -1)
+                continue;
+            break;
+        }
+        // insert after prevSibling, if
+        // it was -1 this becomes 0 (first slot)
+        idx++; 
+        gn.add(idx, childNode);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/BindingListener.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/BindingListener.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/BindingListener.java
new file mode 100644
index 0000000..1223311
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/BindingListener.java
@@ -0,0 +1,37 @@
+/*
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.flex.forks.batik.bridge.svg12;
+
+import java.util.EventListener;
+
+import org.w3c.dom.Element;
+
+/**
+ * The interface for listening to binding changes on bindable elements.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: BindingListener.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public interface BindingListener extends EventListener {
+
+    /**
+     * Invoked when the specified bindable element's binding has changed.
+     */
+    void bindingChanged(Element bindableElement, Element shadowTree);
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentManager.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentManager.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentManager.java
new file mode 100644
index 0000000..8fb2704
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentManager.java
@@ -0,0 +1,552 @@
+/*
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.flex.forks.batik.bridge.svg12;
+
+import javax.swing.event.EventListenerList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+
+import org.apache.flex.forks.batik.dom.AbstractNode;
+import org.apache.flex.forks.batik.dom.events.NodeEventTarget;
+import org.apache.flex.forks.batik.dom.xbl.XBLManager;
+import org.apache.flex.forks.batik.dom.svg12.XBLEventSupport;
+import org.apache.flex.forks.batik.dom.svg12.XBLOMContentElement;
+import org.apache.flex.forks.batik.dom.svg12.XBLOMShadowTreeElement;
+import org.apache.flex.forks.batik.util.XBLConstants;
+import org.apache.flex.forks.batik.util.XMLConstants;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventListener;
+import org.w3c.dom.events.EventTarget;
+import org.w3c.dom.events.MutationEvent;
+
+/**
+ * A class to manage all XBL content elements in a shadow tree.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: ContentManager.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class ContentManager {
+
+    /**
+     * The shadow tree whose content elements this object is managing.
+     */
+    protected XBLOMShadowTreeElement shadowTree;
+
+    /**
+     * The bound element that owns the shadow tree.
+     */
+    protected Element boundElement;
+
+    /**
+     * The XBL manager.
+     */
+    protected DefaultXBLManager xblManager;
+
+    /**
+     * Map of content elements to selectors.
+     * [XBLContentElement, AbstractContentSelector]
+     */
+    protected HashMap selectors = new HashMap();
+
+    /**
+     * Map of content elements to a list of nodes that were selected
+     * by that content element.
+     * [XBLContentElement, NodeList]
+     */
+    protected HashMap selectedNodes = new HashMap();
+
+    /**
+     * List of content elements.
+     * [XBLContentElement]
+     */
+    protected LinkedList contentElementList = new LinkedList();
+
+    /**
+     * The recently removed node from the shadow tree.
+     */
+    protected Node removedNode;
+
+    /**
+     * Map of XBLContentElement objects to EventListenerList
+     * objects.
+     */
+    protected HashMap listeners = new HashMap();
+
+    /**
+     * DOMAttrModified listener for content elements.
+     */
+    protected ContentElementDOMAttrModifiedEventListener
+        contentElementDomAttrModifiedEventListener;
+
+    /**
+     * DOMAttrModified listener for bound element children.
+     */
+    protected DOMAttrModifiedEventListener domAttrModifiedEventListener;
+
+    /**
+     * DOMNodeInserted listener for bound element children.
+     */
+    protected DOMNodeInsertedEventListener domNodeInsertedEventListener;
+
+    /**
+     * DOMNodeRemoved listener for bound element children.
+     */
+    protected DOMNodeRemovedEventListener domNodeRemovedEventListener;
+
+    /**
+     * DOMSubtreeModified listener for shadow tree nodes.
+     */
+    protected DOMSubtreeModifiedEventListener domSubtreeModifiedEventListener;
+
+    /**
+     * DOMNodeInserted listener for content elements in the shadow tree.
+     */
+    protected ShadowTreeNodeInsertedListener shadowTreeNodeInsertedListener;
+
+    /**
+     * DOMNodeRemoved listener for content elements in the shadow tree.
+     */
+    protected ShadowTreeNodeRemovedListener shadowTreeNodeRemovedListener;
+
+    /**
+     * DOMSubtreeModified listener for content elements in the shadow tree.
+     */
+    protected ShadowTreeSubtreeModifiedListener
+        shadowTreeSubtreeModifiedListener;
+
+    /**
+     * Creates a new ContentManager object.
+     * @param s the shadow tree element whose content elements this object
+     *          will be managing
+     * @param xm the XBLManager for this document
+     */
+    public ContentManager(XBLOMShadowTreeElement s, XBLManager xm) {
+        shadowTree = s;
+        xblManager = (DefaultXBLManager) xm;
+
+        xblManager.setContentManager(s, this);
+        boundElement = xblManager.getXblBoundElement(s);
+
+        contentElementDomAttrModifiedEventListener =
+            new ContentElementDOMAttrModifiedEventListener();
+
+        XBLEventSupport es = (XBLEventSupport)
+            shadowTree.initializeEventSupport();
+        shadowTreeNodeInsertedListener = new ShadowTreeNodeInsertedListener();
+        shadowTreeNodeRemovedListener = new ShadowTreeNodeRemovedListener();
+        shadowTreeSubtreeModifiedListener
+            = new ShadowTreeSubtreeModifiedListener();
+        es.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMNodeInserted",
+             shadowTreeNodeInsertedListener, true);
+        es.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMNodeRemoved",
+             shadowTreeNodeRemovedListener, true);
+        es.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMSubtreeModified",
+             shadowTreeSubtreeModifiedListener, true);
+
+        es = (XBLEventSupport)
+            ((AbstractNode) boundElement).initializeEventSupport();
+        domAttrModifiedEventListener = new DOMAttrModifiedEventListener();
+        domNodeInsertedEventListener = new DOMNodeInsertedEventListener();
+        domNodeRemovedEventListener = new DOMNodeRemovedEventListener();
+        domSubtreeModifiedEventListener = new DOMSubtreeModifiedEventListener();
+        es.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMAttrModified",
+             domAttrModifiedEventListener, true);
+        es.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMNodeInserted",
+             domNodeInsertedEventListener, true);
+        es.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMNodeRemoved",
+             domNodeRemovedEventListener, true);
+        es.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMSubtreeModified",
+             domSubtreeModifiedEventListener, false);
+
+        update(true);
+    }
+
+    /**
+     * Disposes this ContentManager.
+     */
+    public void dispose() {
+        xblManager.setContentManager(shadowTree, null);
+
+        Iterator i = selectedNodes.entrySet().iterator();
+        while (i.hasNext()) {
+            Map.Entry e = (Map.Entry) i.next();
+            NodeList nl = (NodeList) e.getValue();
+            for (int j = 0; j < nl.getLength(); j++) {
+                Node n = nl.item(j);
+                xblManager.getRecord(n).contentElement = null;
+            }
+        }
+
+        i = contentElementList.iterator();
+        while (i.hasNext()) {
+            NodeEventTarget n = (NodeEventTarget) i.next();
+            n.removeEventListenerNS
+                (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified",
+                 contentElementDomAttrModifiedEventListener, false);
+        }
+
+        contentElementList.clear();
+        selectedNodes.clear();
+
+        XBLEventSupport es
+            = (XBLEventSupport) ((AbstractNode) boundElement).getEventSupport();
+        es.removeImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMAttrModified",
+             domAttrModifiedEventListener, true);
+        es.removeImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMNodeInserted",
+             domNodeInsertedEventListener, true);
+        es.removeImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMNodeRemoved",
+             domNodeRemovedEventListener, true);
+        es.removeImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMSubtreeModified",
+             domSubtreeModifiedEventListener, false);
+    }
+
+    /**
+     * Returns a NodeList of the content that was selected by the
+     * given content element.
+     */
+    public NodeList getSelectedContent(XBLOMContentElement e) {
+        return (NodeList) selectedNodes.get(e);
+    }
+
+    /**
+     * Returns the content element that selected a given node.
+     */
+    protected XBLOMContentElement getContentElement(Node n) {
+        return xblManager.getXblContentElement(n);
+    }
+
+    /**
+     * Adds the specified ContentSelectionChangedListener to the
+     * listener list.
+     */
+    public void addContentSelectionChangedListener
+            (XBLOMContentElement e, ContentSelectionChangedListener l) {
+        EventListenerList ll = (EventListenerList) listeners.get(e);
+        if (ll == null) {
+            ll = new EventListenerList();
+            listeners.put(e, ll);
+        }
+        ll.add(ContentSelectionChangedListener.class, l);
+    }
+
+    /**
+     * Removes the specified ContentSelectionChangedListener from the
+     * listener list.
+     */
+    public void removeContentSelectionChangedListener
+            (XBLOMContentElement e, ContentSelectionChangedListener l) {
+        EventListenerList ll = (EventListenerList) listeners.get(e);
+        if (ll != null) {
+            ll.remove(ContentSelectionChangedListener.class, l);
+        }
+    }
+
+    /**
+     * Dispatches the ContentSelectionChangedEvent to the registered
+     * listeners.
+     */
+    protected void dispatchContentSelectionChangedEvent(XBLOMContentElement e) {
+        xblManager.invalidateChildNodes(e.getXblParentNode());
+
+        ContentSelectionChangedEvent evt =
+            new ContentSelectionChangedEvent(e);
+
+        EventListenerList ll = (EventListenerList) listeners.get(e);
+        if (ll != null) {
+            Object[] ls = ll.getListenerList();
+            for (int i = ls.length - 2; i >= 0; i -= 2) {
+                ContentSelectionChangedListener l =
+                    (ContentSelectionChangedListener) ls[i + 1];
+                l.contentSelectionChanged(evt);
+            }
+        }
+
+        Object[] ls = xblManager.getContentSelectionChangedListeners();
+        for (int i = ls.length - 2; i >= 0; i -= 2) {
+            ContentSelectionChangedListener l =
+                (ContentSelectionChangedListener) ls[i + 1];
+            l.contentSelectionChanged(evt);
+        }
+    }
+
+    /**
+     * Updates all content elements.
+     * @param first Whether this is the first update for this ContentManager.
+     */
+    protected void update(boolean first) {
+        HashSet previouslySelectedNodes = new HashSet();
+        Iterator i = selectedNodes.entrySet().iterator();
+        while (i.hasNext()) {
+            Map.Entry e = (Map.Entry) i.next();
+            NodeList nl = (NodeList) e.getValue();
+            for (int j = 0; j < nl.getLength(); j++) {
+                Node n = nl.item(j);
+                xblManager.getRecord(n).contentElement = null;
+                previouslySelectedNodes.add(n);
+            }
+        }
+
+        i = contentElementList.iterator();
+        while (i.hasNext()) {
+            NodeEventTarget n = (NodeEventTarget) i.next();
+            n.removeEventListenerNS
+                (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified",
+                 contentElementDomAttrModifiedEventListener, false);
+        }
+
+        contentElementList.clear();
+        selectedNodes.clear();
+
+        boolean updated = false;
+        for (Node n = shadowTree.getFirstChild();
+                n != null;
+                n = n.getNextSibling()) {
+            if (update(first, n)) {
+                updated = true;
+            }
+        }
+
+        if (updated) {
+            HashSet newlySelectedNodes = new HashSet();
+            i = selectedNodes.entrySet().iterator();
+            while (i.hasNext()) {
+                Map.Entry e = (Map.Entry) i.next();
+                NodeList nl = (NodeList) e.getValue();
+                for (int j = 0; j < nl.getLength(); j++) {
+                    Node n = nl.item(j);
+                    newlySelectedNodes.add(n);
+                }
+            }
+
+            HashSet removed = new HashSet();
+            removed.addAll(previouslySelectedNodes);
+            removed.removeAll(newlySelectedNodes);
+
+            HashSet added = new HashSet();
+            added.addAll(newlySelectedNodes);
+            added.removeAll(previouslySelectedNodes);
+
+            if (!first) {
+                xblManager.shadowTreeSelectedContentChanged(removed, added);
+            }
+        }
+    }
+
+    protected boolean update(boolean first, Node n) {
+        boolean updated = false;
+        for (Node m = n.getFirstChild(); m != null; m = m.getNextSibling()) {
+            if (update(first, m)) {
+                updated = true;
+            }
+        }
+        if (n instanceof XBLOMContentElement) {
+            contentElementList.add(n);
+            XBLOMContentElement e = (XBLOMContentElement) n;
+            e.addEventListenerNS
+                (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified",
+                 contentElementDomAttrModifiedEventListener, false, null);
+            AbstractContentSelector s =
+                (AbstractContentSelector) selectors.get(n);
+            boolean changed;
+            if (s == null) {
+                if (e.hasAttributeNS(null,
+                                     XBLConstants.XBL_INCLUDES_ATTRIBUTE)) {
+                    String lang = getContentSelectorLanguage(e);
+                    String selector = e.getAttributeNS
+                        (null, XBLConstants.XBL_INCLUDES_ATTRIBUTE);
+                    s = AbstractContentSelector.createSelector
+                        (lang, this, e, boundElement, selector);
+                } else {
+                    s = new DefaultContentSelector(this, e, boundElement);
+                }
+                selectors.put(n, s);
+                changed = true;
+            } else {
+                changed = s.update();
+            }
+            NodeList selectedContent = s.getSelectedContent();
+            selectedNodes.put(n, selectedContent);
+            for (int i = 0; i < selectedContent.getLength(); i++) {
+                Node m = selectedContent.item(i);
+                xblManager.getRecord(m).contentElement = e;
+            }
+            if (changed) {
+                updated = true;
+                dispatchContentSelectionChangedEvent(e);
+            }
+        }
+        return updated;
+    }
+
+    /**
+     * Returns the selector language to be used for the given
+     * xbl:content element.  This will look at the xbl:content
+     * element and the document element for an attribute
+     * batik:selectorLanguage.
+     */
+    protected String getContentSelectorLanguage(Element e) {
+        String lang = e.getAttributeNS("http://xml.apache.org/batik/ext",
+                                       "selectorLanguage");
+        if (lang.length() != 0) {
+            return lang;
+        }
+        lang = e.getOwnerDocument().getDocumentElement().getAttributeNS
+            ("http://xml.apache.org/batik/ext", "selectorLanguage");
+        if (lang.length() != 0) {
+            return lang;
+        }
+        return null;
+    }
+
+    /**
+     * The DOM EventListener invoked when an attribute is modified,
+     * for content elements.
+     */
+    protected class ContentElementDOMAttrModifiedEventListener
+            implements EventListener {
+        public void handleEvent(Event evt) {
+            MutationEvent me = (MutationEvent) evt;
+            Attr a = (Attr) me.getRelatedNode();
+            Element e = (Element) evt.getTarget();
+            if (e instanceof XBLOMContentElement) {
+                String ans = a.getNamespaceURI();
+                String aln = a.getLocalName();
+                if (aln == null) {
+                    aln = a.getNodeName();
+                }
+                if (ans == null && XBLConstants.XBL_INCLUDES_ATTRIBUTE.equals(aln)
+                        || "http://xml.apache.org/batik/ext".equals(ans)
+                            && "selectorLanguage".equals(aln)) {
+                    selectors.remove(e);
+                    update(false);
+                }
+            }
+        }
+    }
+
+    /**
+     * The DOM EventListener invoked when an attribute is modified.
+     */
+    protected class DOMAttrModifiedEventListener implements EventListener {
+        public void handleEvent(Event evt) {
+            if (evt.getTarget() != boundElement) {
+                update(false);
+            }
+        }
+    }
+
+    /**
+     * The DOM EventListener invoked when a node is added.
+     */
+    protected class DOMNodeInsertedEventListener implements EventListener {
+        public void handleEvent(Event evt) {
+            update(false);
+        }
+    }
+
+    /**
+     * The DOM EventListener invoked when a node is removed.
+     */
+    protected class DOMNodeRemovedEventListener implements EventListener {
+        public void handleEvent(Event evt) {
+            removedNode = (Node) evt.getTarget();
+        }
+    }
+
+    /**
+     * The DOM EventListener invoked when a subtree has changed.
+     */
+    protected class DOMSubtreeModifiedEventListener implements EventListener {
+        public void handleEvent(Event evt) {
+            if (removedNode != null) {
+                removedNode = null;
+                update(false);
+            }
+        }
+
+    }
+
+    /**
+     * The DOM EventListener invoked when a node in the shadow tree has been
+     * inserted.
+     */
+    protected class ShadowTreeNodeInsertedListener implements EventListener {
+        public void handleEvent(Event evt) {
+            if (evt.getTarget() instanceof XBLOMContentElement) {
+                update(false);
+            }
+        }
+    }
+
+    /**
+     * The DOM EventListener invoked when a node in the shadow tree has been
+     * removed.
+     */
+    protected class ShadowTreeNodeRemovedListener implements EventListener {
+        public void handleEvent(Event evt) {
+            EventTarget target = evt.getTarget();
+            if (target instanceof XBLOMContentElement) {
+                removedNode = (Node) evt.getTarget();
+            }
+        }
+    }
+
+    /**
+     * The DOM EventListener invoked when a subtree of the shadow tree
+     * has changed.
+     */
+    protected class ShadowTreeSubtreeModifiedListener implements EventListener {
+        public void handleEvent(Event evt) {
+            if (removedNode != null) {
+                removedNode = null;
+                update(false);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentSelectionChangedEvent.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentSelectionChangedEvent.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentSelectionChangedEvent.java
new file mode 100644
index 0000000..c3463bf
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentSelectionChangedEvent.java
@@ -0,0 +1,48 @@
+/*
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.flex.forks.batik.bridge.svg12;
+
+import java.util.EventObject;
+
+import org.apache.flex.forks.batik.dom.svg12.XBLOMContentElement;
+
+/**
+ * An event to signify a change to the list of selected nodes for an
+ * xbl;content element.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: ContentSelectionChangedEvent.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class ContentSelectionChangedEvent extends EventObject {
+
+    /**
+     * Creates a new ContentSelectionChangedEvent object.
+     * @param c the xbl:content element whose selection is changing
+     */
+    public ContentSelectionChangedEvent(XBLOMContentElement c) {
+        super(c);
+    }
+
+    /**
+     * Returns the xbl:content element where the event originated.
+     */
+    public XBLOMContentElement getContentElement() {
+        return (XBLOMContentElement) source;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentSelectionChangedListener.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentSelectionChangedListener.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentSelectionChangedListener.java
new file mode 100644
index 0000000..25aadd9
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/ContentSelectionChangedListener.java
@@ -0,0 +1,38 @@
+/*
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.flex.forks.batik.bridge.svg12;
+
+import java.util.EventListener;
+
+/**
+ * The interface for listening to changes in selected nodes on an
+ * xbl:content element.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: ContentSelectionChangedListener.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public interface ContentSelectionChangedListener extends EventListener {
+
+    /**
+     * Invoked after an xbl:content element has updated its selected
+     * nodes list.
+     * @param csce the ContentSelectionChangedEvent object
+     */
+    void contentSelectionChanged(ContentSelectionChangedEvent csce);
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/DefaultContentSelector.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/DefaultContentSelector.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/DefaultContentSelector.java
new file mode 100644
index 0000000..427bb82
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/DefaultContentSelector.java
@@ -0,0 +1,134 @@
+/*
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.flex.forks.batik.bridge.svg12;
+
+import java.util.ArrayList;
+
+import org.apache.flex.forks.batik.dom.svg12.XBLOMContentElement;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A class to handle content selection when the includes attribute is not
+ * present.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: DefaultContentSelector.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class DefaultContentSelector extends AbstractContentSelector {
+
+    /**
+     * The selected nodes.
+     */
+    protected SelectedNodes selectedContent;
+
+    /**
+     * Creates a new XPathSubsetContentSelector object.
+     */
+    public DefaultContentSelector(ContentManager cm,
+                                  XBLOMContentElement content,
+                                  Element bound) {
+        super(cm, content, bound);
+    }
+
+    /**
+     * Returns a list of nodes that were matched by the given selector
+     * string.
+     */
+    public NodeList getSelectedContent() {
+        if (selectedContent == null) {
+            selectedContent = new SelectedNodes();
+        }
+        return selectedContent;
+    }
+
+    /**
+     * Forces this selector to update its selected nodes list.
+     * Returns true if the selected node list needed updating.
+     * This assumes that the previous content elements in this
+     * shadow tree (in document order) have up-to-date selectedContent
+     * lists.
+     */
+    boolean update() {
+        if (selectedContent == null) {
+            selectedContent = new SelectedNodes();
+            return true;
+        }
+        return selectedContent.update();
+    }
+
+    /**
+     * Implementation of NodeList that contains the nodes that matched
+     * this selector.
+     */
+    protected class SelectedNodes implements NodeList {
+
+        /**
+         * The selected nodes.
+         */
+        protected ArrayList nodes = new ArrayList(10);
+
+        /**
+         * Creates a new SelectedNodes object.
+         */
+        public SelectedNodes() {
+            update();
+        }
+
+        protected boolean update() {
+            ArrayList oldNodes = (ArrayList) nodes.clone();
+            nodes.clear();
+            for (Node n = boundElement.getFirstChild(); n != null; n = n.getNextSibling()) {
+                if (isSelected(n)) {
+                    continue;
+                }
+                nodes.add(n);
+            }
+            int nodesSize = nodes.size();
+            if (oldNodes.size() != nodesSize) {
+                return true;
+            }
+            for (int i = 0; i < nodesSize; i++) {
+                if (oldNodes.get(i) != nodes.get(i)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link org.w3c.dom.NodeList#item(int)}.
+         */
+        public Node item(int index) {
+            if (index < 0 || index >= nodes.size()) {
+                return null;
+            }
+            return (Node) nodes.get(index);
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link org.w3c.dom.NodeList#getLength()}.
+         */
+        public int getLength() {
+            return nodes.size();
+        }
+    }
+}