Bug 727303 - Add nsPIDOMWindow::SetFullScreenInteral. r=roc

This commit is contained in:
Chris Pearce
2012-02-20 10:02:08 +13:00
parent 5352c8ded2
commit fe02b726c5
5 changed files with 29 additions and 10 deletions

View File

@@ -4457,6 +4457,12 @@ nsGlobalWindow::GetNearestWidget()
NS_IMETHODIMP
nsGlobalWindow::SetFullScreen(bool aFullScreen)
{
return SetFullScreenInternal(aFullScreen, true);
}
nsresult
nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aRequireTrust)
{
FORWARD_TO_OUTER(SetFullScreen, (aFullScreen), NS_ERROR_NOT_INITIALIZED);
@@ -4464,11 +4470,10 @@ nsGlobalWindow::SetFullScreen(bool aFullScreen)
bool rootWinFullScreen;
GetFullScreen(&rootWinFullScreen);
// Only chrome can change our fullScreen mode, unless the DOM full-screen
// API is enabled.
if ((aFullScreen == rootWinFullScreen ||
!nsContentUtils::IsCallerTrustedForWrite()) &&
!nsContentUtils::IsFullScreenApiEnabled()) {
// Only chrome can change our fullScreen mode, unless we're running in
// untrusted mode.
if (aFullScreen == rootWinFullScreen ||
(aRequireTrust && !nsContentUtils::IsCallerTrustedForWrite())) {
return NS_OK;
}
@@ -4478,11 +4483,11 @@ nsGlobalWindow::SetFullScreen(bool aFullScreen)
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
nsCOMPtr<nsIDocShellTreeItem> rootItem;
treeItem->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(rootItem);
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(rootItem);
if (!window)
return NS_ERROR_FAILURE;
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,
// which might happen in embedding world