Reviewers: MikeSamuel,

Description:
right now, domita emits a log message for every event dispatched,
which is a lot of noise when there are mouseover or mousemove handlers.

this change squelches those log messages unless a gadget
calls setDomitaTrace(1);

Please review this at http://codereview.appspot.com/110099

Affected files:
  M     src/com/google/caja/plugin/domita.js


Index: src/com/google/caja/plugin/domita.js
===================================================================
--- src/com/google/caja/plugin/domita.js        (revision 3663)
+++ src/com/google/caja/plugin/domita.js        (working copy)
@@ -3578,6 +3578,16 @@
       return idClass;
     };

+    // bitmask of trace points
+    //    0x0001 plugin_dispatchEvent
+    imports.domitaTrace___ = 0;
+    imports.getDomitaTrace = ___.markFuncFreeze(
+        function () { return imports.domitaTrace___; }
+    );
+    imports.setDomitaTrace = ___.markFuncFreeze(
+        function (x) { imports.domitaTrace___ = x; }
+    );
+
     // TODO(mikesamuel): remove these, and only expose them via window once
     // Valija works
     imports.setTimeout = tameSetTimeout;
@@ -4014,13 +4024,15 @@
 function plugin_dispatchEvent___(thisNode, event, pluginId, handler) {
   event = (event || window.event);
   var sig = String(handler).match(/^function\b[^\)]*\)/);
-  cajita.log(
-      'Dispatch ' + (event && event.type) +
-      'event thisNode=' + thisNode + ', ' +
-      'event=' + event + ', ' +
-      'pluginId=' + pluginId + ', ' +
-      'handler=' + (sig ? sig[0] : handler));
   var imports = ___.getImports(pluginId);
+  if (imports.domitaTrace___ & 0x1) {
+    cajita.log(
+        'Dispatch ' + (event && event.type) +
+        'event thisNode=' + thisNode + ', ' +
+        'event=' + event + ', ' +
+        'pluginId=' + pluginId + ', ' +
+        'handler=' + (sig ? sig[0] : handler));
+  }
   switch (typeof handler) {
     case 'string':
       handler = imports[handler];


Reply via email to