Bug 1138290 - New option in WindowWatcher.openWindow to open another toplevel window on b2g. r=roc

This commit is contained in:
Shelly Lin 2015-04-29 17:25:26 +08:00
parent 23be71ff8d
commit 173e809a66
6 changed files with 58 additions and 6 deletions

View File

@ -21,7 +21,7 @@ interface nsITabParent;
interface nsIURI;
interface nsIWebBrowserChrome;
[scriptable, uuid(e28f810b-9b49-4927-a4be-62a74fadfe21)]
[scriptable, uuid(b6c44689-f97e-4f32-a723-29eeddfbdc53)]
interface nsIWindowCreator2 : nsIWindowCreator {
@ -59,4 +59,14 @@ interface nsIWindowCreator2 : nsIWindowCreator {
in nsIURI uri,
in nsITabParent aOpeningTab,
out boolean cancel);
/**
* B2G multi-screen support. When open another top-level window on b2g,
* a screen ID is needed for identifying which screen this window is
* opened to.
* @param aScreenId Differentiate screens of windows. It is platform-
* specific due to the hardware limitation for now.
*/
[noscript]
void setScreenId(in uint32_t aScreenId);
};

View File

@ -614,6 +614,17 @@ nsAppStartup::CreateChromeWindow(nsIWebBrowserChrome *aParent,
// nsAppStartup->nsIWindowCreator2
//
NS_IMETHODIMP
nsAppStartup::SetScreenId(uint32_t aScreenId)
{
nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
if (!appShell) {
return NS_ERROR_FAILURE;
}
return appShell->SetScreenId(aScreenId);
}
NS_IMETHODIMP
nsAppStartup::CreateChromeWindow2(nsIWebBrowserChrome *aParent,
uint32_t aChromeFlags,

View File

@ -94,8 +94,9 @@ struct nsWidgetInitData {
mBorderStyle(eBorderStyle_default),
mPopupHint(ePopupTypePanel),
mPopupLevel(ePopupLevelTop),
clipChildren(false),
clipSiblings(false),
mScreenId(0),
clipChildren(false),
clipSiblings(false),
mDropShadow(false),
mListenForResizes(false),
mUnicode(true),
@ -113,6 +114,10 @@ struct nsWidgetInitData {
nsBorderStyle mBorderStyle;
nsPopupType mPopupHint;
nsPopupLevel mPopupLevel;
// B2G multi-screen support. Screen ID is for differentiating screens of
// windows, and due to the hardware limitation, it is platform-specific for
// now, which align with the value of display type defined in HWC.
uint32_t mScreenId;
// when painting exclude area occupied by child windows and sibling windows
bool clipChildren, clipSiblings, mDropShadow;
bool mListenForResizes;

View File

@ -58,11 +58,12 @@ using namespace mozilla;
class nsIAppShell;
nsAppShellService::nsAppShellService() :
nsAppShellService::nsAppShellService() :
mXPCOMWillShutDown(false),
mXPCOMShuttingDown(false),
mModalWindowCount(0),
mApplicationProvidedHiddenWindow(false)
mApplicationProvidedHiddenWindow(false),
mScreenId(0)
{
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
@ -90,6 +91,13 @@ nsAppShellService::CreateHiddenWindow()
return CreateHiddenWindowHelper(false);
}
NS_IMETHODIMP
nsAppShellService::SetScreenId(uint32_t aScreenId)
{
mScreenId = aScreenId;
return NS_OK;
}
void
nsAppShellService::EnsurePrivateHiddenWindow()
{
@ -600,6 +608,13 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
widgetInitData.mRTL = isRTL;
}
#ifdef MOZ_WIDGET_GONK
// B2G multi-screen support. Screen ID is for differentiating screens of
// windows, and due to the hardware limitation, it is platform-specific for
// now, which align with the value of display type defined in HWC.
widgetInitData.mScreenId = mScreenId;
#endif
nsresult rv = window->Initialize(parent, center ? aParent : nullptr,
aUrl, aInitialWidth, aInitialHeight,
aIsHiddenWindow, aOpeningTab, widgetInitData);

View File

@ -51,6 +51,7 @@ protected:
bool mXPCOMShuttingDown;
uint16_t mModalWindowCount;
bool mApplicationProvidedHiddenWindow;
uint32_t mScreenId;
};
#endif

View File

@ -18,7 +18,7 @@ interface nsITabParent;
#include "js/TypeDecls.h"
%}
[scriptable, uuid(41a2f0c6-3ca1-44f9-8efa-744a43aa399d)]
[scriptable, uuid(83f23c7e-6ce0-433f-9fe2-f287ae8c6e0c)]
interface nsIAppShellService : nsISupports
{
/**
@ -60,6 +60,16 @@ interface nsIAppShellService : nsISupports
void destroyHiddenWindow();
/**
* B2G multi-screen support. When open another top-level window on b2g,
* a screen ID is needed for identifying which screen this window is
* opened to.
* @param aScreenId Differentiate screens of windows. It is platform-
* specific due to the hardware limitation for now.
*/
[noscript]
void setScreenId(in uint32_t aScreenId);
/**
* Return the (singleton) application hidden window, automatically created
* and maintained by this AppShellService.