[KSS-checkins] r43359 - kukit/kukit.js/branch/ree-stripout-comments/kukit

reebalazs at codespeak.net reebalazs at codespeak.net
Mon May 14 13:47:56 CEST 2007


Author: reebalazs
Date: Mon May 14 13:47:55 2007
New Revision: 43359

Modified:
   kukit/kukit.js/branch/ree-stripout-comments/kukit/commandreg.js
   kukit/kukit.js/branch/ree-stripout-comments/kukit/eventreg.js
   kukit/kukit.js/branch/ree-stripout-comments/kukit/resourcedata.js
   kukit/kukit.js/branch/ree-stripout-comments/kukit/selectorreg.js
Log:
Add the passnode selector that can be used to access the value of
a default parm passed programmatically from the event (via makeActionOper)

Also: change and fix the orignode handling in selectors. Also fixed the samenode
  param provider.


Modified: kukit/kukit.js/branch/ree-stripout-comments/kukit/commandreg.js
==============================================================================
--- kukit/kukit.js/branch/ree-stripout-comments/kukit/commandreg.js	(original)
+++ kukit/kukit.js/branch/ree-stripout-comments/kukit/commandreg.js	Mon May 14 13:47:55 2007
@@ -107,7 +107,9 @@
 
 kukit.cr._Command_execute_selector = function(oper) {
     var selfunc = kukit.selectorTypesGlobalRegistry.get(this.selectorType);
-    var nodes = selfunc(this.selector, null, oper.orignode);
+    // When applying the selection, the original event target will be used
+    // as a starting point for the selection.
+    var nodes = selfunc(this.selector, oper.orignode, {});
     ;;; var printtype;
     ;;; if (this.selectorType) {
     ;;;     printtype = this.selectorType;

Modified: kukit/kukit.js/branch/ree-stripout-comments/kukit/eventreg.js
==============================================================================
--- kukit/kukit.js/branch/ree-stripout-comments/kukit/eventreg.js	(original)
+++ kukit/kukit.js/branch/ree-stripout-comments/kukit/eventreg.js	Mon May 14 13:47:55 2007
@@ -736,18 +736,21 @@
         var rules_per_node = this.infopernode[nodehash];
         // filter only the events we are interested in
         var filtered_rules = {};
-        var found = false;
+        var foundoper = false;
         for (var i=0; i<eventset.names.length; i++) {
             var name = eventset.names[i];
             var oper = rules_per_node[name];
             if (typeof(oper) != 'undefined') {
                 filtered_rules[name] = oper;
-                found = true;
+                foundoper = oper;
             }
         }
         // call it
-        if (found) {
-            this.call_bind_method(eventset, binderinstance, filtered_rules);
+        // All opers have the same node, the last one is yet in foundoper, so
+        // we use it as a second parameter to the call.
+        // The method may or may not want to use this.
+        if (foundoper) {
+            this.call_bind_method(eventset, binderinstance, filtered_rules, foundoper.node);
         }
     }
 };

Modified: kukit/kukit.js/branch/ree-stripout-comments/kukit/resourcedata.js
==============================================================================
--- kukit/kukit.js/branch/ree-stripout-comments/kukit/resourcedata.js	(original)
+++ kukit/kukit.js/branch/ree-stripout-comments/kukit/resourcedata.js	Mon May 14 13:47:55 2007
@@ -306,6 +306,13 @@
     this.content = {};
 };
 
+kukit.rd.ActionSet.prototype.hasActions = function() {
+    for (var name in this.content) {
+        return true;
+    }
+    return false;
+};
+
 kukit.rd.ActionSet.prototype.merge = function(other) {
     for (var key in other.content) {
         var action = this.content[key];
@@ -450,26 +457,25 @@
     }
 };
 
-kukit.rd.Action.prototype.makeActionOper = function(oper, defaultparms) {
+kukit.rd.Action.prototype.makeActionOper = function(oper) {
     // Fill the completed action parameters, based on the node
-    // if defaultparms is given, its values can be used with the 
-    // pass() function.
-    // The kssXxx parameters, reserved for the action, are put into
-    // aparms.
+    // The kssXxx parameters, reserved for the action, are 
+    // handled as appropriate.
     // A cloned oper is returned.
     var parms = {};
     var aparms = {};
-    if (typeof(defaultparms) == 'undefined') {
-        defaultparms = {};
+    // Make sure we have defaultparms on oper
+    if (typeof(oper.defaultparms) == 'undefined') {
+        oper.defaultparms = {};
     }
     for (var key in this.parms) {
         var kssvalue = this.parms[key]; 
         if (key.match(/^kss/)) {
             // kssXxx parameters are separated to aparms.
-            kssvalue.evaluate(aparms, key, oper.node, defaultparms); 
+            kssvalue.evaluate(aparms, key, oper.node, oper.defaultparms); 
         } else {
             // evaluate the method parameters into parms
-            kssvalue.evaluate(parms, key, oper.node, defaultparms); 
+            kssvalue.evaluate(parms, key, oper.node, oper.defaultparms); 
         }
     }
     var aoper = oper.clone({
@@ -481,7 +487,7 @@
 };
 
 kukit.rd.Action.prototype.execute = function(oper) {
-    oper = this.makeActionOper(oper, oper.parms);
+    oper = this.makeActionOper(oper);
     switch (this.type) {
         case 'D': {
             // Default action.

Modified: kukit/kukit.js/branch/ree-stripout-comments/kukit/selectorreg.js
==============================================================================
--- kukit/kukit.js/branch/ree-stripout-comments/kukit/selectorreg.js	(original)
+++ kukit/kukit.js/branch/ree-stripout-comments/kukit/selectorreg.js	Mon May 14 13:47:55 2007
@@ -33,15 +33,17 @@
     check: function(args) {
         // check does not need to be used here actually.
         if (args.length != 1) {
-            ;;; throw 'internal error, AnyPP needs 1 argument';
-            throw 'E';
+            throw 'internal error, xxxselector() needs 1 argument';
         }
     },
     /*
     */
-    eval: function(args, node) {
+    eval: function(args, node, defaultparms) {
         var f = kukit.selectorTypesGlobalRegistry.get(this.selector_type);
-        return f(args[0], node);
+        // We don't have orignode if we evaluate from here, consequently
+        // the orignode parameter cannot be used from selectors. We pass
+        // node just to be sure...
+        return f(args[0], node, defaultparms, node);
     }
 };
 
@@ -55,7 +57,30 @@
     return pp;
 };
 
-
+// this can be used to pass a node programmatically
+kukit.sr.PassnodePP = function() {};
+kukit.sr.PassnodePP.prototype = {
+    /*
+    ;;; */
+    check: function(args) {
+        if (args.length != 1) {
+            throw 'passnode selector method needs 1 argument';
+        }
+    },
+    /*
+    */
+    eval: function(args, node, defaultparms) {
+        var value = defaultparms[args[0]];
+        if (typeof(value) == 'undefined') {
+            // notfound arguments will get null
+            ;;; throw 'Nonexistent default parm "'+ key +'"';
+            throw 'E';
+        }
+        nodes = [value];
+        return nodes;
+    }
+};
+kukit.sr.pproviderSelRegistry.register('passnode', kukit.sr.PassnodePP);
 
 
 /* 
@@ -84,11 +109,9 @@
     ;;;    return;
     ;;; }
     this.mapping[name] = func;
-    // Also register the selector param provider (not for samenode though)
-    if (name != 'sanenode') {
-        var pp = kukit.sr.makeAnyPP(name);
-        kukit.sr.pproviderSelRegistry.register(name, pp);
-    }
+    // Also register the selector param provider
+    var pp = kukit.sr.makeAnyPP(name);
+    kukit.sr.pproviderSelRegistry.register(name, pp);
 };
 
 kukit.sr.SelectorTypeRegistry.prototype.get = function(name) {
@@ -121,19 +144,14 @@
     return nodes;
 });
 
-kukit.selectorTypesGlobalRegistry.register('samenode', function(expr, node, orignode) {
-    nodes = [orignode];
+kukit.selectorTypesGlobalRegistry.register('samenode', function(expr, node) {
+    nodes = [node];
     return nodes;
 });
 
 // Return a list of all nodes that match the css expression in the parent chain
-kukit.selectorTypesGlobalRegistry.register('parentnode', function(expr, node, orignode) {
+kukit.selectorTypesGlobalRegistry.register('parentnode', function(expr, node) {
     var selectednodes = kukit.dom.cssQuery(expr);
-
-
-    var node = orignode || node; // TODO: Explain to me (Jeroen) what node vs
-                                 //       orignode should do and why we have both.
-
     var parentnodes = [];
     var parentnode = node.parentNode;
     while(parentnode.parentNode) {


More information about the Kukit-checkins mailing list