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:19 UTC

[04/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/svg12/SVG12ScriptingEnvironment.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12ScriptingEnvironment.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12ScriptingEnvironment.java
new file mode 100644
index 0000000..43cde23
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12ScriptingEnvironment.java
@@ -0,0 +1,334 @@
+/*
+
+   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.BridgeContext;
+import org.apache.flex.forks.batik.bridge.DocumentLoader;
+import org.apache.flex.forks.batik.bridge.Messages;
+import org.apache.flex.forks.batik.bridge.ScriptingEnvironment;
+import org.apache.flex.forks.batik.bridge.SVGUtilities;
+import org.apache.flex.forks.batik.dom.AbstractDocument;
+import org.apache.flex.forks.batik.dom.AbstractElement;
+import org.apache.flex.forks.batik.dom.events.EventSupport;
+import org.apache.flex.forks.batik.dom.svg12.SVGGlobal;
+import org.apache.flex.forks.batik.dom.svg12.XBLEventSupport;
+import org.apache.flex.forks.batik.dom.util.DOMUtilities;
+import org.apache.flex.forks.batik.dom.util.TriplyIndexedTable;
+import org.apache.flex.forks.batik.script.Interpreter;
+import org.apache.flex.forks.batik.util.SVGConstants;
+import org.apache.flex.forks.batik.util.SVG12Constants;
+import org.apache.flex.forks.batik.util.XMLConstants;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventTarget;
+import org.w3c.dom.events.EventListener;
+
+/**
+ * Manages scripting handlers for SVG 1.2 'handler' elements.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: SVG12ScriptingEnvironment.java 502538 2007-02-02 08:52:56Z dvholten $
+ */
+public class SVG12ScriptingEnvironment extends ScriptingEnvironment {
+
+    /**
+     * Constant used to describe handler scripts.
+     * {0} - URL of document containing script.
+     * {1} - Event type
+     * {2} - Event namespace
+     * {3} - line number of element.
+     */
+    public static final String HANDLER_SCRIPT_DESCRIPTION
+        = "SVG12ScriptingEnvironment.constant.handler.script.description";
+
+    /**
+     * Creates a new SVG12ScriptingEnvironment.
+     * @param ctx the bridge context
+     */
+    public SVG12ScriptingEnvironment(BridgeContext ctx) {
+        super(ctx);
+    }
+
+    /**
+     * The listeners for XML Events style handlers.
+     * Maps (event namespace, event local name, element) to a handler.
+     */
+    protected TriplyIndexedTable handlerScriptingListeners;
+
+    /**
+     * Adds DOM listeners to the document.
+     */
+    protected void addDocumentListeners() {
+        domNodeInsertedListener = new DOMNodeInsertedListener();
+        domNodeRemovedListener = new DOMNodeRemovedListener();
+        domAttrModifiedListener = new DOMAttrModifiedListener();
+        AbstractDocument doc = (AbstractDocument) document;
+        XBLEventSupport es = (XBLEventSupport) doc.initializeEventSupport();
+        es.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMNodeInserted",
+             domNodeInsertedListener, false);
+        es.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMNodeRemoved",
+             domNodeRemovedListener, false);
+        es.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMAttrModified",
+             domAttrModifiedListener, false);
+    }
+
+    /**
+     * Removes DOM listeners from the document.
+     */
+    protected void removeDocumentListeners() {
+        AbstractDocument doc = (AbstractDocument) document;
+        XBLEventSupport es = (XBLEventSupport) doc.initializeEventSupport();
+        es.removeImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMNodeInserted",
+             domNodeInsertedListener, false);
+        es.removeImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMNodeRemoved",
+             domNodeRemovedListener, false);
+        es.removeImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+             "DOMAttrModified",
+             domAttrModifiedListener, false);
+    }
+
+    /**
+     * The listener class for 'DOMNodeInserted' event.
+     */
+    protected class DOMNodeInsertedListener
+            extends ScriptingEnvironment.DOMNodeInsertedListener {
+        public void handleEvent(Event evt) {
+            super.handleEvent(EventSupport.getUltimateOriginalEvent(evt));
+        }
+    }
+
+    /**
+     * The listener class for 'DOMNodeRemoved' event.
+     */
+    protected class DOMNodeRemovedListener
+            extends ScriptingEnvironment.DOMNodeRemovedListener {
+        public void handleEvent(Event evt) {
+            super.handleEvent(EventSupport.getUltimateOriginalEvent(evt));
+        }
+    }
+
+    protected class DOMAttrModifiedListener
+            extends ScriptingEnvironment.DOMAttrModifiedListener {
+        public void handleEvent (Event evt) {
+            super.handleEvent(EventSupport.getUltimateOriginalEvent(evt));
+        }
+    }
+
+    /**
+     * Adds the scripting listeners to the given element.
+     */
+    protected void addScriptingListenersOn(Element elt) {
+        String eltNS = elt.getNamespaceURI();
+        String eltLN = elt.getLocalName();
+        if (SVGConstants.SVG_NAMESPACE_URI.equals(eltNS)
+                && SVG12Constants.SVG_HANDLER_TAG.equals(eltLN)) {
+            // For this 'handler' element, add a handler for the given
+            // event type.
+            AbstractElement tgt = (AbstractElement) elt.getParentNode();
+            String eventType = elt.getAttributeNS
+                (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+                 XMLConstants.XML_EVENTS_EVENT_ATTRIBUTE);
+            String eventNamespaceURI = XMLConstants.XML_EVENTS_NAMESPACE_URI;
+            if (eventType.indexOf(':') != -1) {
+                String prefix = DOMUtilities.getPrefix(eventType);
+                eventType = DOMUtilities.getLocalName(eventType);
+                eventNamespaceURI
+                    = ((AbstractElement) elt).lookupNamespaceURI(prefix);
+            }
+
+            EventListener listener = new HandlerScriptingEventListener
+                (eventNamespaceURI, eventType, (AbstractElement) elt);
+            tgt.addEventListenerNS
+                (eventNamespaceURI, eventType, listener, false, null);
+            if (handlerScriptingListeners == null) {
+                handlerScriptingListeners = new TriplyIndexedTable();
+            }
+            handlerScriptingListeners.put
+                (eventNamespaceURI, eventType, elt, listener);
+        }
+
+        super.addScriptingListenersOn(elt);
+    }
+
+    /**
+     * Removes the scripting listeners from the given element.
+     */
+    protected void removeScriptingListenersOn(Element elt) {
+        String eltNS = elt.getNamespaceURI();
+        String eltLN = elt.getLocalName();
+        if (SVGConstants.SVG_NAMESPACE_URI.equals(eltNS)
+                && SVG12Constants.SVG_HANDLER_TAG.equals(eltLN)) {
+            // For this 'handler' element, remove the handler for the given
+            // event type.
+            AbstractElement tgt = (AbstractElement) elt.getParentNode();
+            String eventType = elt.getAttributeNS
+                (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+                 XMLConstants.XML_EVENTS_EVENT_ATTRIBUTE);
+            String eventNamespaceURI = XMLConstants.XML_EVENTS_NAMESPACE_URI;
+            if (eventType.indexOf(':') != -1) {
+                String prefix = DOMUtilities.getPrefix(eventType);
+                eventType = DOMUtilities.getLocalName(eventType);
+                eventNamespaceURI
+                    = ((AbstractElement) elt).lookupNamespaceURI(prefix);
+            }
+
+            EventListener listener =
+                (EventListener) handlerScriptingListeners.put
+                    (eventNamespaceURI, eventType, elt, null);
+            tgt.removeEventListenerNS
+                (eventNamespaceURI, eventType, listener, false);
+        }
+
+        super.removeScriptingListenersOn(elt);
+    }
+
+    /**
+     * To handle a scripting event with an XML Events style handler.
+     */
+    protected class HandlerScriptingEventListener implements EventListener {
+
+        /**
+         * The namespace URI of the event type.
+         */
+        protected String eventNamespaceURI;
+
+        /**
+         * The event type.
+         */
+        protected String eventType;
+
+        /**
+         * The handler element.
+         */
+        protected AbstractElement handlerElement;
+
+        /**
+         * Creates a new HandlerScriptingEventListener.
+         * @param ns Namespace URI of the event type.
+         * @param et The event type.
+         * @param e The handler element.
+         */
+        public HandlerScriptingEventListener(String ns,
+                                             String et,
+                                             AbstractElement e) {
+            eventNamespaceURI = ns;
+            eventType = et;
+            handlerElement = e;
+        }
+
+        /**
+         * Runs the script.
+         */
+        public void handleEvent(Event evt) {
+            Element elt = (Element)evt.getCurrentTarget();
+            // Evaluate the script
+            String script = handlerElement.getTextContent();
+            if (script.length() == 0)
+                return;
+
+            DocumentLoader dl = bridgeContext.getDocumentLoader();
+            AbstractDocument d
+                = (AbstractDocument) handlerElement.getOwnerDocument();
+            int line = dl.getLineNumber(handlerElement);
+            final String desc = Messages.formatMessage
+                (HANDLER_SCRIPT_DESCRIPTION,
+                 new Object [] {d.getDocumentURI(),
+                                eventNamespaceURI,
+                                eventType,
+                                new Integer(line)});
+
+            // Find the scripting language
+            String lang = handlerElement.getAttributeNS
+                (null, SVGConstants.SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE);
+            if (lang.length() == 0) {
+                Element e = elt;
+                while (e != null &&
+                       (!SVGConstants.SVG_NAMESPACE_URI.equals
+                        (e.getNamespaceURI()) ||
+                        !SVGConstants.SVG_SVG_TAG.equals(e.getLocalName()))) {
+                    e = SVGUtilities.getParentElement(e);
+                }
+                if (e == null)
+                    return;
+
+                lang = e.getAttributeNS
+                    (null, SVGConstants.SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE);
+            }
+
+            runEventHandler(script, evt, lang, desc);
+        }
+    }
+
+    /**
+     * Creates a new Window object.
+     */
+    public org.apache.flex.forks.batik.script.Window createWindow(Interpreter interp,
+                                                       String lang) {
+        return new Global(interp, lang);
+    }
+
+    /**
+     * The SVGGlobal object.
+     */
+    protected class Global
+            extends ScriptingEnvironment.Window
+            implements SVGGlobal  {
+
+        /**
+         * Creates a new Global object.
+         */
+        public Global(Interpreter interp, String lang) {
+            super(interp, lang);
+        }
+
+        /**
+         * Implements
+         * {@link org.apache.flex.forks.batik.dom.svg12.SVGGlobal#startMouseCapture(EventTarget,boolean,boolean)}.
+         */
+        public void startMouseCapture(EventTarget target, boolean sendAll,
+                                      boolean autoRelease) {
+            // XXX not sure if it's right to do this on the
+            //     primary bridge context
+            ((SVG12BridgeContext) bridgeContext.getPrimaryBridgeContext())
+                .startMouseCapture(target, sendAll, autoRelease);
+        }
+
+        /**
+         * Stops mouse capture.
+         */
+        public void stopMouseCapture() {
+            // XXX not sure if it's right to do this on the
+            //     primary bridge context
+            ((SVG12BridgeContext) bridgeContext.getPrimaryBridgeContext())
+                .stopMouseCapture();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12TextElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12TextElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12TextElementBridge.java
new file mode 100644
index 0000000..8bb7fdb
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12TextElementBridge.java
@@ -0,0 +1,190 @@
+/*
+
+   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.Bridge;
+import org.apache.flex.forks.batik.bridge.BridgeContext;
+import org.apache.flex.forks.batik.bridge.SVGTextElementBridge;
+import org.apache.flex.forks.batik.dom.AbstractNode;
+import org.apache.flex.forks.batik.dom.svg12.XBLEventSupport;
+import org.apache.flex.forks.batik.dom.events.EventSupport;
+import org.apache.flex.forks.batik.dom.events.NodeEventTarget;
+import org.apache.flex.forks.batik.dom.xbl.NodeXBL;
+import org.apache.flex.forks.batik.util.XMLConstants;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.MutationEvent;
+
+/**
+ * Bridge class for SVG 'text' elements with support for text content
+ * that has been specified with XBL.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: SVG12TextElementBridge.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class SVG12TextElementBridge
+        extends SVGTextElementBridge
+        implements SVG12BridgeUpdateHandler {
+
+    /**
+     * Returns a new instance of this bridge.
+     */
+    public Bridge getInstance() {
+        return new SVG12TextElementBridge();
+    }
+
+    /**
+     * Adds the DOM listeners for this text bridge.
+     */
+    protected void addTextEventListeners(BridgeContext ctx, NodeEventTarget e) {
+        if (childNodeRemovedEventListener == null) {
+            childNodeRemovedEventListener =
+                new DOMChildNodeRemovedEventListener();
+        }
+        if (subtreeModifiedEventListener == null) {
+            subtreeModifiedEventListener =
+                new DOMSubtreeModifiedEventListener();
+        }
+
+        SVG12BridgeContext ctx12 = (SVG12BridgeContext) ctx;
+        AbstractNode n = (AbstractNode) e;
+        XBLEventSupport evtSupport =
+            (XBLEventSupport) n.initializeEventSupport();
+
+        //to be notified when a child is removed from the 
+        //<text> element.
+        evtSupport.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved",
+             childNodeRemovedEventListener, true);
+        ctx12.storeImplementationEventListenerNS
+            (e, XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved",
+             childNodeRemovedEventListener, true);
+        
+        //to be notified when the modification of the subtree
+        //of the <text> element is done
+        evtSupport.addImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMSubtreeModified",
+             subtreeModifiedEventListener, false);
+        ctx12.storeImplementationEventListenerNS
+            (e, XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMSubtreeModified",
+             subtreeModifiedEventListener, false);
+    }
+
+    /**
+     * Removes the DOM listeners for this text bridge.
+     */
+    protected void removeTextEventListeners(BridgeContext ctx,
+                                            NodeEventTarget e) {
+        AbstractNode n = (AbstractNode) e;
+        XBLEventSupport evtSupport =
+            (XBLEventSupport) n.initializeEventSupport();
+
+        evtSupport.removeImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved",
+             childNodeRemovedEventListener, true);
+        evtSupport.removeImplementationEventListenerNS
+            (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMSubtreeModified",
+             subtreeModifiedEventListener, false);
+    }
+
+    /**
+     * The DOM EventListener invoked when a node is removed.
+     */
+    protected class DOMChildNodeRemovedEventListener
+            extends SVGTextElementBridge.DOMChildNodeRemovedEventListener {
+        public void handleEvent(Event evt) {
+            super.handleEvent(EventSupport.getUltimateOriginalEvent(evt));
+        }
+    }
+
+    /**
+     * The DOM EventListener invoked when the subtree is modified.
+     */
+    protected class DOMSubtreeModifiedEventListener
+            extends SVGTextElementBridge.DOMSubtreeModifiedEventListener {
+        public void handleEvent(Event evt) {
+            super.handleEvent(EventSupport.getUltimateOriginalEvent(evt));
+        }
+    }
+
+    // Tree navigation ------------------------------------------------------
+
+    /**
+     * Returns the first child node of the given node that should be
+     * processed by the text bridge.
+     */
+    protected Node getFirstChild(Node n) {
+        return ((NodeXBL) n).getXblFirstChild();
+    }
+
+    /**
+     * Returns the next sibling node of the given node that should be
+     * processed by the text bridge.
+     */
+    protected Node getNextSibling(Node n) {
+        return ((NodeXBL) n).getXblNextSibling();
+    }
+
+    /**
+     * Returns the parent node of the given node that should be
+     * processed by the text bridge.
+     */
+    protected Node getParentNode(Node n) {
+        return ((NodeXBL) n).getXblParentNode();
+    }
+
+    // SVG12BridgeUpdateHandler //////////////////////////////////////////////
+
+    /**
+     * Invoked when an MutationEvent of type 'DOMCharacterDataModified' 
+     * is fired.
+     */
+    public void handleDOMCharacterDataModified(MutationEvent evt) {
+        Node childNode = (Node)evt.getTarget();
+        //if the parent is displayed, then discard the layout.
+        if (isParentDisplayed(childNode)) {
+            if (getParentNode(childNode) != childNode.getParentNode()) {
+                // This text node was selected with an xbl:content element,
+                // so a DOMSubtreeModified event is not going to be captured.
+                // Better recompute the text layout now.
+                computeLaidoutText(ctx, e, node);
+            } else {
+                laidoutText = null;
+            }
+        }
+    }
+
+    /**
+     * Invoked when a bindable element's binding has changed.
+     */
+    public void handleBindingEvent(Element bindableElement,
+                                   Element shadowTree) {
+    }
+
+    /**
+     * Invoked when the xblChildNodes property has changed because a
+     * descendant xbl:content element has updated its selected nodes.
+     */
+    public void handleContentSelectionChangedEvent
+            (ContentSelectionChangedEvent csce) {
+        computeLaidoutText(ctx, e, node);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12URIResolver.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12URIResolver.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12URIResolver.java
new file mode 100644
index 0000000..788fafc
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVG12URIResolver.java
@@ -0,0 +1,86 @@
+/*
+
+   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.DocumentLoader;
+import org.apache.flex.forks.batik.bridge.URIResolver;
+import org.apache.flex.forks.batik.dom.AbstractNode;
+import org.apache.flex.forks.batik.dom.xbl.NodeXBL;
+import org.apache.flex.forks.batik.dom.xbl.XBLShadowTreeElement;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.svg.SVGDocument;
+
+/**
+ * A URIResolver for SVG 1.2 documents.  This is to allow resolution of
+ * fragment IDs within shadow trees to work properly.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: SVG12URIResolver.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class SVG12URIResolver extends URIResolver {
+
+    /**
+     * Creates a new SVG12URIResolver object.
+     */
+    public SVG12URIResolver(SVGDocument doc, DocumentLoader dl) {
+        super(doc, dl);
+    }
+
+    /**
+     * Returns the base URI of the referer element.
+     */
+    protected String getRefererBaseURI(Element ref) {
+        AbstractNode aref = (AbstractNode) ref;
+        if (aref.getXblBoundElement() != null) {
+            return null;
+        }
+        return aref.getBaseURI();
+    }
+
+    /**
+     * Returns the node referenced by the given fragment identifier.
+     * This is called when the whole URI just contains a fragment identifier
+     * and there is no XML Base URI in effect.
+     * @param frag the URI fragment
+     * @param ref  the context element from which to resolve the URI fragment
+     */
+    protected Node getNodeByFragment(String frag, Element ref) {
+        NodeXBL refx = (NodeXBL) ref;
+        NodeXBL boundElt = (NodeXBL) refx.getXblBoundElement();
+        if (boundElt != null) {
+            XBLShadowTreeElement shadow
+                = (XBLShadowTreeElement) boundElt.getXblShadowTree();
+            Node n = shadow.getElementById(frag);
+            if (n != null) {
+                return n;
+            }
+            NodeList nl = refx.getXblDefinitions();
+            for (int i = 0; i < nl.getLength(); i++) {
+                n = nl.item(i).getOwnerDocument().getElementById(frag);
+                if (n != null) {
+                    return n;
+                }
+            }
+        }
+        return super.getNodeByFragment(frag, ref);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGFlowRootElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGFlowRootElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGFlowRootElementBridge.java
index 20264d2..ba40bff 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGFlowRootElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGFlowRootElementBridge.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
 
@@ -18,14 +19,16 @@
 
 package org.apache.flex.forks.batik.bridge.svg12;
 
+import java.awt.Color;
+import java.awt.RenderingHints;
 import java.awt.Shape;
 import java.awt.font.TextAttribute;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
 import java.text.AttributedCharacterIterator;
 import java.text.AttributedString;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.LinkedList;
@@ -33,21 +36,17 @@ import java.util.Map;
 
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.dom.events.EventTarget;
 
 import org.apache.flex.forks.batik.bridge.Bridge;
-import org.apache.flex.forks.batik.bridge.BridgeException;
 import org.apache.flex.forks.batik.bridge.BridgeContext;
 import org.apache.flex.forks.batik.bridge.CSSUtilities;
-import org.apache.flex.forks.batik.bridge.GraphicsNodeBridge;
+import org.apache.flex.forks.batik.bridge.CursorManager;
 import org.apache.flex.forks.batik.bridge.GVTBuilder;
 import org.apache.flex.forks.batik.bridge.SVGTextElementBridge;
 import org.apache.flex.forks.batik.bridge.SVGUtilities;
 import org.apache.flex.forks.batik.bridge.TextUtilities;
-import org.apache.flex.forks.batik.bridge.UnitProcessor;
 import org.apache.flex.forks.batik.bridge.UserAgent;
 import org.apache.flex.forks.batik.bridge.SVGAElementBridge;
-
 import org.apache.flex.forks.batik.css.engine.CSSEngine;
 import org.apache.flex.forks.batik.css.engine.SVGCSSEngine;
 import org.apache.flex.forks.batik.css.engine.value.ComputedValue;
@@ -55,47 +54,91 @@ import org.apache.flex.forks.batik.css.engine.value.svg12.SVG12ValueConstants;
 import org.apache.flex.forks.batik.css.engine.value.svg12.LineHeightValue;
 import org.apache.flex.forks.batik.css.engine.value.Value;
 import org.apache.flex.forks.batik.css.engine.value.ValueConstants;
-
+import org.apache.flex.forks.batik.dom.AbstractNode;
+import org.apache.flex.forks.batik.dom.events.NodeEventTarget;
+import org.apache.flex.forks.batik.dom.svg.SVGOMElement;
+import org.apache.flex.forks.batik.dom.svg12.SVGOMFlowRegionElement;
+import org.apache.flex.forks.batik.dom.svg12.XBLEventSupport;
 import org.apache.flex.forks.batik.dom.util.XMLSupport;
 import org.apache.flex.forks.batik.dom.util.XLinkSupport;
-
+import org.apache.flex.forks.batik.gvt.CompositeGraphicsNode;
 import org.apache.flex.forks.batik.gvt.GraphicsNode;
 import org.apache.flex.forks.batik.gvt.TextNode;
 import org.apache.flex.forks.batik.gvt.flow.BlockInfo;
 import org.apache.flex.forks.batik.gvt.flow.FlowTextNode;
 import org.apache.flex.forks.batik.gvt.flow.RegionInfo;
 import org.apache.flex.forks.batik.gvt.flow.TextLineBreaks;
-
 import org.apache.flex.forks.batik.gvt.text.GVTAttributedCharacterIterator;
 import org.apache.flex.forks.batik.gvt.text.TextPaintInfo;
 import org.apache.flex.forks.batik.gvt.text.TextPath;
-
 import org.apache.flex.forks.batik.util.SVG12Constants;
 import org.apache.flex.forks.batik.util.SVG12CSSConstants;
+import org.apache.flex.forks.batik.util.XMLConstants;
+
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventListener;
 
 /**
  * Bridge class for the &lt;flowRoot> element.
  *
  * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
- * @version $Id: SVGFlowRootElementBridge.java,v 1.4 2005/03/27 08:58:30 cam Exp $
+ * @version $Id: SVGFlowRootElementBridge.java 594018 2007-11-12 04:17:41Z cam $
  */
-public class SVGFlowRootElementBridge extends SVGTextElementBridge {
+public class SVGFlowRootElementBridge extends SVG12TextElementBridge {
+
+    public static final
+        AttributedCharacterIterator.Attribute FLOW_PARAGRAPH =
+        GVTAttributedCharacterIterator.TextAttribute.FLOW_PARAGRAPH;
 
-    public static final AttributedCharacterIterator.Attribute FLOW_PARAGRAPH
-        = GVTAttributedCharacterIterator.TextAttribute.FLOW_PARAGRAPH;
+    public static final
+        AttributedCharacterIterator.Attribute FLOW_EMPTY_PARAGRAPH =
+        GVTAttributedCharacterIterator.TextAttribute.FLOW_EMPTY_PARAGRAPH;
 
-    public static final AttributedCharacterIterator.Attribute 
-        FLOW_EMPTY_PARAGRAPH
-        = GVTAttributedCharacterIterator.TextAttribute.FLOW_EMPTY_PARAGRAPH;
+    public static final
+        AttributedCharacterIterator.Attribute FLOW_LINE_BREAK =
+        GVTAttributedCharacterIterator.TextAttribute.FLOW_LINE_BREAK;
 
-    public static final AttributedCharacterIterator.Attribute FLOW_LINE_BREAK
-        = GVTAttributedCharacterIterator.TextAttribute.FLOW_LINE_BREAK;
-    
-    public static final AttributedCharacterIterator.Attribute FLOW_REGIONS
-        = GVTAttributedCharacterIterator.TextAttribute.FLOW_REGIONS;
+    public static final
+        AttributedCharacterIterator.Attribute FLOW_REGIONS =
+        GVTAttributedCharacterIterator.TextAttribute.FLOW_REGIONS;
 
-    public static final AttributedCharacterIterator.Attribute LINE_HEIGHT
-        = GVTAttributedCharacterIterator.TextAttribute.LINE_HEIGHT;
+    public static final
+        AttributedCharacterIterator.Attribute LINE_HEIGHT =
+        GVTAttributedCharacterIterator.TextAttribute.LINE_HEIGHT;
+
+    public static final
+    GVTAttributedCharacterIterator.TextAttribute TEXTPATH =
+        GVTAttributedCharacterIterator.TextAttribute.TEXTPATH;
+
+    public static final
+    GVTAttributedCharacterIterator.TextAttribute ANCHOR_TYPE =
+        GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE;
+
+    public static final
+    GVTAttributedCharacterIterator.TextAttribute LETTER_SPACING =
+        GVTAttributedCharacterIterator.TextAttribute.LETTER_SPACING;
+
+    public static final
+    GVTAttributedCharacterIterator.TextAttribute WORD_SPACING =
+        GVTAttributedCharacterIterator.TextAttribute.WORD_SPACING;
+
+    public static final
+    GVTAttributedCharacterIterator.TextAttribute KERNING =
+        GVTAttributedCharacterIterator.TextAttribute.KERNING;
+
+    /**
+     * Map of flowRegion elements to their graphics nodes.
+     */
+    protected Map flowRegionNodes;
+
+    protected TextNode textNode;
+
+    protected TextNode getTextNode() { return textNode; }
+
+    /**
+     * Listener for flowRegion changes.
+     */
+    protected RegionChangeListener regionChangeListener;
 
     /**
      * Constructs a new bridge for the &lt;flowRoot> element.
@@ -130,6 +173,71 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
         return false;
     }
 
+    /**
+     * 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 cgn = new CompositeGraphicsNode();
+
+        // 'transform'
+        String s = e.getAttributeNS(null, SVG_TRANSFORM_ATTRIBUTE);
+        if (s.length() != 0) {
+            cgn.setTransform
+                (SVGUtilities.convertTransform(e, SVG_TRANSFORM_ATTRIBUTE, s,
+                                               ctx));
+        }
+        // 'visibility'
+        cgn.setVisible(CSSUtilities.convertVisibility(e));
+
+        // 'text-rendering' and 'color-rendering'
+        RenderingHints hints = null;
+        hints = CSSUtilities.convertColorRendering(e, hints);
+        hints = CSSUtilities.convertTextRendering (e, hints);
+        if (hints != null) {
+            cgn.setRenderingHints(hints);
+        }
+
+        // first child holds the flow region nodes
+        CompositeGraphicsNode cgn2 = new CompositeGraphicsNode();
+        cgn.add(cgn2);
+
+        // second child is the text node
+        FlowTextNode tn = (FlowTextNode)instantiateGraphicsNode();
+        tn.setLocation(getLocation(ctx, e));
+
+        // specify the text painter to use
+        if (ctx.getTextPainter() != null) {
+            tn.setTextPainter(ctx.getTextPainter());
+        }
+        textNode = tn;
+        cgn.add(tn);
+
+        associateSVGContext(ctx, e, cgn);
+
+        // traverse the children to add SVGContext
+        Node child = getFirstChild(e);
+        while (child != null) {
+            if (child.getNodeType() == Node.ELEMENT_NODE) {
+                addContextToChild(ctx,(Element)child);
+            }
+            child = getNextSibling(child);
+        }
+
+        return cgn;
+    }
+
+    /**
+     * Creates the graphics node for this element.
+     */
     protected GraphicsNode instantiateGraphicsNode() {
         return new FlowTextNode();
     }
@@ -167,14 +275,137 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
                 nodeName.equals(SVG12Constants.SVG_FLOW_REGION_BREAK_TAG) ||
                 nodeName.equals(SVG12Constants.SVG_FLOW_SPAN_TAG));
     }
-    
-    protected void computeLaidoutText(BridgeContext ctx, 
+
+    /**
+     * 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) {
+        CompositeGraphicsNode cgn = (CompositeGraphicsNode) node;
+
+        // build flowRegion shapes
+        boolean isStatic = !ctx.isDynamic();
+        if (isStatic) {
+            flowRegionNodes = new HashMap();
+        } else {
+            regionChangeListener = new RegionChangeListener();
+        }
+        CompositeGraphicsNode cgn2 = (CompositeGraphicsNode) cgn.get(0);
+        GVTBuilder builder = ctx.getGVTBuilder();
+        for (Node n = getFirstChild(e); n != null; n = getNextSibling(n)) {
+            if (n instanceof SVGOMFlowRegionElement) {
+                for (Node m = getFirstChild(n);
+                        m != null;
+                        m = getNextSibling(m)) {
+                    if (m.getNodeType() != Node.ELEMENT_NODE) {
+                        continue;
+                    }
+                    GraphicsNode gn = builder.build(ctx, (Element) m);
+                    if (gn != null) {
+                        cgn2.add(gn);
+                        if (isStatic) {
+                            flowRegionNodes.put(m, gn);
+                        }
+                    }
+                }
+
+                if (!isStatic) {
+                    AbstractNode an = (AbstractNode) n;
+                    XBLEventSupport es =
+                        (XBLEventSupport) an.initializeEventSupport();
+                    es.addImplementationEventListenerNS
+                        (SVG_NAMESPACE_URI, "shapechange", regionChangeListener,
+                         false);
+                }
+            }
+        }
+
+        // build text node
+        GraphicsNode tn = (GraphicsNode) cgn.get(1);
+        super.buildGraphicsNode(ctx, e, tn);
+
+        // Drop references once static build is completed.
+        flowRegionNodes = null;
+    }
+
+    protected void computeLaidoutText(BridgeContext ctx,
                                        Element e,
                                        GraphicsNode node) {
         super.computeLaidoutText(ctx, getFlowDivElement(e), node);
     }
 
     /**
+     * Add to the element children of the node, a
+     * <code>SVGContext</code> to support dynamic update. This is
+     * recursive, the children of the nodes are also traversed to add
+     * to the support elements their context
+     *
+     * @param ctx a <code>BridgeContext</code> value
+     * @param e an <code>Element</code> value
+     *
+     * @see org.apache.flex.forks.batik.dom.svg.SVGContext
+     * @see org.apache.flex.forks.batik.bridge.BridgeUpdateHandler
+     */
+    protected void addContextToChild(BridgeContext ctx, Element e) {
+        if (SVG_NAMESPACE_URI.equals(e.getNamespaceURI())) {
+            String ln = e.getLocalName();
+            if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG)
+                    || ln.equals(SVG12Constants.SVG_FLOW_LINE_TAG)
+                    || ln.equals(SVG12Constants.SVG_FLOW_PARA_TAG)
+                    || ln.equals(SVG12Constants.SVG_FLOW_SPAN_TAG)) {
+                ((SVGOMElement) e).setSVGContext
+                    (new FlowContentBridge(ctx, this, e));
+            }
+        }
+
+        // traverse the children to add SVGContext
+        Node child = getFirstChild(e);
+        while (child != null) {
+            if (child.getNodeType() == Node.ELEMENT_NODE) {
+                addContextToChild(ctx,(Element)child);
+            }
+            child = getNextSibling(child);
+        }
+    }
+
+    /**
+     * From the <code>SVGContext</code> from the element children of the node.
+     *
+     * @param ctx the <code>BridgeContext</code> for the document
+     * @param e the <code>Element</code> whose subtree's elements will have
+     *   threir <code>SVGContext</code>s removed
+     *
+     * @see org.apache.flex.forks.batik.dom.svg.SVGContext
+     * @see org.apache.flex.forks.batik.bridge.BridgeUpdateHandler
+     */
+    protected void removeContextFromChild(BridgeContext ctx, Element e) {
+        if (SVG_NAMESPACE_URI.equals(e.getNamespaceURI())) {
+            String ln = e.getLocalName();
+            if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG)
+                    || ln.equals(SVG12Constants.SVG_FLOW_LINE_TAG)
+                    || ln.equals(SVG12Constants.SVG_FLOW_PARA_TAG)
+                    || ln.equals(SVG12Constants.SVG_FLOW_SPAN_TAG)) {
+                ((AbstractTextChildBridgeUpdateHandler)
+                    ((SVGOMElement) e).getSVGContext()).dispose();
+            }
+        }
+
+        Node child = getFirstChild(e);
+        while (child != null) {
+            if (child.getNodeType() == Node.ELEMENT_NODE) {
+                removeContextFromChild(ctx, (Element)child);
+            }
+            child = getNextSibling(child);
+        }
+    }
+
+    /**
      * Creates the attributed string which represents the given text
      * element children.
      *
@@ -183,8 +414,11 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
      */
     protected AttributedString buildAttributedString(BridgeContext ctx,
                                                      Element element) {
+        if (element == null) return null;
+
         List rgns = getRegions(ctx, element);
         AttributedString ret = getFlowDiv(ctx, element);
+        if (ret == null) return ret;
         ret.addAttribute(FLOW_REGIONS, rgns, 0, 1);
         TextLineBreaks.findLineBrk(ret);
         // dumpACIWord(ret);
@@ -192,24 +426,28 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
     }
 
     protected void dumpACIWord(AttributedString as) {
-        String chars = "";
-        String brkStr = "";
+        if (as == null) return;
+
+        StringBuffer chars = new StringBuffer();
+        StringBuffer brkStr = new StringBuffer();
         AttributedCharacterIterator aci = as.getIterator();
         AttributedCharacterIterator.Attribute WORD_LIMIT =
             TextLineBreaks.WORD_LIMIT;
 
-        for (char ch = aci.current(); 
+        for (char ch = aci.current();
              ch!=AttributedCharacterIterator.DONE;
              ch = aci.next()) {
-            chars  += ch + "  ";
-            int w = ((Integer)aci.getAttribute(WORD_LIMIT)).intValue();
-            if (w >=10)
-                brkStr += ""+w+" ";
-            else 
-                brkStr += ""+w+"  ";
-        }
-        System.out.println(chars);
-        System.out.println(brkStr);
+
+                chars.append( ch ).append( ' ' ).append( ' ' );
+                int w = ((Integer)aci.getAttribute(WORD_LIMIT)).intValue();
+                brkStr.append( w ).append( ' ' );
+                if (w < 10) {
+                    // for small values append another ' '
+                    brkStr.append( ' ' );
+                }
+        }
+        System.out.println( chars.toString() );
+        System.out.println( brkStr.toString() );
     }
 
     protected Element getFlowDivElement(Element elem) {
@@ -220,9 +458,9 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
         if (nodeName.equals(SVG12Constants.SVG_FLOW_DIV_TAG)) return elem;
 
         if (!nodeName.equals(SVG12Constants.SVG_FLOW_ROOT_TAG)) return null;
-        
-        for (Node n = elem.getFirstChild();
-             n != null; n = n.getNextSibling()) {
+
+        for (Node n = getFirstChild(elem);
+             n != null; n = getNextSibling(n)) {
             if (n.getNodeType()     != Node.ELEMENT_NODE) continue;
 
             String nNS = n.getNamespaceURI();
@@ -230,7 +468,7 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
 
             Element e = (Element)n;
             String ln = e.getLocalName();
-            if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG)) 
+            if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG))
                 return e;
         }
         return null;
@@ -245,33 +483,49 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
 
     protected AttributedString gatherFlowPara
         (BridgeContext ctx, Element div) {
+        TextPaintInfo divTPI = new TextPaintInfo();
+        // Set some basic props so we can get bounds info for complex paints.
+        divTPI.visible   = true;
+        divTPI.fillPaint = Color.black;
+        elemTPI.put(div, divTPI);
+
         AttributedStringBuffer asb = new AttributedStringBuffer();
         List paraEnds  = new ArrayList();
         List paraElems = new ArrayList();
         List lnLocs    = new ArrayList();
-        for (Node n = div.getFirstChild();
-             n != null; n = n.getNextSibling()) {
-            if (n.getNodeType()     != Node.ELEMENT_NODE) continue;
-            if (!getNamespaceURI().equals(n.getNamespaceURI())) continue;
+        for (Node n = getFirstChild(div);
+             n != null;
+             n = getNextSibling(n)) {
+
+            if (n.getNodeType() != Node.ELEMENT_NODE
+                    || !getNamespaceURI().equals(n.getNamespaceURI())) {
+                continue;
+            }
             Element e = (Element)n;
 
             String ln = e.getLocalName();
             if (ln.equals(SVG12Constants.SVG_FLOW_PARA_TAG)) {
-                fillAttributedStringBuffer(ctx, e, true, null, asb, lnLocs);
+                fillAttributedStringBuffer
+                    (ctx, e, true, null, null, asb, lnLocs);
 
                 paraElems.add(e);
                 paraEnds.add(new Integer(asb.length()));
             } else if (ln.equals(SVG12Constants.SVG_FLOW_REGION_BREAK_TAG)) {
-                fillAttributedStringBuffer(ctx, e, true, null, asb, lnLocs);
+                fillAttributedStringBuffer
+                    (ctx, e, true, null, null, asb, lnLocs);
 
                 paraElems.add(e);
                 paraEnds.add(new Integer(asb.length()));
             }
         }
+        divTPI.startChar = 0;
+        divTPI.endChar   = asb.length()-1;
 
         // Layer in the PARAGRAPH/LINE_BREAK Attributes so we can
         // break up text chunks.
         AttributedString ret = asb.toAttributedString();
+        if (ret == null)
+            return null;
 
         // Note: The Working Group (in conjunction with XHTML working
         // group) has decided that multiple line elements collapse.
@@ -282,7 +536,7 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
             if (nextLN == prevLN) continue;
 
             // System.out.println("Attr: [" + prevLN + "," + nextLN + "]");
-            ret.addAttribute(FLOW_LINE_BREAK, 
+            ret.addAttribute(FLOW_LINE_BREAK,
                              new Object(),
                              prevLN, nextLN);
             prevLN  = nextLN;
@@ -301,7 +555,7 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
                 continue;
             }
             // System.out.println("Para: [" + start + ", " + end + "]");
-            ret.addAttribute(FLOW_PARAGRAPH, makeBlockInfo(ctx, elem), 
+            ret.addAttribute(FLOW_PARAGRAPH, makeBlockInfo(ctx, elem),
                              start, end);
             if (emptyPara != null) {
                 ret.addAttribute(FLOW_EMPTY_PARAGRAPH, emptyPara, start, end);
@@ -312,15 +566,18 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
         return ret;
     }
 
+    /**
+     * Returns a list of Shapes that define the flow regions.
+     */
     protected List getRegions(BridgeContext ctx, Element element)  {
         // Element comes in as flowDiv element we want flowRoot.
         element = (Element)element.getParentNode();
         List ret = new LinkedList();
-        for (Node n = element.getFirstChild();
-             n != null; n = n.getNextSibling()) {
-            
+        for (Node n = getFirstChild(element);
+             n != null; n = getNextSibling(n)) {
+
             if (n.getNodeType()     != Node.ELEMENT_NODE) continue;
-            if (!SVG12Constants.SVG_NAMESPACE_URI.equals(n.getNamespaceURI())) 
+            if (!SVG12Constants.SVG_NAMESPACE_URI.equals(n.getNamespaceURI()))
                 continue;
 
             Element e = (Element)n;
@@ -329,32 +586,34 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
 
             // our default alignment is to the top of the flow rect.
             float verticalAlignment = 0.0f;
-            
+
             gatherRegionInfo(ctx, e, verticalAlignment, ret);
         }
 
         return ret;
     }
-    
+
     protected void gatherRegionInfo(BridgeContext ctx, Element rgn,
                                     float verticalAlign, List regions) {
 
-        GVTBuilder builder = ctx.getGVTBuilder();
-        for (Node n = rgn.getFirstChild(); 
-             n != null; n = n.getNextSibling()) {
+        boolean isStatic = !ctx.isDynamic();
+        for (Node n = getFirstChild(rgn); n != null; n = getNextSibling(n)) {
 
-            if (n.getNodeType()     != Node.ELEMENT_NODE) continue;
-            if (!getNamespaceURI().equals(n.getNamespaceURI())) continue;
-            Element e = (Element)n;
-
-            GraphicsNode gn = builder.build(ctx, e) ;
-            if (gn == null) continue;
+            if (n.getNodeType() != Node.ELEMENT_NODE) {
+                continue;
+            }
 
+            GraphicsNode gn = isStatic ? (GraphicsNode) flowRegionNodes.get(n)
+                                       : ctx.getGraphicsNode(n);
             Shape s = gn.getOutline();
-            if (s == null) continue;
+            if (s == null) {
+                continue;
+            }
+
             AffineTransform at = gn.getTransform();
-            if (at != null) 
+            if (at != null) {
                 s = at.createTransformedShape(s);
+            }
             regions.add(new RegionInfo(s, verticalAlign));
         }
     }
@@ -368,6 +627,7 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
                                               Element element,
                                               boolean top,
                                               Integer bidiLevel,
+                                              Map initialAttributes,
                                               AttributedStringBuffer asb,
                                               List lnLocs) {
         // 'requiredFeatures', 'requiredExtensions', 'systemLanguage' &
@@ -381,40 +641,49 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
         boolean preserve = s.equals(SVG_PRESERVE_VALUE);
         boolean prevEndsWithSpace;
         Element nodeElement = element;
+        int elementStartChar = asb.length();
 
-        if (top)
+        if (top) {
             endLimit = startLen = asb.length();
-
-        if (preserve)
+        }
+        if (preserve) {
             endLimit = startLen;
-        
-	Map map = getAttributeMap(ctx, element, null, bidiLevel);
-	Object o = map.get(TextAttribute.BIDI_EMBEDDING);
+        }
+
+        Map map = initialAttributes == null
+                ? new HashMap()
+                : new HashMap(initialAttributes);
+        initialAttributes =
+            getAttributeMap(ctx, element, null, bidiLevel, map);
+        Object o = map.get(TextAttribute.BIDI_EMBEDDING);
         Integer subBidiLevel = bidiLevel;
-	if (o != null)
-	    subBidiLevel = (Integer)o;
+        if (o != null) {
+            subBidiLevel = (Integer) o;
+        }
 
         int lineBreak = -1;
-        if (lnLocs.size() != 0)
+        if (lnLocs.size() != 0) {
             lineBreak = ((Integer)lnLocs.get(lnLocs.size()-1)).intValue();
+        }
 
-        for (Node n = element.getFirstChild();
+        for (Node n = getFirstChild(element);
              n != null;
-             n = n.getNextSibling()) {
-            
+             n = getNextSibling(n)) {
+
             if (preserve) {
                 prevEndsWithSpace = false;
             } else {
                 int len = asb.length();
-                if (len == startLen) 
+                if (len == startLen) {
                     prevEndsWithSpace = true;
-                else {
+                } else {
                     prevEndsWithSpace = (asb.getLastChar() == ' ');
                     int idx = lnLocs.size()-1;
                     if (!prevEndsWithSpace && (idx >= 0)) {
                         Integer i = (Integer)lnLocs.get(idx);
-                        if (i.intValue() == len)
+                        if (i.intValue() == len) {
                             prevEndsWithSpace = true;
+                        }
                     }
                 }
             }
@@ -424,71 +693,99 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
                 // System.out.println("Element: " + n);
                 if (!SVG_NAMESPACE_URI.equals(n.getNamespaceURI()))
                     break;
-                
+
                 nodeElement = (Element)n;
 
                 String ln = n.getLocalName();
 
                 if (ln.equals(SVG12Constants.SVG_FLOW_LINE_TAG)) {
-                    fillAttributedStringBuffer(ctx, nodeElement, 
-                                               false, subBidiLevel, 
-					       asb, lnLocs);
-                    // System.out.println("Line: " + asb.length() + 
+                    int before = asb.length();
+                    fillAttributedStringBuffer(ctx, nodeElement, false,
+                                               subBidiLevel, initialAttributes,
+                                               asb, lnLocs);
+                    // System.out.println("Line: " + asb.length() +
                     //                    " - '" +  asb + "'");
                     lineBreak = asb.length();
                     lnLocs.add(new Integer(lineBreak));
+                    if (before != lineBreak) {
+                        initialAttributes = null;
+                    }
                 } else if (ln.equals(SVG12Constants.SVG_FLOW_SPAN_TAG) ||
                            ln.equals(SVG12Constants.SVG_ALT_GLYPH_TAG)) {
-                    fillAttributedStringBuffer(ctx, nodeElement,
-                                               false, subBidiLevel, 
-					       asb, lnLocs);
+                    int before = asb.length();
+                    fillAttributedStringBuffer(ctx, nodeElement, false,
+                                               subBidiLevel, initialAttributes,
+                                               asb, lnLocs);
+                    if (asb.length() != before) {
+                        initialAttributes = null;
+                    }
                 } else if (ln.equals(SVG_A_TAG)) {
                     if (ctx.isInteractive()) {
-                        EventTarget target = (EventTarget)nodeElement;
+                        NodeEventTarget target = (NodeEventTarget)nodeElement;
                         UserAgent ua = ctx.getUserAgent();
-                        target.addEventListener
-                            (SVG_EVENT_CLICK, 
-                             new SVGAElementBridge.AnchorListener(ua),
-                             false);
-                    
-                        target.addEventListener
-                            (SVG_EVENT_MOUSEOVER,
-                             new SVGAElementBridge.CursorMouseOverListener(ua),
-                             false);
-                    
-                        target.addEventListener
-                            (SVG_EVENT_MOUSEOUT,
-                             new SVGAElementBridge.CursorMouseOutListener(ua),
-                             false);
+                        SVGAElementBridge.CursorHolder ch;
+                        ch = new SVGAElementBridge.CursorHolder
+                            (CursorManager.DEFAULT_CURSOR);
+                        target.addEventListenerNS
+                            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+                             SVG_EVENT_CLICK,
+                             new SVGAElementBridge.AnchorListener(ua, ch),
+                             false, null);
+
+                        target.addEventListenerNS
+                            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+                             SVG_EVENT_MOUSEOVER,
+                             new SVGAElementBridge.CursorMouseOverListener(ua,ch),
+                             false, null);
+
+                        target.addEventListenerNS
+                            (XMLConstants.XML_EVENTS_NAMESPACE_URI,
+                             SVG_EVENT_MOUSEOUT,
+                             new SVGAElementBridge.CursorMouseOutListener(ua,ch),
+                             false, null);
                     }
-                    fillAttributedStringBuffer(ctx,
-                                               nodeElement,
-                                               false, subBidiLevel,
+                    int before = asb.length();
+                    fillAttributedStringBuffer(ctx, nodeElement, false,
+                                               subBidiLevel, initialAttributes,
                                                asb, lnLocs);
+                    if (asb.length() != before) {
+                        initialAttributes = null;
+                    }
                 } else if (ln.equals(SVG_TREF_TAG)) {
                     String uriStr = XLinkSupport.getXLinkHref((Element)n);
                     Element ref = ctx.getReferencedElement((Element)n, uriStr);
                     s = TextUtilities.getElementContent(ref);
                     s = normalizeString(s, preserve, prevEndsWithSpace);
-                    if (s != null) {
-                        Map m = getAttributeMap(ctx, nodeElement, null, 
-						bidiLevel);
+                    if (s.length() != 0) {
+                        int trefStart = asb.length();
+                        Map m = new HashMap();
+                        getAttributeMap(ctx, nodeElement, null, bidiLevel, m);
                         asb.append(s, m);
+                        int trefEnd = asb.length() - 1;
+                        TextPaintInfo tpi;
+                        tpi = (TextPaintInfo)elemTPI.get(nodeElement);
+                        tpi.startChar = trefStart;
+                        tpi.endChar   = trefEnd;
                     }
                 }
                 break;
-                
+
             case Node.TEXT_NODE:
             case Node.CDATA_SECTION_NODE:
                 s = n.getNodeValue();
                 s = normalizeString(s, preserve, prevEndsWithSpace);
-                asb.append(s, map);
-                if (preserve)
-                    endLimit = asb.length();
+                if (s.length() != 0) {
+                    asb.append(s, map);
+                    if (preserve) {
+                        endLimit = asb.length();
+                    }
+                    initialAttributes = null;
+                }
             }
         }
 
         if (top) {
+            boolean strippedSome = false;
             while ((endLimit < asb.length()) && (asb.getLastChar() == ' ')) {
                 int idx = lnLocs.size()-1;
                 int len = asb.length();
@@ -508,45 +805,41 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
                     }
                 }
                 asb.stripLast();
+                strippedSome = true;
+            }
+            if (strippedSome) {
+                Iterator iter = elemTPI.values().iterator();
+                while (iter.hasNext()) {
+                    TextPaintInfo tpi = (TextPaintInfo)iter.next();
+                    if (tpi.endChar >= asb.length()) {
+                        tpi.endChar = asb.length()-1;
+                        if (tpi.startChar > tpi.endChar)
+                            tpi.startChar = tpi.endChar;
+                    }
+                }
             }
         }
+
+        int elementEndChar = asb.length()-1;
+        TextPaintInfo tpi = (TextPaintInfo)elemTPI.get(element);
+        tpi.startChar = elementStartChar;
+        tpi.endChar   = elementEndChar;
     }
 
-    /**
-     * Returns the map to pass to the current characters.
-     */
     protected Map getAttributeMap(BridgeContext ctx,
                                   Element element,
                                   TextPath textPath,
-                                  Integer bidiLevel) {
-        Map result = super.getAttributeMap(ctx, element, textPath, bidiLevel);
+                                  Integer bidiLevel,
+                                  Map result) {
+        Map inheritingMap =
+            super.getAttributeMap(ctx, element, textPath, bidiLevel, result);
 
         float fontSize   = TextUtilities.convertFontSize(element).floatValue();
         float lineHeight = getLineHeight(ctx, element, fontSize);
         result.put(LINE_HEIGHT, new Float(lineHeight));
-        
-        return result;
-    }
 
-    protected final static 
-        GVTAttributedCharacterIterator.TextAttribute TEXTPATH = 
-        GVTAttributedCharacterIterator.TextAttribute.TEXTPATH;
-
-    protected final static 
-        GVTAttributedCharacterIterator.TextAttribute ANCHOR_TYPE = 
-        GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE;
-
-    protected final static 
-        GVTAttributedCharacterIterator.TextAttribute LETTER_SPACING = 
-        GVTAttributedCharacterIterator.TextAttribute.LETTER_SPACING;
-
-    protected final static 
-        GVTAttributedCharacterIterator.TextAttribute WORD_SPACING = 
-        GVTAttributedCharacterIterator.TextAttribute.WORD_SPACING;
-
-    protected final static 
-        GVTAttributedCharacterIterator.TextAttribute KERNING = 
-        GVTAttributedCharacterIterator.TextAttribute.KERNING;
+        return inheritingMap;
+    }
 
     protected void checkMap(Map attrs) {
         if (attrs.containsKey(TEXTPATH)) {
@@ -610,9 +903,9 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
 
         v = CSSUtilities.getComputedStyle(element, textAlignIndex);
         if (v == ValueConstants.INHERIT_VALUE) {
-            v = CSSUtilities.getComputedStyle(element, 
+            v = CSSUtilities.getComputedStyle(element,
                                               SVGCSSEngine.DIRECTION_INDEX);
-            if (v == ValueConstants.LTR_VALUE) 
+            if (v == ValueConstants.LTR_VALUE)
                 v = SVG12ValueConstants.START_VALUE;
             else
                 v = SVG12ValueConstants.END_VALUE;
@@ -627,21 +920,20 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
         else
             textAlign = BlockInfo.ALIGN_FULL;
 
-        Map   fontAttrs      = getFontProperties(ctx, element, null);
+        Map   fontAttrs      = new HashMap(20);
+        List  fontList       = getFontList(ctx, element, fontAttrs);
         Float fs             = (Float)fontAttrs.get(TextAttribute.SIZE);
         float fontSize       = fs.floatValue();
         float lineHeight     = getLineHeight(ctx, element, fontSize);
-        List  fontFamilyList = getFontFamilyList(element, ctx);
 
         String ln = element.getLocalName();
         boolean rgnBr;
         rgnBr = ln.equals(SVG12Constants.SVG_FLOW_REGION_BREAK_TAG);
-        return new BlockInfo(top, right, bottom, left, indent, textAlign, 
-                             lineHeight, fontFamilyList, fontAttrs,
-                             rgnBr);
+        return new BlockInfo(top, right, bottom, left, indent, textAlign,
+                             lineHeight, fontList, fontAttrs, rgnBr);
     }
 
-    protected float getLineHeight(BridgeContext ctx, Element element, 
+    protected float getLineHeight(BridgeContext ctx, Element element,
                                   float fontSize) {
         if (lineHeightIndex == -1) initCSSPropertyIndexes(element);
 
@@ -659,4 +951,34 @@ public class SVGFlowRootElementBridge extends SVGTextElementBridge {
             lineHeight *= fontSize;
         return lineHeight;
     }
+
+    /**
+     * Bridge class for flow text children that contain text.
+     */
+    protected class FlowContentBridge extends AbstractTextChildTextContent {
+
+        /**
+         * Creates a new FlowContentBridge.
+         */
+        public FlowContentBridge(BridgeContext ctx,
+                                 SVGTextElementBridge parent,
+                                 Element e) {
+            super(ctx, parent, e);
+        }
+    }
+
+    /**
+     * svg:shapechange listener for flowRegion elements.
+     */
+    protected class RegionChangeListener implements EventListener {
+
+        /**
+         * Handles the svg:shapechange event.
+         */
+        public void handleEvent(Event evt) {
+            // the flowRegion geometry may have changed, so relayout text
+            laidoutText = null;
+            computeLaidoutText(ctx, e, getTextNode());
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGMultiImageElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGMultiImageElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGMultiImageElementBridge.java
index bac6212..61554c8 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGMultiImageElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGMultiImageElementBridge.java
@@ -1,10 +1,11 @@
 /*
 
-   Copyright 2002-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
 
@@ -34,9 +35,9 @@ import org.apache.flex.forks.batik.bridge.BridgeException;
 import org.apache.flex.forks.batik.bridge.CSSUtilities;
 import org.apache.flex.forks.batik.bridge.SVGImageElementBridge;
 import org.apache.flex.forks.batik.bridge.SVGUtilities;
+import org.apache.flex.forks.batik.bridge.UnitProcessor;
 import org.apache.flex.forks.batik.bridge.Viewport;
-import org.apache.flex.forks.batik.dom.svg.SVGOMElement;
-import org.apache.flex.forks.batik.dom.svg.XMLBaseSupport;
+import org.apache.flex.forks.batik.dom.AbstractNode;
 import org.apache.flex.forks.batik.dom.util.XLinkSupport;
 import org.apache.flex.forks.batik.gvt.GraphicsNode;
 import org.apache.flex.forks.batik.gvt.ImageNode;
@@ -70,7 +71,7 @@ import org.w3c.dom.Node;
  *
  *
  * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
- * @version $Id: SVGMultiImageElementBridge.java,v 1.4 2005/03/27 08:58:30 cam Exp $
+ * @version $Id: SVGMultiImageElementBridge.java 475477 2006-11-15 22:44:28Z cam $
  */
 public class SVGMultiImageElementBridge extends SVGImageElementBridge {
 
@@ -94,7 +95,7 @@ public class SVGMultiImageElementBridge extends SVGImageElementBridge {
      * Returns a new instance of this bridge.
      */
     public Bridge getInstance() {
-        return new SVGImageElementBridge();
+        return new SVGMultiImageElementBridge();
     }
 
      /**
@@ -116,15 +117,19 @@ public class SVGMultiImageElementBridge extends SVGImageElementBridge {
             return null;
         }
 
+        associateSVGContext(ctx, e, imgNode);
+
         Rectangle2D b = getImageBounds(ctx, e);
 
         // 'transform'
         AffineTransform at = null;
         String s = e.getAttribute(SVG_TRANSFORM_ATTRIBUTE);
-        if (s.length() != 0)
-            at = SVGUtilities.convertTransform(e, SVG_TRANSFORM_ATTRIBUTE, s);
-        else
+        if (s.length() != 0) {
+            at = SVGUtilities.convertTransform(e, SVG_TRANSFORM_ATTRIBUTE, s,
+                                               ctx);
+        } else {
             at = new AffineTransform();
+        }
 
         at.translate(b.getX(), b.getY());
         imgNode.setTransform(at);
@@ -231,18 +236,10 @@ public class SVGMultiImageElementBridge extends SVGImageElementBridge {
     protected void initializeDynamicSupport(BridgeContext ctx,
                                             Element e,
                                             GraphicsNode node) {
-        if (!ctx.isInteractive())
-            return;
-
-        // HACK due to the way images are represented in GVT
-        ImageNode imgNode = (ImageNode)node;
-        ctx.bind(e, imgNode.getImage());
-
-        if (ctx.isDynamic()) {
-            this.e = e;
-            this.node = node;
-            this.ctx = ctx;
-            ((SVGOMElement)e).setSVGContext(this);
+        if (ctx.isInteractive()) {
+            // HACK due to the way images are represented in GVT
+            ImageNode imgNode = (ImageNode)node;
+            ctx.bind(e, imgNode.getImage());
         }
     }
 
@@ -254,6 +251,58 @@ public class SVGMultiImageElementBridge extends SVGImageElementBridge {
         super.dispose();
     }
 
+    /**
+     * Returns the bounds of the specified image element.
+     *
+     * @param ctx the bridge context
+     * @param element the image element
+     */
+    protected static
+        Rectangle2D getImageBounds(BridgeContext ctx, Element element) {
+
+        UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, element);
+
+        // 'x' attribute - default is 0
+        String s = element.getAttributeNS(null, SVG_X_ATTRIBUTE);
+        float x = 0;
+        if (s.length() != 0) {
+            x = UnitProcessor.svgHorizontalCoordinateToUserSpace
+                (s, SVG_X_ATTRIBUTE, uctx);
+        }
+
+        // 'y' attribute - default is 0
+        s = element.getAttributeNS(null, SVG_Y_ATTRIBUTE);
+        float y = 0;
+        if (s.length() != 0) {
+            y = UnitProcessor.svgVerticalCoordinateToUserSpace
+                (s, SVG_Y_ATTRIBUTE, uctx);
+        }
+
+        // 'width' attribute - required
+        s = element.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
+        float w;
+        if (s.length() == 0) {
+            throw new BridgeException(ctx, element, ERR_ATTRIBUTE_MISSING,
+                                      new Object[] {SVG_WIDTH_ATTRIBUTE});
+        } else {
+            w = UnitProcessor.svgHorizontalLengthToUserSpace
+                (s, SVG_WIDTH_ATTRIBUTE, uctx);
+        }
+
+        // 'height' attribute - required
+        s = element.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
+        float h;
+        if (s.length() == 0) {
+            throw new BridgeException(ctx, element, ERR_ATTRIBUTE_MISSING,
+                                      new Object[] {SVG_HEIGHT_ATTRIBUTE});
+        } else {
+            h = UnitProcessor.svgVerticalLengthToUserSpace
+                (s, SVG_HEIGHT_ATTRIBUTE, uctx);
+        }
+
+        return new Rectangle2D.Float(x, y, w, h);
+    }
+
     protected void addInfo(Element e, Collection elems, 
                            Collection minDim, Collection maxDim,
                            Rectangle2D bounds) {
@@ -285,18 +334,18 @@ public class SVGMultiImageElementBridge extends SVGImageElementBridge {
                               Rectangle2D bounds) {
         String uriStr = XLinkSupport.getXLinkHref(e);
         if (uriStr.length() == 0) {
-            throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
+            throw new BridgeException(ctx, e, ERR_ATTRIBUTE_MISSING,
                                       new Object[] {"xlink:href"});
         }
-        String baseURI = XMLBaseSupport.getCascadedXMLBase(e);
+        String baseURI = AbstractNode.getBaseURI(e);
         ParsedURL purl;
         if (baseURI == null) purl = new ParsedURL(uriStr);
         else                 purl = new ParsedURL(baseURI, uriStr);
         Document doc = e.getOwnerDocument();
         Element imgElem = doc.createElementNS(SVG_NAMESPACE_URI, 
                                               SVG_IMAGE_TAG);
-        imgElem.setAttributeNS(XLinkSupport.XLINK_NAMESPACE_URI, 
-                               "href", purl.toString());
+        imgElem.setAttributeNS(XLINK_NAMESPACE_URI, 
+                               XLINK_HREF_ATTRIBUTE, purl.toString());
         // move the attributes from <subImageRef> to the <image> element
         NamedNodeMap attrs = e.getAttributes();
         int len = attrs.getLength();
@@ -338,8 +387,8 @@ public class SVGMultiImageElementBridge extends SVGImageElementBridge {
         s = e.getAttribute(attr);
         if (s.length() == 0) return null;
 
-        Float [] vals = SVGUtilities.convertSVGNumberOptionalNumber
-            (e, attr, s);
+        Float[] vals = SVGUtilities.convertSVGNumberOptionalNumber
+            (e, attr, s, ctx);
 
         if (vals[0] == null) return null;
 

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGSolidColorElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGSolidColorElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGSolidColorElementBridge.java
index cc9eec0..6ed2f8b 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGSolidColorElementBridge.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/SVGSolidColorElementBridge.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
 
@@ -22,7 +23,7 @@ import java.awt.Paint;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.flex.forks.batik.bridge.AbstractSVGBridge;
+import org.apache.flex.forks.batik.bridge.AnimatableGenericSVGBridge;
 import org.apache.flex.forks.batik.bridge.BridgeContext;
 import org.apache.flex.forks.batik.bridge.BridgeException;
 import org.apache.flex.forks.batik.bridge.CSSUtilities;
@@ -47,9 +48,10 @@ import org.w3c.dom.css.CSSValue;
  * Bridge class for a regular polygon element.
  *
  * @author <a href="mailto:thomas.deweese@kodak.com">Thomas Deweese</a>
+ * @version $Id: SVGSolidColorElementBridge.java 498740 2007-01-22 18:35:57Z dvholten $
  */
-public class SVGSolidColorElementBridge extends AbstractSVGBridge
-    implements PaintBridge {
+public class SVGSolidColorElementBridge extends AnimatableGenericSVGBridge
+        implements PaintBridge {
 
     /**
      * Constructs a new bridge for the &lt;rect> element.
@@ -90,7 +92,7 @@ public class SVGSolidColorElementBridge extends AbstractSVGBridge
         return extractColor(paintElement, opacity, ctx);
     }
 
-    protected static float extractOpacity(Element paintElement, 
+    protected static float extractOpacity(Element paintElement,
                                           float opacity,
                                           BridgeContext ctx) {
         Map refs = new HashMap();
@@ -101,7 +103,7 @@ public class SVGSolidColorElementBridge extends AbstractSVGBridge
         for (;;) {
             Value opacityVal =
                 CSSUtilities.getComputedStyle(paintElement, pidx);
-        
+
             // Was solid-opacity explicity set on this element?
             StyleMap sm =
                 ((CSSStylableElement)paintElement).getComputedStyleMap(null);
@@ -122,7 +124,7 @@ public class SVGSolidColorElementBridge extends AbstractSVGBridge
             // check if there is circular dependencies
             if (refs.containsKey(purl)) {
                 throw new BridgeException
-                    (paintElement,
+                    (ctx, paintElement,
                      ErrorConstants.ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
                      new Object[] {uri});
             }
@@ -131,7 +133,7 @@ public class SVGSolidColorElementBridge extends AbstractSVGBridge
         }
     }
 
-    protected static Color extractColor(Element paintElement, 
+    protected static Color extractColor(Element paintElement,
                                         float opacity,
                                         BridgeContext ctx) {
         Map refs = new HashMap();
@@ -142,7 +144,7 @@ public class SVGSolidColorElementBridge extends AbstractSVGBridge
         for (;;) {
             Value colorDef =
                 CSSUtilities.getComputedStyle(paintElement, pidx);
-        
+
             // Was solid-color explicity set on this element?
             StyleMap sm =
                 ((CSSStylableElement)paintElement).getComputedStyleMap(null);
@@ -162,8 +164,8 @@ public class SVGSolidColorElementBridge extends AbstractSVGBridge
 
             String uri = XLinkSupport.getXLinkHref(paintElement);
             if (uri.length() == 0) {
-                // no xlink:href found, exit    
-                return new Color(0, 0, 0, opacity); 
+                // no xlink:href found, exit
+                return new Color(0, 0, 0, opacity);
             }
 
             SVGOMDocument doc = (SVGOMDocument)paintElement.getOwnerDocument();
@@ -172,7 +174,7 @@ public class SVGSolidColorElementBridge extends AbstractSVGBridge
             // check if there is circular dependencies
             if (refs.containsKey(purl)) {
                 throw new BridgeException
-                    (paintElement,
+                    (ctx, paintElement,
                      ErrorConstants.ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
                      new Object[] {uri});
             }

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XBLContentElementBridge.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XBLContentElementBridge.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XBLContentElementBridge.java
new file mode 100644
index 0000000..3e782ed
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/svg12/XBLContentElementBridge.java
@@ -0,0 +1,213 @@
+/*
+
+   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.dom.AbstractDocument;
+import org.apache.flex.forks.batik.dom.svg12.XBLOMContentElement;
+import org.apache.flex.forks.batik.gvt.CompositeGraphicsNode;
+import org.apache.flex.forks.batik.gvt.GraphicsNode;
+import org.apache.flex.forks.batik.util.XBLConstants;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Bridge class for the &lt;xbl:content&gt; element.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: XBLContentElementBridge.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class XBLContentElementBridge extends AbstractGraphicsNodeBridge {
+    
+    /**
+     * The event listener for content element selection changes.
+     */
+    protected ContentChangedListener contentChangedListener;
+
+    /**
+     * The ContentManager object used for the content element selection
+     * change events.
+     */
+    protected ContentManager contentManager;
+
+    /**
+     * Constructs a new bridge for the &lt;xbl:content&gt; element.
+     */
+    public XBLContentElementBridge() {
+    }
+
+    /**
+     * Returns 'content'.
+     */
+    public String getLocalName() {
+        return XBLConstants.XBL_CONTENT_TAG;
+    }
+
+    /**
+     * Returns the XBL namespace.
+     */
+    public String getNamespaceURI() {
+        return XBLConstants.XBL_NAMESPACE_URI;
+    }
+
+    /**
+     * Returns a new instance of this bridge.
+     */
+    public Bridge getInstance() {
+        return new XBLContentElementBridge();
+    }
+
+    /**
+     * 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) {
+        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 cgn 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 cgn) {
+
+        XBLOMContentElement content = (XBLOMContentElement) e;
+        AbstractDocument doc = (AbstractDocument) e.getOwnerDocument();
+        DefaultXBLManager xm = (DefaultXBLManager) doc.getXBLManager();
+        contentManager = xm.getContentManager(e);
+
+        if (cgn == null) {
+            cgn = new CompositeGraphicsNode();
+            associateSVGContext(ctx, e, cgn);
+        } else {
+            int s = cgn.size();
+            for (int i = 0; i < s; i++) {
+                cgn.remove(0);
+            }
+        }
+
+        GVTBuilder builder = ctx.getGVTBuilder();
+        NodeList nl = contentManager.getSelectedContent(content);
+        if (nl != null) {
+            for (int i = 0; i < nl.getLength(); i++) {
+                Node n = nl.item(i);
+                if (n.getNodeType() == Node.ELEMENT_NODE) {
+                    GraphicsNode gn = builder.build(ctx, (Element) n);
+                    if (gn != null) {
+                        cgn.add(gn);
+                    }
+                }
+            }
+        }
+
+        if (ctx.isDynamic()) {
+            if (contentChangedListener == null) {
+                // Should be the same ContentManager each build
+                contentChangedListener = new ContentChangedListener();
+                contentManager.addContentSelectionChangedListener
+                    (content, contentChangedListener);
+            }
+        }
+
+        return cgn;
+    }
+
+    /**
+     * Creates a <tt>CompositeGraphicsNode</tt>.
+     */
+    protected GraphicsNode instantiateGraphicsNode() {
+        // Not needed, since createGraphicsNode is overridden
+        return null;
+    }
+
+    /**
+     * 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);
+    }
+
+    /**
+     * Returns true if the graphics node has to be displayed, false
+     * otherwise.
+     */
+    public boolean getDisplay(Element e) {
+        return true;
+    }
+
+    /**
+     * Returns false as the &lt;xbl:content&gt; element's selected nodes
+     * are built all in this class.
+     */
+    public boolean isComposite() {
+        return false;
+    }
+
+    /**
+     * Dispose this bridge by removing the ContentSelectionChangedListener
+     * object.
+     */
+    public void dispose() {
+        super.dispose();
+
+        if (contentChangedListener != null) {
+            contentManager.removeContentSelectionChangedListener
+                ((XBLOMContentElement) e, contentChangedListener);
+        }
+    }
+
+    /**
+     * Class to respond to content selection changes and cause GVT rebuilds.
+     */
+    protected class ContentChangedListener
+            implements ContentSelectionChangedListener {
+
+        /**
+         * Invoked after an xbl:content element has updated its selected
+         * nodes list.
+         * @param csce the ContentSelectionChangedEvent object
+         */
+        public void contentSelectionChanged(ContentSelectionChangedEvent csce) {
+            buildCompositeGraphicsNode(ctx, e, (CompositeGraphicsNode) node);
+        }
+    }
+}