Bug 766902 - Don't listen for fullscreenchange when screen has been locked by an application. r=smaug

This commit is contained in:
Mounir Lamouri 2012-06-22 10:53:03 +02:00
parent b17b10b8dc
commit 0637b22b08

View File

@ -318,6 +318,7 @@ NS_IMETHODIMP
nsScreen::MozLockOrientation(const nsAString& aOrientation, bool* aReturn)
{
ScreenOrientation orientation;
*aReturn = false;
if (aOrientation.EqualsLiteral("portrait")) {
orientation = eScreenOrientation_Portrait;
@ -332,37 +333,31 @@ nsScreen::MozLockOrientation(const nsAString& aOrientation, bool* aReturn)
} else if (aOrientation.EqualsLiteral("landscape-secondary")) {
orientation = eScreenOrientation_LandscapeSecondary;
} else {
*aReturn = false;
return NS_OK;
}
if (!GetOwner()) {
*aReturn = false;
return NS_OK;
}
if (!IsChromeType(GetOwner()->GetDocShell())) {
// Chrome code and apps can always lock the screen orientation.
if (!IsChromeType(GetOwner()->GetDocShell()) &&
!static_cast<nsGlobalWindow*>(GetOwner())->IsPartOfApp()) {
nsCOMPtr<nsIDOMDocument> doc;
GetOwner()->GetDocument(getter_AddRefs(doc));
if (!doc) {
*aReturn = false;
return NS_OK;
}
// Apps and frames contained in apps can lock orientation.
// But non-apps can lock orientation only if they're fullscreen.
if (!static_cast<nsGlobalWindow*>(GetOwner())->IsPartOfApp()) {
bool fullscreen;
doc->GetMozFullScreen(&fullscreen);
if (!fullscreen) {
*aReturn = false;
return NS_OK;
}
// Non-apps content can lock orientation only if fullscreen.
bool fullscreen;
doc->GetMozFullScreen(&fullscreen);
if (!fullscreen) {
return NS_OK;
}
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(GetOwner());
if (!target) {
*aReturn = false;
return NS_OK;
}