Bug 29183
| Summary: | refactor event handling code in WI.Object to make it mixin-able | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Patrick Mueller <pmuellr> |
| Component: | Web Inspector (Deprecated) | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED WONTFIX | ||
| Severity: | Normal | CC: | bburg |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | All | ||
| OS: | All | ||
Patrick Mueller
The current event handling logic in WebInspector.Object (Object.js) is quite nice, but could be made more consumable.
Rather than require someone who wants to use it to subclass this class, seems like it would be nice to able to "mixin" the functionality, at an event level. For instance, conceptually I might have a class which has some events, and for each event I might be able to do something like:
WebInspector.EventMixin.add(myClass, "fooBar")
which would add the methods to the class's prototype
addFooBarListener(...)
removeFooBarListener(...)
_dispatchFooBarEvent(...)
These messages would lazily create a _fooBarEventListeners property as needed. Or something.
This would then be useful to use instead of the current single-listener event handlers like onattach, onpopulate, etc, in TreeOutline, so that you could have more than one listener without jumping through nasty hoops like daisy chaining them (I assume you could daisy chain them in simple cases).
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Timothy Hatcher
I don't see why this is needed. Any class in the WebInspector should just inherit WebInspector.Object and there is no problem. But I have never been "mix-in" person, so I might not understand the utility.
Timothy Hatcher
This would be the first use of mix-ins in the Inspector. So I think we really need to understand the benefit and reasoning. And why the current code isn't enough.