cjolif      01/10/08 08:07:51

  Modified:    sources/org/apache/batik/bridge BridgeEventSupport.java
  Log:
  take modification into scripting (new evaluate method) into account
  
  Revision  Changes    Path
  1.15      +25 -14    
xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java
  
  Index: BridgeEventSupport.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- BridgeEventSupport.java   2001/09/13 13:10:54     1.14
  +++ BridgeEventSupport.java   2001/10/08 15:07:51     1.15
  @@ -53,7 +53,7 @@
    * on the GVT root to propagate GVT events to the DOM.
    * @author <a href="mailto:[EMAIL PROTECTED]>Christophe Jolif</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: BridgeEventSupport.java,v 1.14 2001/09/13 13:10:54 tkormann Exp $
  + * @version $Id: BridgeEventSupport.java,v 1.15 2001/10/08 15:07:51 cjolif Exp $
    */
   class BridgeEventSupport implements SVGConstants {
       private static final String[] EVENT_ATTRIBUTES_GRAPHICS = {
  @@ -172,6 +172,8 @@
                               break;
                           }
                       }
  +                    // <!> TODO this will stop working if someone change
  +                    // the content of the event attribute
                       addScriptCaller(target, EVENT_NAMES[i+FIRST_SVG_EVENT],
                                        new ScriptCaller(ctx.getUserAgent(),
                                                         script, interpret));
  @@ -200,10 +202,12 @@
                                   break;
                               }
                           }
  +                        // <!> TODO this will stop working if someone change
  +                        // the content of the event attribute
                           addScriptCaller(target, EVENT_NAMES[i+
  -                                                            FIRST_ANIMATION_EVENT],
  -                                         new ScriptCaller(ctx.getUserAgent(),
  -                                                          script, interpret));
  +                                                           FIRST_ANIMATION_EVENT],
  +                                        new ScriptCaller(ctx.getUserAgent(),
  +                                                         script, interpret));
                       }
                   }
                   // not other stuff to do on this kind of events
  @@ -221,10 +225,13 @@
                       if (interpret == null) {
                           UserAgent ua = ctx.getUserAgent();
                           if (ua != null)
  -                            ua.displayError(new Exception("unknow language: 
"+language));
  +                            ua.displayError(new Exception("unknow language: "+
  +                                                          language));
                           break;
                       }
                   }
  +                // <!> TODO this will stop working if someone change
  +                // the content of the event attribute
                   addScriptCaller(target, EVENT_NAMES[i],
                                    new ScriptCaller(ctx.getUserAgent(),
                                                     script, interpret));
  @@ -279,7 +286,8 @@
           public static SVGUnloadListener getInstance(Element svgRoot) {
               return (SVGUnloadListener)map.get(svgRoot);
           }
  -        public void addListener(EventTarget element, String type, EventListener 
listener) {
  +        public void addListener(EventTarget element, String type,
  +                                EventListener listener) {
               list.add(new Entry(type, listener, element));
           }
           public void handleEvent(Event evt) {
  @@ -320,7 +328,7 @@
   
       public static void loadScripts(BridgeContext ctx, Document doc) {
           NodeList list = doc.getElementsByTagNameNS(SVG_NAMESPACE_URI,
  -                                                SVG_SCRIPT_TAG);
  +                                                   SVG_SCRIPT_TAG);
           final UserAgent ua = ctx.getUserAgent();
           String language = null;
           Element selement = null;
  @@ -336,13 +344,16 @@
                       script.append(n.getNodeValue());
                   }
                   try {
  -                    interpret.evaluate
  -                        (new StringReader(script.toString()));
  +                    // use Reader mechanism => no caching
  +                    // (will not be revaluated + <script> content is
  +                    // generally bigger than the one in event attributes
  +                    interpret.evaluate(new StringReader(script.toString()));
                   } catch (IOException io) {
                       // will never appeared we don't use a file
                   } catch (InterpreterException e) {
                       if (ua != null)
  -                        ua.displayError(new Exception("scripting error: " 
+e.getMessage()));
  +                        ua.displayError(new Exception("scripting error: "+
  +                                                      e.getMessage()));
                   }
               } else
                   if (ua != null)
  @@ -506,12 +517,12 @@
           public void handleEvent(Event evt) {
               interpreter.bindObject(EVENT_NAME, evt);
               try {
  -                interpreter.evaluate(new StringReader(script));
  -            } catch (IOException io) {
  -                // will never appeared we don't use a file
  +                // use the String version to enable caching mechanism
  +                interpreter.evaluate(script);
               } catch (InterpreterException e) {
                   if (ua != null)
  -                    ua.displayError(new Exception("scripting error: " 
+e.getMessage()));
  +                    ua.displayError(new Exception("scripting error: "+
  +                                                  e.getMessage()));
               }
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to