Hello all,

I have some code that needs to traverse the windows hierarchy. It runs
approximately 20 times slower while Firebug is active.

I don't mind detecting Firebug and tweaking my behavior if it's
unavoidable, but wanted to report this in case it is possible for you
guys to fix.

I wonder what is the reason for the slowdown?

Regards,
Boris

var activateMarkup = function(opt_win) {
  var winCount = 0;
  var now = new Date().getTime();

  walkWindows(window.top, function(w) {
        try {
           winCount++;
          if (!win['activated']) {
            var doc = win.document;
            // some custom stuff goes here
            win['activated'] = true;
          }
        } catch (e) {
          // document not accessible or not ready yet
        }
     return true; // process all subwindows anyway
  });

  alert('activateMarkup ' + winCount + ' >' + (new Date().getTime() -
now) + '<');
};

/**
 * Walks the window hierarchy starting with the root. Executes fn(win)
for each
 * window, and if fn(win) returns true, descends into win's subtree.
 *
 * @param {Window} root the root window.
 * @param {Function} fn the function to execute.
 */
function walkWindows(root, fn) {
  if (fn(root)) {
    var frames = root['frames'];
    var length = frames && frames.length;
    for (var i = 0; i < length; i++) {
      var frame = frames[i];
      if (fn(frame)) {
        walkWindows(frame, fn);
      }
    }
  }
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to