X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FTrap.java;h=df51b5317974ab988ce053fe6400d28523c30467;hb=10950dd1b8e91c45197b9ad487b5e8d86e4aee5c;hp=d2b39541179a4bb509272828cd2dec64af0c4bf0;hpb=6242c991f365dbd67eba62ecfa5df769a83fcbc6;p=org.ibex.core.git diff --git a/src/org/xwt/Trap.java b/src/org/xwt/Trap.java index d2b3954..df51b53 100644 --- a/src/org/xwt/Trap.java +++ b/src/org/xwt/Trap.java @@ -1,9 +1,9 @@ -// Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; -import org.xwt.util.*; import java.util.*; -import org.mozilla.javascript.*; +import org.xwt.js.*; +import org.xwt.util.*; /** * This class encapsulates a single trap placed on a given node. The @@ -15,48 +15,37 @@ public class Trap { // Static Data ////////////////////////////////////////////////////////////// - /** a vector of weak references to all instances of Trap; used for retheming */ - private static Vec allTraps = new Vec(1000); - /** List of properties that cannot be trapped */ private static final Hash PROHIBITED = new Hash(120, 3); static { String[] p = new String[] { - "sizetoimage", "shrink", "hshrink", "vshrink", "x", "y", "width", "height", - "flex", "align", "invisible", "absolute", "globalx", "globaly", - "minwidth", "minheight", "height", "width", "maxwidth", "maxheight", - "numchildren", "hpad", "vpad", "doublebuffered", "cursor", - "mousex", "mousey", "xwt", "static", "mouseinside", "root", "thisbox", "indexof", "svg" + "shrink", "hshrink", "vshrink", "x", "y", + "width", "height", "flex", "colspan", "rowspan", "cols", + "rows", "align", "invisible", "absolute", "globalx", + "globaly", "minwidth", "minheight", "height", "width", + "maxwidth", "maxheight", "numchildren", "hpad", "vpad", + "buffered", "cursor", "mousex", "mousey", + "mouseinside", "thisbox", "indexof", "path", "font", "fontsize" }; for(int i=0; i
b
by the currently-running script */
- public static Trap getTrap(Box b, String name) {
- if (b.traps == null) return null;
-
- String currentFunctionNodeName = JSObject.getCurrentFunctionSourceName();
- for(Trap cur = (Trap)b.traps.get(name); cur != null; cur = cur.next)
- if (cur.placerNodeName.equals(currentFunctionNodeName))
- return cur;
- return null;
- }
-
- /** Called by Rhino's arguments.cascade. Note: cx will be null if this was invoked from perform() rather than from a script. */
- public static final Function cascadeFunction = new CascadeFunction();
- private static class CascadeFunction extends JSObject implements Function {
- CascadeFunction() { setSeal(true); }
- public Scriptable construct(Context cx, Scriptable scope, java.lang.Object[] args) { return null; }
- public Object call(Context cx, Scriptable thisObj, Scriptable ctorObj, Object[] args) {
- Trap currentTrap = TrapContext.get().currentTrap;
- if (currentTrap == null || (cx != null && Context.getCurrentContext().currentFunction != currentTrap.f)) {
- if (Log.on) Log.log(this, "attempt to cascade() by a function that was not invoked as a trap at " +
- cx.interpreterSourceFile + ":" + cx.interpreterLine);
- return null;
- }
- if (args.length != 0) TrapContext.get().putCascadeHappened = true;
- Trap t = currentTrap.next;
- // if we've hit the end of the trap stack, just do a put(,,,true)
- if (t == null) {
- if (args.length == 0) return currentTrap.trapee.get(currentTrap.name, currentTrap.trapee, true);
- currentTrap.trapee.put(currentTrap.name, currentTrap.trapee, args[0], true);
- return null;
- }
- return t.perform(args);
+ /**
+ * deletes a trap.
+ * @param trapee the box to remove the trap from
+ * @param name the name of the property to trap on
+ * @param f the function to remove
+ */
+ static void delTrap(Box trapee, Object name, JS.CompiledFunction f) {
+ Trap t = (Trap)trapee.get(name, Trap.class);
+ if (t.f == f) {
+ trapee.put(name, Trap.class, t.next);
+ return;
}
- };
-
- /** called by Rhino's arguments.trapee hack */
- public static Object currentTrapee() {
- Trap current = TrapContext.get().currentTrap;
- if (current == null) return null;
- else if (current.rp != null) return current.rp;
- else return current.trapee;
- }
-
- /** removes all traps whose function's ultimate parent scope is b. Used for retheming */
- public static void removeAllTrapsByBox(Box b) {
- for(int i=0; i