Now that we control all the code that can attempt to touch
Components.interfaces.nsIDOM*, we can try to get rid of these interfaces
and their corresponding bloat.
The main issue is that we have consumers that use these for testing what
sort of object we have, like so:
if (obj instanceof Ci.nsIDOMWhatever)
and we'd need to find ways to make that work. In some cases various
hacky workarounds are possible in terms of property names the object has
and maybe their values, but they can end up pretty non-intuitive and
fragile. For example, this:
element instanceof Components.interfaces.nsIDOMHTMLEmbedElement
becomes:
element.localName === "embed" &&
element.namespaceURI === "http://www.w3.org/1999/xhtml"
and even that is only OK at the callsite in question because we know it
came from
http://searchfox.org/mozilla-central/rev/51b3d67a5ec1758bd2fe7d7b6e75ad6b6b5da223/dom/interfaces/xul/nsIDOMXULCommandDispatcher.idl#17
and hence we know it really is an Element...
Anyway, we need a replacement. Some possible options:
1) Use "obj instanceof Whatever". The problem is that we'd like to
maybe kill off the cross-global instanceof behavior we have now for DOM
constructors.
2) Introduce chromeonly "is" methods on all DOM constructors. So
"HTMLEmbedElement.is(obj)". Possibly with some nicer but uniform name.
3) Introduce chromeonly "isWhatever" methods (akin to Array.isArray) on
DOM constructors. So "HTMLEmbedElement.isHTMLEmbedElement(obj)". Kinda
wordy and repetitive...
4) Something else?
Thoughts? It really would be nice to get rid of some of this stuff
going forward. And since the web platform seems to be punting on
branding, there's no existing solution we can use.
-Boris
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform