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";
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);

View File

@ -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<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<nsIScreen> screen;

View File

@ -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;

View File

@ -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;
}