View | Details | Raw Unified | Return to bug 46072
Collapse All | Expand All

(-)sources/org/apache/batik/swing/svg/JSVGComponent.java (+18 lines)
Lines 3082-3087 Link Here
3082
            } catch (Exception e) {
3082
            } catch (Exception e) {
3083
            }
3083
            }
3084
        }
3084
        }
3085
3086
        /**
3087
         * This method should load a new document described by the supplied URL.
3088
         *
3089
         * @param url The url to be loaded as a string.
3090
         */
3091
        public void loadDocument(String url) {
3092
            userAgent.loadDocument(url);
3093
        }
3085
    }
3094
    }
3086
3095
3087
    /**
3096
    /**
Lines 3677-3682 Link Here
3677
            }
3686
            }
3678
            return doc;
3687
            return doc;
3679
        }
3688
        }
3689
3690
        /**
3691
         * This method should load a new document described by the supplied URL.
3692
         *
3693
         * @param url The url to be loaded as a string.
3694
         */
3695
        public void loadDocument(String url) {
3696
            JSVGComponent.this.loadSVGDocument(url);
3697
        }
3680
    }
3698
    }
3681
3699
3682
    protected static final Set FEATURES = new HashSet();
3700
    protected static final Set FEATURES = new HashSet();
(-)sources/org/apache/batik/bridge/BaseScriptingEnvironment.java (+14 lines)
Lines 920-924 Link Here
920
            return interpreter;
920
            return interpreter;
921
        }
921
        }
922
922
923
        /**
924
         * Returns the Location.
925
         */
926
        public Location getLocation() {
927
            return null;
928
        }
929
930
        /**
931
         * Returns the parent Window object.
932
         */
933
        public Window getParent() {
934
            return null;
935
        }
936
923
    }
937
    }
924
}
938
}
(-)sources/org/apache/batik/bridge/Location.java (+72 lines)
Line 0 Link Here
1
/*
2
3
   Licensed to the Apache Software Foundation (ASF) under one or more
4
   contributor license agreements.  See the NOTICE file distributed with
5
   this work for additional information regarding copyright ownership.
6
   The ASF licenses this file to You under the Apache License, Version 2.0
7
   (the "License"); you may not use this file except in compliance with
8
   the License.  You may obtain a copy of the License at
9
10
       http://www.apache.org/licenses/LICENSE-2.0
11
12
   Unless required by applicable law or agreed to in writing, software
13
   distributed under the License is distributed on an "AS IS" BASIS,
14
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
   See the License for the specific language governing permissions and
16
   limitations under the License.
17
18
 */
19
package org.apache.batik.bridge;
20
21
import java.net.URL;
22
import org.apache.batik.bridge.BridgeContext;
23
import org.apache.batik.dom.svg.SVGOMDocument;
24
import org.apache.batik.dom.AbstractDocument;
25
26
/**
27
 * This class implements the org.w3c.dom.Location interface for Batik
28
 *
29
 * @author <a href="mailto:gwadej@anomaly.org">G. Wade Johnson</a>
30
 * @version $Id: Location.java$
31
 */
32
public class Location implements org.w3c.dom.Location {
33
    private BridgeContext bridgeContext;
34
35
    /**
36
     * Creates a new Location.
37
     * @param ctx the bridge context
38
     */
39
    public Location(BridgeContext ctx) {
40
        bridgeContext = ctx;
41
    }
42
43
44
    /**
45
     * Invocation of this method causes the user agent to navigate to the
46
     * supplied location.
47
     *
48
     * @param url A string containing the URL where the user agent should
49
     *    navigate to.
50
     */
51
    public void assign(String url) {
52
        ((UserAgent)bridgeContext.getUserAgent()).loadDocument(url);
53
    }
54
55
    /**
56
     * The user agent reloads the current document.
57
     */
58
    public void reload() {
59
        String url = ((AbstractDocument) bridgeContext.getDocument())
60
                    .getDocumentURI();
61
        ((UserAgent)bridgeContext.getUserAgent()).loadDocument(url);
62
    }
63
64
    /**
65
     * Returns the URL of this location as a String.
66
     */
67
    public String toString() {
68
        return ((AbstractDocument) bridgeContext.getDocument())
69
                    .getDocumentURI();
70
    }
71
}
72
(-)sources/org/apache/batik/bridge/UserAgent.java (+7 lines)
Lines 299-302 Link Here
299
     *                loaded (not available, corrupt, unknown format, ...).
299
     *                loaded (not available, corrupt, unknown format, ...).
300
     */
300
     */
301
    SVGDocument getBrokenLinkDocument(Element e, String url, String message);
301
    SVGDocument getBrokenLinkDocument(Element e, String url, String message);
302
303
    /**
304
     * This method should load a new document described by the supplied URL.
305
     *
306
     * @param url The url to be loaded as a string.
307
     */
308
    void loadDocument(String url);
302
}
309
}
(-)sources/org/apache/batik/bridge/UserAgentAdapter.java (+9 lines)
Lines 449-452 Link Here
449
        throw new BridgeException(ctx, e, ErrorConstants.ERR_URI_IMAGE_BROKEN,
449
        throw new BridgeException(ctx, e, ErrorConstants.ERR_URI_IMAGE_BROKEN,
450
                                  new Object[] {url, message });
450
                                  new Object[] {url, message });
451
    }
451
    }
452
453
    /**
454
     * This method should load a new document described by the supplied URL.
455
     *
456
     * @param url The url to be loaded as a string.
457
     */
458
    public void loadDocument(String url) {
459
        // Do nothing.
460
    }
452
}
461
}
(-)sources/org/apache/batik/bridge/ScriptingEnvironment.java (+23 lines)
Lines 49-54 Link Here
49
import org.apache.batik.dom.util.DOMUtilities;
49
import org.apache.batik.dom.util.DOMUtilities;
50
import org.apache.batik.dom.util.SAXDocumentFactory;
50
import org.apache.batik.dom.util.SAXDocumentFactory;
51
import org.apache.batik.dom.util.XLinkSupport;
51
import org.apache.batik.dom.util.XLinkSupport;
52
import org.apache.batik.bridge.Location;
52
import org.apache.batik.script.Interpreter;
53
import org.apache.batik.script.Interpreter;
53
import org.apache.batik.script.InterpreterException;
54
import org.apache.batik.script.InterpreterException;
54
import org.apache.batik.script.ScriptEventWrapper;
55
import org.apache.batik.script.ScriptEventWrapper;
Lines 917-922 Link Here
917
        protected String language;
918
        protected String language;
918
919
919
        /**
920
        /**
921
         * The Location object
922
         */
923
        protected Location location;
924
925
        /**
920
         * Creates a new Window for the given language.
926
         * Creates a new Window for the given language.
921
         */
927
         */
922
        public Window(Interpreter interp, String lang) {
928
        public Window(Interpreter interp, String lang) {
Lines 1316-1321 Link Here
1316
        public Interpreter getInterpreter() {
1322
        public Interpreter getInterpreter() {
1317
            return interpreter;
1323
            return interpreter;
1318
        }
1324
        }
1325
1326
        /**
1327
         * Returns a Window object representing the parent of this Window.
1328
         */
1329
        public Window getParent() {
1330
            return null;
1331
        }
1332
1333
        /**
1334
         * Returns a Location object representing this Window.
1335
         */
1336
        public Location getLocation() {
1337
            if (location == null) {
1338
                location = new Location(bridgeContext);
1339
            }
1340
            return location;
1341
        }
1319
    }
1342
    }
1320
1343
1321
    /**
1344
    /**
(-)sources/org/apache/batik/script/rhino/WindowWrapper.java (-1 / +19 lines)
Lines 33-38 Link Here
33
33
34
import org.w3c.dom.Document;
34
import org.w3c.dom.Document;
35
import org.w3c.dom.Node;
35
import org.w3c.dom.Node;
36
import org.w3c.dom.Location;
36
37
37
/**
38
/**
38
 * This class wraps a Window object to expose it to the interpreter.
39
 * This class wraps a Window object to expose it to the interpreter.
Lines 66-71 Link Here
66
                           "postURL", "alert", "confirm", "prompt" };
67
                           "postURL", "alert", "confirm", "prompt" };
67
        this.defineFunctionProperties(names, WindowWrapper.class,
68
        this.defineFunctionProperties(names, WindowWrapper.class,
68
                                      ScriptableObject.DONTENUM);
69
                                      ScriptableObject.DONTENUM);
70
        this.defineProperty("location", WindowWrapper.class,
71
                            ScriptableObject.PERMANENT);
69
    }
72
    }
70
73
71
    public String getClassName() {
74
    public String getClassName() {
Lines 188-194 Link Here
188
191
189
        Object ret;
192
        Object ret;
190
        // If acc is null we are running in an Applet (or some other
193
        // If acc is null we are running in an Applet (or some other
191
        // restrictive environment) so don't sweat security it's 
194
        // restrictive environment) so don't sweat security it's
192
        // the "Browsers" problem...
195
        // the "Browsers" problem...
193
        if (acc != null) ret = AccessController.doPrivileged(pa , acc);
196
        if (acc != null) ret = AccessController.doPrivileged(pa , acc);
194
        else             ret = AccessController.doPrivileged(pa);
197
        else             ret = AccessController.doPrivileged(pa);
Lines 406-411 Link Here
406
    }
409
    }
407
410
408
    /**
411
    /**
412
     * Return the Location for this Window.
413
     */
414
    public Location getLocation() {
415
        return window.getLocation();
416
    }
417
418
    /**
419
     * Return the Location for this Window.
420
     */
421
    public void setLocation(Object val) {
422
        String url = (String)Context.jsToJava(val, String.class);
423
        window.getLocation().assign(url);
424
    }
425
426
    /**
409
     * To wrap a function in an handler.
427
     * To wrap a function in an handler.
410
     */
428
     */
411
    protected static class FunctionWrapper implements Runnable {
429
    protected static class FunctionWrapper implements Runnable {
(-)sources/org/apache/batik/script/Window.java (-1 / +1 lines)
Lines 30-36 Link Here
30
 * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
30
 * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
31
 * @version $Id$
31
 * @version $Id$
32
 */
32
 */
33
public interface Window {
33
public interface Window extends org.w3c.dom.Window {
34
    /**
34
    /**
35
     * Evaluates the given string repeatedly after the given amount of
35
     * Evaluates the given string repeatedly after the given amount of
36
     * time.  This method does not stall the script: the evaluation is
36
     * time.  This method does not stall the script: the evaluation is
(-)sources/org/w3c/dom/Window.java (+24 lines)
Line 0 Link Here
1
/*
2
3
   Licensed to the Apache Software Foundation (ASF) under one or more
4
   contributor license agreements.  See the NOTICE file distributed with
5
   this work for additional information regarding copyright ownership.
6
   The ASF licenses this file to You under the Apache License, Version 2.0
7
   (the "License"); you may not use this file except in compliance with
8
   the License.  You may obtain a copy of the License at
9
10
       http://www.apache.org/licenses/LICENSE-2.0
11
12
   Unless required by applicable law or agreed to in writing, software
13
   distributed under the License is distributed on an "AS IS" BASIS,
14
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
   See the License for the specific language governing permissions and
16
   limitations under the License.
17
18
 */
19
package org.w3c.dom;
20
21
public interface Window {
22
    Window getParent();
23
    Location getLocation();
24
}
(-)sources/org/w3c/dom/Location.java (+35 lines)
Line 0 Link Here
1
/*
2
3
   Licensed to the Apache Software Foundation (ASF) under one or more
4
   contributor license agreements.  See the NOTICE file distributed with
5
   this work for additional information regarding copyright ownership.
6
   The ASF licenses this file to You under the Apache License, Version 2.0
7
   (the "License"); you may not use this file except in compliance with
8
   the License.  You may obtain a copy of the License at
9
10
       http://www.apache.org/licenses/LICENSE-2.0
11
12
   Unless required by applicable law or agreed to in writing, software
13
   distributed under the License is distributed on an "AS IS" BASIS,
14
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
   See the License for the specific language governing permissions and
16
   limitations under the License.
17
18
 */
19
package org.w3c.dom;
20
21
public interface Location {
22
    /**
23
     * Invocation of this method causes the user agent to navigate to the
24
     * supplied location.
25
     *
26
     * @param url A string containing the URL where the user agent should
27
     *    navigate to.
28
     */
29
    void assign(String url);
30
31
    /**
32
     * The user agent reloads the current document.
33
     */
34
    void reload();
35
}

Return to bug 46072