зеркало из https://github.com/mozilla/gecko-dev.git
Bug 803675 - part1: window.open() open a new tab instead of window when browser is fullscreen mode and the caller is content context. r=bz
This commit is contained in:
Родитель
fd38f5b320
Коммит
82302d1551
|
@ -393,6 +393,13 @@ pref("browser.link.open_newwindow.override.external", -1);
|
|||
// 2: don't divert window.open with features
|
||||
pref("browser.link.open_newwindow.restriction", 2);
|
||||
|
||||
// Disable opening a new window via window.open if browser is in fullscreen mode
|
||||
#ifdef XP_MACOSX
|
||||
pref("browser.link.open_newwindow.disabled_in_fullscreen", true);
|
||||
#else
|
||||
pref("browser.link.open_newwindow.disabled_in_fullscreen", false);
|
||||
#endif
|
||||
|
||||
// Tabbed browser
|
||||
pref("browser.tabs.autoHide", false);
|
||||
pref("browser.tabs.closeWindowWithLastTab", true);
|
||||
|
|
|
@ -1587,6 +1587,17 @@ uint32_t nsWindowWatcher::CalculateChromeFlags(nsIDOMWindow *aParent,
|
|||
bool disableDialogFeature = false;
|
||||
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
|
||||
branch->GetBoolPref("dom.disable_window_open_dialog_feature", &disableDialogFeature);
|
||||
|
||||
bool isFullScreen = false;
|
||||
if (aParent) {
|
||||
aParent->GetFullScreen(&isFullScreen);
|
||||
}
|
||||
if (isFullScreen && !isCallerChrome) {
|
||||
// If the parent window is in fullscreen & the caller context is content,
|
||||
// dialog feature is disabled. (see bug 803675)
|
||||
disableDialogFeature = true;
|
||||
}
|
||||
|
||||
if (!disableDialogFeature) {
|
||||
chromeFlags |= WinHasOption(aFeatures, "dialog", 0, nullptr) ?
|
||||
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG : 0;
|
||||
|
|
|
@ -865,6 +865,12 @@ nsContentTreeOwner::ProvideWindow(nsIDOMWindow* aParent,
|
|||
return *aWindowIsNew ? NS_OK : NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
// the parent window is fullscreen mode or not.
|
||||
bool isFullScreen = false;
|
||||
if (aParent) {
|
||||
aParent->GetFullScreen(&isFullScreen);
|
||||
}
|
||||
|
||||
// Where should we open this?
|
||||
int32_t containerPref;
|
||||
if (NS_FAILED(Preferences::GetInt("browser.link.open_newwindow",
|
||||
|
@ -872,6 +878,14 @@ nsContentTreeOwner::ProvideWindow(nsIDOMWindow* aParent,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool isDisabledOpenNewWindow =
|
||||
isFullScreen &&
|
||||
Preferences::GetBool("browser.link.open_newwindow.disabled_in_fullscreen");
|
||||
|
||||
if (isDisabledOpenNewWindow && (containerPref == nsIBrowserDOMWindow::OPEN_NEWWINDOW)) {
|
||||
containerPref = nsIBrowserDOMWindow::OPEN_NEWTAB;
|
||||
}
|
||||
|
||||
if (containerPref != nsIBrowserDOMWindow::OPEN_NEWTAB &&
|
||||
containerPref != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW) {
|
||||
// Just open a window normally
|
||||
|
@ -891,6 +905,12 @@ nsContentTreeOwner::ProvideWindow(nsIDOMWindow* aParent,
|
|||
restrictionPref = 2; // Sane default behavior
|
||||
}
|
||||
|
||||
if (isDisabledOpenNewWindow) {
|
||||
// In browser fullscreen, the window should be opened
|
||||
// in the current window with no features (see bug 803675)
|
||||
restrictionPref = 0;
|
||||
}
|
||||
|
||||
if (restrictionPref == 1) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче