2003/10/15 10:16:40
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:39:19 +0000 (07:39 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:39:19 +0000 (07:39 +0000)
darcs-hash:20040130073919-2ba56-845ccf20dae2bafc5c4abee88f50359b4611d865.gz

src/org/xwt/Box.java.pp

index 5c7a242..429c7a4 100644 (file)
@@ -542,21 +542,25 @@ public final class Box extends JS.Scope {
      */
     public void put(int i, Object value) {
         if (i < 0) return;
      */
     public void put(int i, Object value) {
         if (i < 0) return;
-
+        Trap t = value == null ? (Trap)get("childremoved", Trap.class) : (Trap)get("childadded", Trap.class);
+            
         if (value != null && !(value instanceof Box)) {
         if (value != null && !(value instanceof Box)) {
-            if (Log.on) Log.logJS(this, "attempt to set a numerical property on a box to anything other than a box");
-        } else if (redirect == null) {
-            if (Log.on) Log.logJS(this, "attempt to add/remove children to/from a node with a null redirect");
-            put("0", (Box)value);
+            if (Log.on) Log.logJS(this, "attempt to set a numerical property on a box to a non-box");
+            return;
+        }
+
+        if (redirect == null) {
+            if (t != null) t.perform(value);
+            else if (Log.on) Log.logJS(this, "attempt to add/remove children to/from a node with a null redirect");
         } else if (redirect != this) {
             Box b = value == null ? (Box)redirect.get(i) : (Box)value;
             redirect.put(i, value);
         } else if (redirect != this) {
             Box b = value == null ? (Box)redirect.get(i) : (Box)value;
             redirect.put(i, value);
-            put("0", b);
+            if (t != null) t.perform(value);
         } else if (value == null) {
             if (i >= 0 && i < numChildren()) {
                 Box b = getChild(i);
                 b.remove();
         } else if (value == null) {
             if (i >= 0 && i < numChildren()) {
                 Box b = getChild(i);
                 b.remove();
-                put("0", b);
+                if (t != null) t.perform(b);
             }
         } else {
             Box newnode = (Box)value;
             }
         } else {
             Box newnode = (Box)value;
@@ -618,9 +622,7 @@ public final class Box extends JS.Scope {
             MARK_FOR_REFLOW_this;
             
             newnode.dirty();
             MARK_FOR_REFLOW_this;
             
             newnode.dirty();
-
-            // note that JavaScript box[0] will invoke put(int i), not put(String s)
-            put("0", newnode);
+            if (t != null) t.perform(b);
         }
     }
     
         }
     }
     
@@ -680,9 +682,6 @@ public final class Box extends JS.Scope {
             }
         }
 
             }
         }
 
-        // don't want to really cascade down to the box on this one
-        if (name.equals("0")) return;
-
         SpecialBoxProperty gph = (SpecialBoxProperty)SpecialBoxProperty.specialBoxProperties.get(name);
         if (gph != null) { gph.put(name, this, value); return; }
 
         SpecialBoxProperty gph = (SpecialBoxProperty)SpecialBoxProperty.specialBoxProperties.get(name);
         if (gph != null) { gph.put(name, this, value); return; }
 
@@ -750,7 +749,10 @@ public final class Box extends JS.Scope {
         if (oldparent != null) { Box b = oldparent; MARK_FOR_REFLOW_b; }
 
         // note that JavaScript box[0] will invoke put(int i), not put(String s)
         if (oldparent != null) { Box b = oldparent; MARK_FOR_REFLOW_b; }
 
         // note that JavaScript box[0] will invoke put(int i), not put(String s)
-        if (oldparent != null) oldparent.put("0", this);
+        if (oldparent != null) {
+            Trap t = (Trap)oldparent.get("childremoved", Trap.class);
+            if (t != null) t.perform(this);
+        }
     }
 
     /** returns our next sibling (parent[ourindex + 1]) */
     }
 
     /** returns our next sibling (parent[ourindex + 1]) */