Bug 1102060 - Part2: Change the way to send/rcv for ScreenForBrowser. r=smaug

This commit is contained in:
chunminchang 2015-02-03 16:03:28 +08:00
parent 9df7469a59
commit c56433b717
4 changed files with 14 additions and 5 deletions

View File

@ -9,6 +9,7 @@ include protocol PContent;
include "mozilla/GfxMessageUtils.h"; include "mozilla/GfxMessageUtils.h";
using struct nsIntRect from "nsRect.h"; using struct nsIntRect from "nsRect.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -49,7 +50,7 @@ parent:
returns (ScreenDetails screen, returns (ScreenDetails screen,
bool success); bool success);
prio(high) sync ScreenForBrowser(PBrowser aBrowser) prio(high) sync ScreenForBrowser(TabId aTabId)
returns (ScreenDetails screen, returns (ScreenDetails screen,
bool success); bool success);

View File

@ -9,6 +9,7 @@
#include "nsIWidget.h" #include "nsIWidget.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "ScreenManagerParent.h" #include "ScreenManagerParent.h"
#include "ContentProcessManager.h"
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -116,7 +117,7 @@ ScreenManagerParent::RecvScreenForRect(const int32_t& aLeft,
} }
bool bool
ScreenManagerParent::RecvScreenForBrowser(PBrowserParent* aBrowser, ScreenManagerParent::RecvScreenForBrowser(const TabId& aTabId,
ScreenDetails* aRetVal, ScreenDetails* aRetVal,
bool* aSuccess) bool* aSuccess)
{ {
@ -129,7 +130,14 @@ ScreenManagerParent::RecvScreenForBrowser(PBrowserParent* aBrowser,
// Find the mWidget associated with the tabparent, and then return // Find the mWidget associated with the tabparent, and then return
// the nsIScreen it's on. // the nsIScreen it's on.
TabParent* tabParent = static_cast<TabParent*>(aBrowser); ContentParent* cp = static_cast<ContentParent*>(this->Manager());
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
nsRefPtr<TabParent> tabParent =
cpm->GetTopLevelTabParentByProcessAndTabId(cp->ChildID(), aTabId);
if(!tabParent){
return false;
}
nsCOMPtr<nsIWidget> widget = tabParent->GetWidget(); nsCOMPtr<nsIWidget> widget = tabParent->GetWidget();
nsCOMPtr<nsIScreen> screen; nsCOMPtr<nsIScreen> screen;

View File

@ -41,7 +41,7 @@ class ScreenManagerParent : public PScreenManagerParent
ScreenDetails* aRetVal, ScreenDetails* aRetVal,
bool* aSuccess) MOZ_OVERRIDE; bool* aSuccess) MOZ_OVERRIDE;
virtual bool RecvScreenForBrowser(PBrowserParent* aBrowser, virtual bool RecvScreenForBrowser(const TabId& aTabId,
ScreenDetails* aRetVal, ScreenDetails* aRetVal,
bool* aSuccess) MOZ_OVERRIDE; bool* aSuccess) MOZ_OVERRIDE;

View File

@ -126,7 +126,7 @@ nsScreenManagerProxy::ScreenForNativeWidget(void* aWidget,
// for it. // for it.
bool success = false; bool success = false;
ScreenDetails details; ScreenDetails details;
unused << SendScreenForBrowser(tabChild, &details, &success); unused << SendScreenForBrowser(tabChild->GetTabId(), &details, &success);
if (!success) { if (!success) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }