From dd818f0292d784d8695be65d9cee9702a6b9c6ed Mon Sep 17 00:00:00 2001 From: chunminchang Date: Tue, 3 Feb 2015 16:03:28 +0800 Subject: [PATCH] Bug 1102060 - Part2: Change the way to send/rcv for ScreenForBrowser. r=smaug --- dom/ipc/PScreenManager.ipdl | 3 ++- dom/ipc/ScreenManagerParent.cpp | 12 ++++++++++-- dom/ipc/ScreenManagerParent.h | 2 +- widget/nsScreenManagerProxy.cpp | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/dom/ipc/PScreenManager.ipdl b/dom/ipc/PScreenManager.ipdl index 070c11f18b6b..d958993fb0ad 100644 --- a/dom/ipc/PScreenManager.ipdl +++ b/dom/ipc/PScreenManager.ipdl @@ -9,6 +9,7 @@ include protocol PContent; include "mozilla/GfxMessageUtils.h"; using struct nsIntRect from "nsRect.h"; +using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h"; namespace mozilla { namespace dom { @@ -49,7 +50,7 @@ parent: returns (ScreenDetails screen, bool success); - prio(high) sync ScreenForBrowser(PBrowser aBrowser) + prio(high) sync ScreenForBrowser(TabId aTabId) returns (ScreenDetails screen, bool success); diff --git a/dom/ipc/ScreenManagerParent.cpp b/dom/ipc/ScreenManagerParent.cpp index 19c7f42235fb..2e9e0c50ae69 100644 --- a/dom/ipc/ScreenManagerParent.cpp +++ b/dom/ipc/ScreenManagerParent.cpp @@ -9,6 +9,7 @@ #include "nsIWidget.h" #include "nsServiceManagerUtils.h" #include "ScreenManagerParent.h" +#include "ContentProcessManager.h" namespace mozilla { namespace dom { @@ -116,7 +117,7 @@ ScreenManagerParent::RecvScreenForRect(const int32_t& aLeft, } bool -ScreenManagerParent::RecvScreenForBrowser(PBrowserParent* aBrowser, +ScreenManagerParent::RecvScreenForBrowser(const TabId& aTabId, ScreenDetails* aRetVal, bool* aSuccess) { @@ -129,7 +130,14 @@ ScreenManagerParent::RecvScreenForBrowser(PBrowserParent* aBrowser, // Find the mWidget associated with the tabparent, and then return // the nsIScreen it's on. - TabParent* tabParent = static_cast(aBrowser); + ContentParent* cp = static_cast(this->Manager()); + ContentProcessManager* cpm = ContentProcessManager::GetSingleton(); + nsRefPtr tabParent = + cpm->GetTopLevelTabParentByProcessAndTabId(cp->ChildID(), aTabId); + if(!tabParent){ + return false; + } + nsCOMPtr widget = tabParent->GetWidget(); nsCOMPtr screen; diff --git a/dom/ipc/ScreenManagerParent.h b/dom/ipc/ScreenManagerParent.h index 666b8dd9391d..e2680e6d1d27 100644 --- a/dom/ipc/ScreenManagerParent.h +++ b/dom/ipc/ScreenManagerParent.h @@ -41,7 +41,7 @@ class ScreenManagerParent : public PScreenManagerParent ScreenDetails* aRetVal, bool* aSuccess) MOZ_OVERRIDE; - virtual bool RecvScreenForBrowser(PBrowserParent* aBrowser, + virtual bool RecvScreenForBrowser(const TabId& aTabId, ScreenDetails* aRetVal, bool* aSuccess) MOZ_OVERRIDE; diff --git a/widget/nsScreenManagerProxy.cpp b/widget/nsScreenManagerProxy.cpp index 747e2fbe6170..e014940ade97 100644 --- a/widget/nsScreenManagerProxy.cpp +++ b/widget/nsScreenManagerProxy.cpp @@ -126,7 +126,7 @@ nsScreenManagerProxy::ScreenForNativeWidget(void* aWidget, // for it. bool success = false; ScreenDetails details; - unused << SendScreenForBrowser(tabChild, &details, &success); + unused << SendScreenForBrowser(tabChild->GetTabId(), &details, &success); if (!success) { return NS_ERROR_FAILURE; }