Bug 964875 part 2. Add a static nsGlobalWindow::IsChromeWindow test function for use in Func annotations. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 05 Feb 2014 23:36:59 -0500
changeset 167146 ef6e5cfea527314e63184499e78d3d277dae3d6e
parent 167145 97ee8ec34362e77e7f2fa5627eee07380049d02a
child 167147 9dcc5957f89eab6a77e0745425180cd7e96171e1
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 2. Add a static nsGlobalWindow::IsChromeWindow test function for use in Func annotations. r=peterv
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4085,16 +4085,29 @@ nsGlobalWindow::GetOwnPropertyNames(JSCo
                                     ErrorResult& aRv)
 {
   nsScriptNameSpaceManager* nameSpaceManager = GetNameSpaceManager();
   if (nameSpaceManager) {
     nameSpaceManager->EnumerateGlobalNames(EnumerateGlobalName, &aNames);
   }
 }
 
+/* static */ bool
+nsGlobalWindow::IsChromeWindow(JSContext* aCx, JSObject* aObj)
+{
+  // For now, have to deal with XPConnect objects here.
+  nsGlobalWindow* win;
+  nsresult rv = UNWRAP_OBJECT(Window, aObj, win);
+  if (NS_FAILED(rv)) {
+    nsCOMPtr<nsPIDOMWindow> piWin = do_QueryWrapper(aCx, aObj);
+    win = static_cast<nsGlobalWindow*>(piWin.get());
+  }
+  return win->IsChromeWindow();
+}
+
 nsIDOMOfflineResourceList*
 nsGlobalWindow::GetApplicationCache(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetApplicationCache, (aError), aError, nullptr);
 
   if (!mApplicationCache) {
     nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetDocShell()));
     if (!webNav) {
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -470,16 +470,18 @@ public:
   // nsIInterfaceRequestor
   NS_DECL_NSIINTERFACEREQUESTOR
 
   // WebIDL interface.
   already_AddRefed<nsIDOMWindow> IndexedGetter(uint32_t aIndex, bool& aFound);
 
   void GetSupportedNames(nsTArray<nsString>& aNames);
 
+  static bool IsChromeWindow(JSContext* /* unused */, JSObject* aObj);
+
   bool DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
                     JS::Handle<jsid> aId,
                     JS::MutableHandle<JSPropertyDescriptor> aDesc);
 
   void GetOwnPropertyNames(JSContext* aCx, nsTArray<nsString>& aNames,
                            mozilla::ErrorResult& aRv);
 
   // Object Management