diff --git a/accessible/src/windows/msaa/DocAccessibleWrap.cpp b/accessible/src/windows/msaa/DocAccessibleWrap.cpp index 84da422820e6..03c0767cbf5c 100644 --- a/accessible/src/windows/msaa/DocAccessibleWrap.cpp +++ b/accessible/src/windows/msaa/DocAccessibleWrap.cpp @@ -279,7 +279,7 @@ DocAccessibleWrap::DoInitialUpdate() // Create window for tab document. if (mDocFlags & eTabDocument) { mozilla::dom::TabChild* tabChild = - mozilla::dom::GetTabChildFrom(mDocumentNode->GetShell()); + mozilla::dom::TabChild::GetFrom(mDocumentNode->GetShell()); a11y::RootAccessible* rootDocument = RootAccessible(); diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 794fa4b27490..ed834ce6072b 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -12731,7 +12731,7 @@ nsDocShell::GetAppId(uint32_t* aAppId) NS_IMETHODIMP nsDocShell::GetAsyncPanZoomEnabled(bool* aOut) { - if (TabChild* tabChild = GetTabChildFrom(this)) { + if (TabChild* tabChild = TabChild::GetFrom(this)) { *aOut = tabChild->IsAsyncPanZoomEnabled(); return NS_OK; } diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp index 51f7027a4a85..8a1d981a0162 100644 --- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -2154,7 +2154,7 @@ public: // because owner implements nsITabChild, we can assume that it is // the one and only TabChild. - TabChild* child = GetTabChildFrom(mWindow->GetDocShell()); + TabChild* child = TabChild::GetFrom(mWindow->GetDocShell()); if (!child) { return NS_OK; } @@ -3173,7 +3173,7 @@ nsDOMDeviceStorage::EnumerateInternal(const nsAString& aPath, if (XRE_GetProcessType() == GeckoProcessType_Content) { // because owner implements nsITabChild, we can assume that it is // the one and only TabChild. - TabChild* child = GetTabChildFrom(win->GetDocShell()); + TabChild* child = TabChild::GetFrom(win->GetDocShell()); if (!child) { return cursor.forget(); } diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index 49b8de07627e..6ac17c0928bf 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -148,7 +148,7 @@ IDBFactory::Create(nsPIDOMWindow* aWindow, factory->mContentParent = aContentParent; if (!IndexedDatabaseManager::IsMainProcess()) { - TabChild* tabChild = GetTabChildFrom(aWindow); + TabChild* tabChild = TabChild::GetFrom(aWindow); NS_ENSURE_TRUE(tabChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); IndexedDBChild* actor = new IndexedDBChild(origin); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 2eeb51039829..77300d8e1c04 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -388,13 +388,13 @@ TabChild::Observe(nsISupports *aSubject, { if (!strcmp(aTopic, CANCEL_DEFAULT_PAN_ZOOM)) { nsCOMPtr docShell(do_QueryInterface(aSubject)); - nsCOMPtr tabChild(GetTabChildFrom(docShell)); + nsCOMPtr tabChild(TabChild::GetFrom(docShell)); if (tabChild == this) { mRemoteFrame->CancelDefaultPanZoom(); } } else if (!strcmp(aTopic, BROWSER_ZOOM_TO_RECT)) { nsCOMPtr docShell(do_QueryInterface(aSubject)); - nsCOMPtr tabChild(GetTabChildFrom(docShell)); + nsCOMPtr tabChild(TabChild::GetFrom(docShell)); if (tabChild == this) { CSSRect rect; sscanf(NS_ConvertUTF16toUTF8(aData).get(), @@ -442,7 +442,7 @@ TabChild::Observe(nsISupports *aSubject, } } else if (!strcmp(aTopic, DETECT_SCROLLABLE_SUBFRAME)) { nsCOMPtr docShell(do_QueryInterface(aSubject)); - nsCOMPtr tabChild(GetTabChildFrom(docShell)); + nsCOMPtr tabChild(TabChild::GetFrom(docShell)); if (tabChild == this) { mRemoteFrame->DetectScrollableSubframe(); } diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 326b8e550a32..8b4cf02893c1 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -342,6 +342,33 @@ public: void UpdateHitRegion(const nsRegion& aRegion); + static inline TabChild* + GetFrom(nsIDocShell* aDocShell) + { + nsCOMPtr tc = do_GetInterface(aDocShell); + return static_cast(tc.get()); + } + + static inline TabChild* + GetFrom(nsIPresShell* aPresShell) + { + nsIDocument* doc = aPresShell->GetDocument(); + if (!doc) { + return nullptr; + } + nsCOMPtr container = doc->GetContainer(); + nsCOMPtr docShell(do_QueryInterface(container)); + return GetFrom(docShell); + } + + static inline TabChild* + GetFrom(nsIDOMWindow* aWindow) + { + nsCOMPtr webNav = do_GetInterface(aWindow); + nsCOMPtr docShell = do_QueryInterface(webNav); + return GetFrom(docShell); + } + protected: virtual PRenderFrameChild* AllocPRenderFrameChild(ScrollingBehavior* aScrolling, TextureFactoryIdentifier* aTextureFactoryIdentifier, @@ -477,33 +504,6 @@ private: DISALLOW_EVIL_CONSTRUCTORS(TabChild); }; -inline TabChild* -GetTabChildFrom(nsIDocShell* aDocShell) -{ - nsCOMPtr tc = do_GetInterface(aDocShell); - return static_cast(tc.get()); -} - -inline TabChild* -GetTabChildFrom(nsIPresShell* aPresShell) -{ - nsIDocument* doc = aPresShell->GetDocument(); - if (!doc) { - return nullptr; - } - nsCOMPtr container = doc->GetContainer(); - nsCOMPtr docShell(do_QueryInterface(container)); - return GetTabChildFrom(docShell); -} - -inline TabChild* -GetTabChildFrom(nsIDOMWindow* aWindow) -{ - nsCOMPtr webNav = do_GetInterface(aWindow); - nsCOMPtr docShell = do_QueryInterface(webNav); - return GetTabChildFrom(docShell); -} - } } diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index 8f8649459fc4..d3f98705672a 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -1461,7 +1461,7 @@ Geolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request) // because owner implements nsITabChild, we can assume that it is // the one and only TabChild. - TabChild* child = GetTabChildFrom(window->GetDocShell()); + TabChild* child = TabChild::GetFrom(window->GetDocShell()); if (!child) { return false; } diff --git a/dom/src/notification/DesktopNotification.cpp b/dom/src/notification/DesktopNotification.cpp index 623042bc2bb1..291f6a3c5e90 100644 --- a/dom/src/notification/DesktopNotification.cpp +++ b/dom/src/notification/DesktopNotification.cpp @@ -161,7 +161,7 @@ DesktopNotification::Init() // because owner implements nsITabChild, we can assume that it is // the one and only TabChild for this docshell. - TabChild* child = GetTabChildFrom(GetOwner()->GetDocShell()); + TabChild* child = TabChild::GetFrom(GetOwner()->GetDocShell()); // Retain a reference so the object isn't deleted without IPDL's knowledge. // Corresponding release occurs in DeallocPContentPermissionRequest. diff --git a/dom/src/notification/Notification.cpp b/dom/src/notification/Notification.cpp index c1b5fd16b8d3..8488ab456da2 100644 --- a/dom/src/notification/Notification.cpp +++ b/dom/src/notification/Notification.cpp @@ -140,7 +140,7 @@ NotificationPermissionRequest::Run() if (XRE_GetProcessType() == GeckoProcessType_Content) { // because owner implements nsITabChild, we can assume that it is // the one and only TabChild. - TabChild* child = GetTabChildFrom(mWindow->GetDocShell()); + TabChild* child = TabChild::GetFrom(mWindow->GetDocShell()); if (!child) { return NS_ERROR_NOT_AVAILABLE; } diff --git a/hal/sandbox/SandboxHal.cpp b/hal/sandbox/SandboxHal.cpp index 8262374c459d..9c8d26b6e56d 100644 --- a/hal/sandbox/SandboxHal.cpp +++ b/hal/sandbox/SandboxHal.cpp @@ -52,7 +52,7 @@ Vibrate(const nsTArray& pattern, const WindowIdentifier &id) WindowIdentifier newID(id); newID.AppendProcessID(); - Hal()->SendVibrate(p, newID.AsArray(), GetTabChildFrom(newID.GetWindow())); + Hal()->SendVibrate(p, newID.AsArray(), TabChild::GetFrom(newID.GetWindow())); } void @@ -62,7 +62,7 @@ CancelVibrate(const WindowIdentifier &id) WindowIdentifier newID(id); newID.AppendProcessID(); - Hal()->SendCancelVibrate(newID.AsArray(), GetTabChildFrom(newID.GetWindow())); + Hal()->SendCancelVibrate(newID.AsArray(), TabChild::GetFrom(newID.GetWindow())); } void diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index b272941318ed..637031f07094 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -2655,7 +2655,7 @@ nsPresContext::IsCrossProcessRootContentDocument() return true; } - TabChild* tabChild = GetTabChildFrom(mShell); + TabChild* tabChild = TabChild::GetFrom(mShell); return (tabChild && tabChild->IsRootContentDocument()); } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index f08912177c2d..6460ab9315a0 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4978,7 +4978,7 @@ void PresShell::UpdateCanvasBackground() mCanvasBackgroundColor = GetDefaultBackgroundColorToDraw(); } if (XRE_GetProcessType() == GeckoProcessType_Content) { - if (TabChild* tabChild = GetTabChildFrom(this)) { + if (TabChild* tabChild = TabChild::GetFrom(this)) { tabChild->SetBackgroundColor(mCanvasBackgroundColor); } } @@ -5471,7 +5471,7 @@ public: !mFrame || !mShell) { return; } - TabChild* tabChild = GetTabChildFrom(mShell); + TabChild* tabChild = TabChild::GetFrom(mShell); if (!tabChild || !tabChild->GetUpdateHitRegion()) { return; } @@ -9420,7 +9420,7 @@ PresShell::SetIsActive(bool aIsActive) // and (ii) has easy access to the TabChild. So we use this // notification to signal the TabChild to drop its layer tree and // stop trying to repaint. - if (TabChild* tab = GetTabChildFrom(this)) { + if (TabChild* tab = TabChild::GetFrom(this)) { if (aIsActive) { tab->MakeVisible(); if (!mIsZombie) { @@ -9561,7 +9561,7 @@ nsIPresShell::RecomputeFontSizeInflationEnabled() // Force-enabling font inflation always trumps the heuristics here. if (!FontSizeInflationForceEnabled()) { - if (TabChild* tab = GetTabChildFrom(this)) { + if (TabChild* tab = TabChild::GetFrom(this)) { // We're in a child process. Cancel inflation if we're not // async-pan zoomed. if (!tab->IsAsyncPanZoomEnabled()) { diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 02a9b5838a1f..e6e6a4831ebe 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -614,7 +614,7 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte nsCString(aMimeContentType), disp, aForceSave, contentLength, referrerParams, - mozilla::dom::GetTabChildFrom(window)); + mozilla::dom::TabChild::GetFrom(window)); ExternalHelperAppChild *childListener = static_cast(pc); NS_ADDREF(*aStreamListener = childListener);