Bug 964875 part 1. Add a WebIDL ChromeWindow interface for use in instanceof once Window is on WebIDL bindings. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 05 Feb 2014 23:36:57 -0500
changeset 167145 97ee8ec34362e77e7f2fa5627eee07380049d02a
parent 167144 9b6d7332710c2b929e3d8abb2343992b9ccd8679
child 167146 ef6e5cfea527314e63184499e78d3d277dae3d6e
push id26159
push usercbook@mozilla.com
push dateThu, 06 Feb 2014 11:50:11 +0000
treeherdermozilla-central@b04e2524e2eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs964875
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 964875 part 1. Add a WebIDL ChromeWindow interface for use in instanceof once Window is on WebIDL bindings. r=peterv
dom/bindings/Bindings.conf
dom/bindings/Codegen.py
dom/webidl/Window.webidl
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -208,16 +208,21 @@ DOMInterfaces = {
     'nativeType': 'nsDOMCaretPosition',
 },
 
 'CharacterData': {
     'nativeType': 'nsGenericDOMDataNode',
     'concrete': False
 },
 
+'ChromeWindow': {
+    'concrete': False,
+    'register': False,
+},
+
 'ChromeWorker': {
     'headerFile': 'mozilla/dom/WorkerPrivate.h',
     'nativeType': 'mozilla::dom::workers::ChromeWorkerPrivate',
 },
 
 'DOMRectList': {
     'headerFile': 'mozilla/dom/DOMRect.h',
     'resultNotAddRefed': [ 'item' ]
@@ -1489,16 +1494,18 @@ DOMInterfaces = {
 
 'WheelEvent': {
     'headerFile': 'DOMWheelEvent.h',
     'nativeType': 'mozilla::dom::DOMWheelEvent',
 },
 
 'Window': {
     'nativeType': 'nsGlobalWindow',
+    # When turning on Window, remember to drop the "'register': False"
+    # from ChromeWindow.
     'hasXPConnectImpls': True,
     'register': False,
     'implicitJSContext': [ 'setInterval', 'setTimeout' ],
     'binaryNames': {
         'postMessage': 'postMessageMoz',
     },
 },
 
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -1281,25 +1281,29 @@ class CGClassHasInstanceHook(CGAbstractS
         hasInstanceCode = """
   const DOMClass* domClass = GetDOMClass(js::UncheckedUnwrap(instance));
   *bp = false;
   if (!domClass) {
     // Not a DOM object, so certainly not an instance of this interface
     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;
 
 def isChromeOnly(m):
     return m.getExtendedAttribute("ChromeOnly")
 
 def getAvailableInTestFunc(obj):
     availableIn = obj.getExtendedAttribute("AvailableIn")
--- a/dom/webidl/Window.webidl
+++ b/dom/webidl/Window.webidl
@@ -334,8 +334,12 @@ partial interface Window {
   [Replaceable, Throws] readonly attribute object? content;
 
   [ChromeOnly, Throws] readonly attribute object? __content;
 };
 
 Window implements TouchEventHandlers;
 
 Window implements OnErrorEventHandlerForWindow;
+
+[ChromeOnly] interface ChromeWindow {};
+
+Window implements ChromeWindow;