Bug 964875 part 1. Add a WebIDL ChromeWindow interface for use in instanceof once Window is on WebIDL bindings. r=peterv

This commit is contained in:
Boris Zbarsky 2014-02-05 23:36:57 -05:00
parent 6a25a13986
commit b58f2006a2
3 changed files with 17 additions and 2 deletions

View File

@ -213,6 +213,11 @@ DOMInterfaces = {
'concrete': False
},
'ChromeWindow': {
'concrete': False,
'register': False,
},
'ChromeWorker': {
'headerFile': 'mozilla/dom/WorkerPrivate.h',
'nativeType': 'mozilla::dom::workers::ChromeWorkerPrivate',
@ -1494,6 +1499,8 @@ DOMInterfaces = {
'Window': {
'nativeType': 'nsGlobalWindow',
# When turning on Window, remember to drop the "'register': False"
# from ChromeWindow.
'hasXPConnectImpls': True,
'register': False,
'implicitJSContext': [ 'setInterval', 'setTimeout' ],

View File

@ -1286,15 +1286,19 @@ class CGClassHasInstanceHook(CGAbstractStaticMethod):
return true;
}
"""
if self.descriptor.interface.identifier.name == "ChromeWindow":
setBp = "*bp = UnwrapDOMObject<nsGlobalWindow>(js::UncheckedUnwrap(instance))->IsChromeWindow()"
else:
setBp = "*bp = true"
# Sort interaces implementing self by name so we get stable output.
for iface in sorted(self.descriptor.interface.interfacesImplementingSelf,
key=lambda iface: iface.identifier.name):
hasInstanceCode += """
if (domClass->mInterfaceChain[PrototypeTraits<prototypes::id::%s>::Depth] == prototypes::id::%s) {
*bp = true;
%s;
return true;
}
""" % (iface.identifier.name, iface.identifier.name)
""" % (iface.identifier.name, iface.identifier.name, setBp)
hasInstanceCode += " return true;"
return header + hasInstanceCode;

View File

@ -339,3 +339,7 @@ partial interface Window {
Window implements TouchEventHandlers;
Window implements OnErrorEventHandlerForWindow;
[ChromeOnly] interface ChromeWindow {};
Window implements ChromeWindow;