The Web Inspector code is very object oriented and it needs to add event listeners and timeouts that call object functions with a correct 'this' object. A common practice sprinkles throughout the code is: var _self = this; setTimeout(function() { _self.foo() }, 0); node.addEventListener('bar', function() { _self.bar() }, false); We should add helper functions that simplify this.
Created attachment 17487 [details] Patch
Comment on attachment 17487 [details] Patch I was thinking about fixing this as well, but in a slightly different way. I was going to add a new function: Function.bind = function(func, thisObject) { return function() { func.call(thisObject) } } Then you could do things like: setTimeout(Function.bind(this.updateTitle, this), 0); What do you think about that solution? I like that it's very general and so can be used in more places.
(In reply to comment #2) > Function.bind = function(func, thisObject) { > return function() { func.call(thisObject) } > } You'd want to pass arguments through, as well.
Comment on attachment 17487 [details] Patch I am going to redo this based on Adam's comment.
Created attachment 17488 [details] Revised Patch
Comment on attachment 17488 [details] Revised Patch I think "toggleExpanded" would be clearer than just "toggle" for the two places you added that function. I don't think the order of the <script> elements matters, since none of this code gets executed as it's parsed. r=me
Landed in r28002. http://trac.webkit.org/projects/webkit/changeset/28002