Bug 332195 - part 1: don't focus tabs by default, add pref to be able to revert late if we see too many issues, r=mconley

This commit is contained in:
Gijs Kruitbosch 2015-10-12 18:10:44 +01:00
parent 7a59c98583
commit 9644ce7b83
7 changed files with 62 additions and 21 deletions

View File

@ -451,6 +451,8 @@ pref("browser.tabs.selectOwnerOnClose", true);
pref("browser.tabs.showAudioPlayingIcon", true);
pref("browser.tabs.dontfocusfordialogs", true);
pref("browser.ctrlTab.previews", false);
// By default, do not export HTML at shutdown.

View File

@ -1110,6 +1110,7 @@
this.updateTitlebar();
this.mCurrentTab.removeAttribute("titlechanged");
this.mCurrentTab.removeAttribute("attention");
}
// If the new tab is busy, and our current state is not busy, then
@ -4330,15 +4331,28 @@
if (!event.isTrusted)
return;
// We're about to open a modal dialog, make sure the opening
// tab is brought to the front.
let targetIsWindow = event.target instanceof Window;
// We're about to open a modal dialog, so figure out for which tab:
// If this is a same-process modal dialog, then we're given its DOM
// window as the event's target. For remote dialogs, we're given the
// browser, but that's in the originalTarget.
// XXX Why originalTarget for the browser?
this.selectedTab = (event.target instanceof Window) ?
this._getTabForContentWindow(event.target.top) :
this.getTabForBrowser(event.originalTarget);
// browser, but that's in the originalTarget and not the target,
// because it's across the tabbrowser's XBL boundary.
let tabForEvent = targetIsWindow ?
this._getTabForContentWindow(event.target.top) :
this.getTabForBrowser(event.originalTarget);
// Don't need to act if the tab is already selected:
if (tabForEvent.selected)
return;
if (event.detail && event.detail.tabPrompt &&
Services.prefs.getBoolPref("browser.tabs.dontfocusfordialogs")) {
tabForEvent.setAttribute("attention", "true");
} else {
// bring tab to the front:
this.selectedTab = tabForEvent;
}
]]>
</handler>
<handler event="DOMTitleChanged">
@ -5831,16 +5845,16 @@
<content context="tabContextMenu">
<xul:stack class="tab-stack" flex="1">
<xul:hbox xbl:inherits="pinned,selected,visuallyselected,titlechanged,fadein"
<xul:hbox xbl:inherits="pinned,selected,visuallyselected,fadein"
class="tab-background">
<xul:hbox xbl:inherits="pinned,selected,visuallyselected,titlechanged"
<xul:hbox xbl:inherits="pinned,selected,visuallyselected"
class="tab-background-start"/>
<xul:hbox xbl:inherits="pinned,selected,visuallyselected,titlechanged"
<xul:hbox xbl:inherits="pinned,selected,visuallyselected"
class="tab-background-middle"/>
<xul:hbox xbl:inherits="pinned,selected,visuallyselected,titlechanged"
<xul:hbox xbl:inherits="pinned,selected,visuallyselected"
class="tab-background-end"/>
</xul:hbox>
<xul:hbox xbl:inherits="pinned,selected,visuallyselected,titlechanged"
<xul:hbox xbl:inherits="pinned,selected,visuallyselected,titlechanged,attention"
class="tab-content" align="center">
<xul:image xbl:inherits="fadein,pinned,busy,progress,selected,visuallyselected"
class="tab-throbber"
@ -5857,7 +5871,7 @@
role="presentation"/>
<xul:label flex="1"
anonid="tab-label"
xbl:inherits="value=visibleLabel,crop,accesskey,fadein,pinned,selected,visuallyselected"
xbl:inherits="value=visibleLabel,crop,accesskey,fadein,pinned,selected,visuallyselected,attention"
class="tab-text tab-label"
role="presentation"/>
<xul:image xbl:inherits="soundplaying,pinned,muted,visuallyselected"

View File

@ -63,7 +63,8 @@ var RemotePrompt = {
});
try {
PromptUtils.fireDialogEvent(window, "DOMWillOpenModalDialog", browser);
let eventDetail = {tabPrompt: true};
PromptUtils.fireDialogEvent(window, "DOMWillOpenModalDialog", browser, eventDetail);
args.promptActive = true;

View File

@ -283,12 +283,18 @@ window:not([chromehidden~="toolbar"]) #urlbar-wrapper {
pointer-events: auto;
}
.tabbrowser-tab[pinned][titlechanged]:not([visuallyselected="true"]) > .tab-stack > .tab-content {
.tabbrowser-tab[image] > .tab-stack > .tab-content[attention]:not([visuallyselected="true"]),
.tabbrowser-tab > .tab-stack > .tab-content[pinned][titlechanged]:not([visuallyselected="true"]) {
background-image: var(--pinned-tab-glow);
background-position: center;
background-size: 100%;
}
.tabbrowser-tab[image] > .tab-stack > .tab-content[attention]:not([pinned]):not([visuallyselected="true"]) {
background-position: left bottom var(--tab-toolbar-navbar-overlap);
background-size: 34px 100%;
}
.tabbrowser-arrowscrollbox > .scrollbutton-down:not([disabled]):hover,
.tabbrowser-arrowscrollbox > .scrollbutton-up:not([disabled]):hover,
.tabbrowser-tab:hover {

View File

@ -444,13 +444,23 @@
position: absolute;
}
.tabbrowser-tab[pinned][titlechanged]:not([visuallyselected="true"]) > .tab-stack > .tab-content {
.tabbrowser-tab[image] > .tab-stack > .tab-content[attention]:not([visuallyselected="true"]),
.tabbrowser-tab > .tab-stack > .tab-content[pinned][titlechanged]:not([visuallyselected="true"]) {
background-image: radial-gradient(farthest-corner at center bottom, rgb(255,255,255) 3%, rgba(186,221,251,0.75) 20%, rgba(127,179,255,0.25) 40%, transparent 70%);
background-position: center bottom var(--tab-toolbar-navbar-overlap);
background-repeat: no-repeat;
background-size: 85% 100%;
}
.tabbrowser-tab[image] > .tab-stack > .tab-content[attention]:not([pinned]):not([visuallyselected="true"]) {
background-position: left bottom var(--tab-toolbar-navbar-overlap);
background-size: 34px 100%;
}
.tab-label[attention]:not([visuallyselected="true"]) {
font-weight: bold;
}
/* Tab separators */
.tabbrowser-tab::after,

View File

@ -13,10 +13,16 @@ this.PromptUtils = {
// For remote dialogs, we pass in a different DOM window and a separate
// target. If the caller doesn't pass in the target, then we'll simply use
// the passed-in DOM window.
fireDialogEvent : function (domWin, eventName, maybeTarget) {
// The detail may contain information about the principal on which the
// prompt is triggered, as well as whether or not this is a tabprompt
// (ie tabmodal alert/prompt/confirm and friends)
fireDialogEvent : function (domWin, eventName, maybeTarget, detail) {
let target = maybeTarget || domWin;
let event = domWin.document.createEvent("Events");
event.initEvent(eventName, true, true);
let eventOptions = {cancelable: true, bubbles: true};
if (detail) {
eventOptions.detail = detail;
}
let event = new domWin.CustomEvent(eventName, eventOptions);
let winUtils = domWin.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
winUtils.dispatchEventToChromeOnly(target, event);

View File

@ -371,7 +371,8 @@ function openModalWindow(domWin, uri, args) {
}
function openTabPrompt(domWin, tabPrompt, args) {
PromptUtils.fireDialogEvent(domWin, "DOMWillOpenModalDialog");
let eventDetail = Cu.cloneInto({tabPrompt: true}, domWin);
PromptUtils.fireDialogEvent(domWin, "DOMWillOpenModalDialog", null, eventDetail);
let winUtils = domWin.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
@ -440,7 +441,8 @@ function openRemotePrompt(domWin, args, tabPrompt) {
.getInterface(Ci.nsITabChild)
.messageManager;
PromptUtils.fireDialogEvent(domWin, "DOMWillOpenModalDialog");
let eventDetail = Cu.cloneInto({tabPrompt}, domWin);
PromptUtils.fireDialogEvent(domWin, "DOMWillOpenModalDialog", null, eventDetail);
let winUtils = domWin.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);