Bug 727303 - Add nsPIDOMWindow::SetFullScreenInteral. r=roc
This commit is contained in:
@@ -8532,7 +8532,7 @@ public:
|
|||||||
NS_IMETHOD Run()
|
NS_IMETHOD Run()
|
||||||
{
|
{
|
||||||
if (mDoc->GetWindow()) {
|
if (mDoc->GetWindow()) {
|
||||||
mDoc->GetWindow()->SetFullScreen(mValue);
|
mDoc->GetWindow()->SetFullScreenInternal(mValue, false);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,12 @@ function nextTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
window.fullScreen = true;
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
is(window.fullScreen, false, "Shouldn't be able to set window fullscreen from content");
|
||||||
|
|
||||||
addLoadEvent(nextTest);
|
addLoadEvent(nextTest);
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
|||||||
@@ -4457,6 +4457,12 @@ nsGlobalWindow::GetNearestWidget()
|
|||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsGlobalWindow::SetFullScreen(bool aFullScreen)
|
nsGlobalWindow::SetFullScreen(bool aFullScreen)
|
||||||
|
{
|
||||||
|
return SetFullScreenInternal(aFullScreen, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aRequireTrust)
|
||||||
{
|
{
|
||||||
FORWARD_TO_OUTER(SetFullScreen, (aFullScreen), NS_ERROR_NOT_INITIALIZED);
|
FORWARD_TO_OUTER(SetFullScreen, (aFullScreen), NS_ERROR_NOT_INITIALIZED);
|
||||||
|
|
||||||
@@ -4464,11 +4470,10 @@ nsGlobalWindow::SetFullScreen(bool aFullScreen)
|
|||||||
|
|
||||||
bool rootWinFullScreen;
|
bool rootWinFullScreen;
|
||||||
GetFullScreen(&rootWinFullScreen);
|
GetFullScreen(&rootWinFullScreen);
|
||||||
// Only chrome can change our fullScreen mode, unless the DOM full-screen
|
// Only chrome can change our fullScreen mode, unless we're running in
|
||||||
// API is enabled.
|
// untrusted mode.
|
||||||
if ((aFullScreen == rootWinFullScreen ||
|
if (aFullScreen == rootWinFullScreen ||
|
||||||
!nsContentUtils::IsCallerTrustedForWrite()) &&
|
(aRequireTrust && !nsContentUtils::IsCallerTrustedForWrite())) {
|
||||||
!nsContentUtils::IsFullScreenApiEnabled()) {
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4478,11 +4483,11 @@ nsGlobalWindow::SetFullScreen(bool aFullScreen)
|
|||||||
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
|
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
|
||||||
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
||||||
treeItem->GetRootTreeItem(getter_AddRefs(rootItem));
|
treeItem->GetRootTreeItem(getter_AddRefs(rootItem));
|
||||||
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(rootItem);
|
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(rootItem);
|
||||||
if (!window)
|
if (!window)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
if (rootItem != treeItem)
|
if (rootItem != treeItem)
|
||||||
return window->SetFullScreen(aFullScreen);
|
return window->SetFullScreenInternal(aFullScreen, aRequireTrust);
|
||||||
|
|
||||||
// make sure we don't try to set full screen on a non-chrome window,
|
// make sure we don't try to set full screen on a non-chrome window,
|
||||||
// which might happen in embedding world
|
// which might happen in embedding world
|
||||||
|
|||||||
@@ -398,6 +398,7 @@ public:
|
|||||||
virtual NS_HIDDEN_(void) MaybeUpdateTouchState();
|
virtual NS_HIDDEN_(void) MaybeUpdateTouchState();
|
||||||
virtual NS_HIDDEN_(void) UpdateTouchState();
|
virtual NS_HIDDEN_(void) UpdateTouchState();
|
||||||
virtual NS_HIDDEN_(bool) DispatchCustomEvent(const char *aEventName);
|
virtual NS_HIDDEN_(bool) DispatchCustomEvent(const char *aEventName);
|
||||||
|
virtual NS_HIDDEN_(nsresult) SetFullScreenInternal(bool aIsFullScreen, bool aRequireTrust);
|
||||||
|
|
||||||
// nsIDOMStorageIndexedDB
|
// nsIDOMStorageIndexedDB
|
||||||
NS_DECL_NSIDOMSTORAGEINDEXEDDB
|
NS_DECL_NSIDOMSTORAGEINDEXEDDB
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ class nsIArray;
|
|||||||
class nsPIWindowRoot;
|
class nsPIWindowRoot;
|
||||||
|
|
||||||
#define NS_PIDOMWINDOW_IID \
|
#define NS_PIDOMWINDOW_IID \
|
||||||
{ 0x1352de12, 0x7a07, 0x4610, \
|
{ 0x9aef58e9, 0x5225, 0x4e58, \
|
||||||
{ 0x93, 0xd5, 0xb8, 0x76, 0xfe, 0x93, 0x09, 0x50 } }
|
{ 0x9a, 0xfb, 0xe6, 0x63, 0x97, 0x1d, 0x86, 0x88 } }
|
||||||
|
|
||||||
class nsPIDOMWindow : public nsIDOMWindowInternal
|
class nsPIDOMWindow : public nsIDOMWindowInternal
|
||||||
{
|
{
|
||||||
@@ -457,6 +457,13 @@ public:
|
|||||||
return mMayHaveTouchEventListener;
|
return mMayHaveTouchEventListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the top-level window into fullscreen mode if aIsFullScreen is true,
|
||||||
|
* otherwise exits fullscreen. If aRequireTrust is true, this method only
|
||||||
|
* changes window state in a context trusted for write.
|
||||||
|
*/
|
||||||
|
virtual nsresult SetFullScreenInternal(bool aIsFullScreen, bool aRequireTrust) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this to indicate that some node (this window, its document,
|
* Call this to indicate that some node (this window, its document,
|
||||||
* or content in that document) has a "MozAudioAvailable" event listener.
|
* or content in that document) has a "MozAudioAvailable" event listener.
|
||||||
|
|||||||
Reference in New Issue
Block a user