зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 16d82f57e0fb (bug 1602808) for bc failures on browser_privatebrowsing_windowtitle.js . CLOSED TREE
This commit is contained in:
Родитель
cc0919a14b
Коммит
7fba7adfcd
|
@ -8369,13 +8369,6 @@ var gPrivateBrowsingUI = {
|
||||||
|
|
||||||
// Adjust the window's title
|
// Adjust the window's title
|
||||||
let docElement = document.documentElement;
|
let docElement = document.documentElement;
|
||||||
if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
|
||||||
docElement.title = docElement.getAttribute("title_privatebrowsing");
|
|
||||||
docElement.setAttribute(
|
|
||||||
"titlemodifier",
|
|
||||||
docElement.getAttribute("titlemodifier_privatebrowsing")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
docElement.setAttribute(
|
docElement.setAttribute(
|
||||||
"privatebrowsingmode",
|
"privatebrowsingmode",
|
||||||
PrivateBrowsingUtils.permanentPrivateBrowsing ? "permanent" : "temporary"
|
PrivateBrowsingUtils.permanentPrivateBrowsing ? "permanent" : "temporary"
|
||||||
|
|
|
@ -40,26 +40,12 @@
|
||||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
xmlns="http://www.w3.org/1999/xhtml"
|
xmlns="http://www.w3.org/1999/xhtml"
|
||||||
title_normal="&mainWindow.title;"
|
|
||||||
#ifdef XP_MACOSX
|
|
||||||
title_privatebrowsing="&mainWindow.title;&mainWindow.titlemodifiermenuseparator;&mainWindow.titlePrivateBrowsingSuffix;"
|
|
||||||
titledefault="&mainWindow.title;"
|
|
||||||
titlemodifier=""
|
|
||||||
titlemodifier_normal=""
|
|
||||||
titlemodifier_privatebrowsing="&mainWindow.titlePrivateBrowsingSuffix;"
|
|
||||||
#else
|
|
||||||
title_privatebrowsing="&mainWindow.titlemodifier; &mainWindow.titlePrivateBrowsingSuffix;"
|
|
||||||
titlemodifier="&mainWindow.titlemodifier;"
|
|
||||||
titlemodifier_normal="&mainWindow.titlemodifier;"
|
|
||||||
titlemodifier_privatebrowsing="&mainWindow.titlemodifier; &mainWindow.titlePrivateBrowsingSuffix;"
|
|
||||||
#endif
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
chromemargin="0,2,2,2"
|
chromemargin="0,2,2,2"
|
||||||
#else
|
#else
|
||||||
chromemargin="0,-1,-1,-1"
|
chromemargin="0,-1,-1,-1"
|
||||||
#endif
|
#endif
|
||||||
tabsintitlebar="true"
|
tabsintitlebar="true"
|
||||||
titlemenuseparator="&mainWindow.titlemodifiermenuseparator;"
|
|
||||||
windowtype="navigator:browser"
|
windowtype="navigator:browser"
|
||||||
macanimationtype="document"
|
macanimationtype="document"
|
||||||
screenX="4" screenY="4"
|
screenX="4" screenY="4"
|
||||||
|
@ -83,7 +69,9 @@
|
||||||
<link rel="localization" href="preview/interventions.ftl"/>
|
<link rel="localization" href="preview/interventions.ftl"/>
|
||||||
<link rel="localization" href="browser/sidebarMenu.ftl"/>
|
<link rel="localization" href="browser/sidebarMenu.ftl"/>
|
||||||
|
|
||||||
<title>&mainWindow.title;</title>
|
<title
|
||||||
|
data-l10n-id="browser-main-window-title"
|
||||||
|
data-l10n-args='{"mode": "default"}'></title>
|
||||||
|
|
||||||
# All JS files which are needed by browser.xhtml and other top level windows to
|
# All JS files which are needed by browser.xhtml and other top level windows to
|
||||||
# support MacOS specific features *must* go into the global-scripts.inc file so
|
# support MacOS specific features *must* go into the global-scripts.inc file so
|
||||||
|
|
|
@ -208,6 +208,13 @@
|
||||||
*/
|
*/
|
||||||
_windowIsClosing: false,
|
_windowIsClosing: false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We'll use this to cache the accessor to the title element.
|
||||||
|
* It's important that the defualt is `undefined`, so that it
|
||||||
|
* can be set to `null` by the `querySelector`.
|
||||||
|
*/
|
||||||
|
_titleElement: undefined,
|
||||||
|
|
||||||
preloadedBrowser: null,
|
preloadedBrowser: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -913,32 +920,9 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
getWindowTitleForBrowser(aBrowser) {
|
getWindowTitleForBrowser(aBrowser) {
|
||||||
var newTitle = "";
|
let title = "";
|
||||||
var docElement = document.documentElement;
|
|
||||||
var sep = docElement.getAttribute("titlemenuseparator");
|
|
||||||
let tab = this.getTabForBrowser(aBrowser);
|
|
||||||
let docTitle;
|
|
||||||
|
|
||||||
if (tab._labelIsContentTitle) {
|
let docElement = document.documentElement;
|
||||||
// Strip out any null bytes in the content title, since the
|
|
||||||
// underlying widget implementations of nsWindow::SetTitle pass
|
|
||||||
// null-terminated strings to system APIs.
|
|
||||||
docTitle = tab.getAttribute("label").replace(/\0/g, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!docTitle) {
|
|
||||||
docTitle = docElement.getAttribute("titledefault");
|
|
||||||
}
|
|
||||||
|
|
||||||
var modifier = docElement.getAttribute("titlemodifier");
|
|
||||||
if (docTitle) {
|
|
||||||
newTitle += docElement.getAttribute("titlepreface") || "";
|
|
||||||
newTitle += docTitle;
|
|
||||||
if (modifier) {
|
|
||||||
newTitle += sep;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newTitle += modifier;
|
|
||||||
|
|
||||||
// If location bar is hidden and the URL type supports a host,
|
// If location bar is hidden and the URL type supports a host,
|
||||||
// add the scheme and host to the title to prevent spoofing.
|
// add the scheme and host to the title to prevent spoofing.
|
||||||
|
@ -946,30 +930,69 @@
|
||||||
try {
|
try {
|
||||||
if (docElement.getAttribute("chromehidden").includes("location")) {
|
if (docElement.getAttribute("chromehidden").includes("location")) {
|
||||||
const uri = Services.io.createExposableURI(aBrowser.currentURI);
|
const uri = Services.io.createExposableURI(aBrowser.currentURI);
|
||||||
if (uri.scheme === "about") {
|
let prefix = uri.prePath;
|
||||||
newTitle = `${uri.spec}${sep}${newTitle}`;
|
if (uri.scheme == "about") {
|
||||||
} else if (uri.scheme === "moz-extension") {
|
prefix = uri.spec;
|
||||||
|
} else if (uri.scheme == "moz-extension") {
|
||||||
const ext = WebExtensionPolicy.getByHostname(uri.host);
|
const ext = WebExtensionPolicy.getByHostname(uri.host);
|
||||||
if (ext && ext.name) {
|
if (ext && ext.name) {
|
||||||
const prefix = document.querySelector("#urlbar-label-extension")
|
let extensionLabel = document.getElementById(
|
||||||
.value;
|
"urlbar-label-extension"
|
||||||
newTitle = `${prefix} (${ext.name})${sep}${newTitle}`;
|
);
|
||||||
} else {
|
prefix = `${extensionLabel.value} (${ext.name})`;
|
||||||
newTitle = `${uri.prePath}${sep}${newTitle}`;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
newTitle = `${uri.prePath}${sep}${newTitle}`;
|
|
||||||
}
|
}
|
||||||
|
title = prefix + " - ";
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
return newTitle;
|
if (docElement.hasAttribute("titlepreface")) {
|
||||||
|
title += docElement.getAttribute("titlepreface");
|
||||||
|
}
|
||||||
|
|
||||||
|
let tab = this.getTabForBrowser(aBrowser);
|
||||||
|
|
||||||
|
if (tab._labelIsContentTitle) {
|
||||||
|
// Strip out any null bytes in the content title, since the
|
||||||
|
// underlying widget implementations of nsWindow::SetTitle pass
|
||||||
|
// null-terminated strings to system APIs.
|
||||||
|
title += tab.getAttribute("label").replace(/\0/g, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
let mode =
|
||||||
|
docElement.getAttribute("privatebrowsingmode") == "temporary"
|
||||||
|
? "private"
|
||||||
|
: "default";
|
||||||
|
|
||||||
|
if (title) {
|
||||||
|
return {
|
||||||
|
id:
|
||||||
|
mode == "private"
|
||||||
|
? "browser-main-window-content-title-private"
|
||||||
|
: "browser-main-window-content-title-default",
|
||||||
|
args: {
|
||||||
|
title,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: "browser-main-window-title",
|
||||||
|
args: {
|
||||||
|
mode,
|
||||||
|
},
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTitlebar() {
|
async updateTitlebar() {
|
||||||
document.title = this.getWindowTitleForBrowser(this.selectedBrowser);
|
if (!this._titleElement) {
|
||||||
|
this._titleElement = document.documentElement.querySelector("title");
|
||||||
|
}
|
||||||
|
|
||||||
|
let { id, args } = this.getWindowTitleForBrowser(this.selectedBrowser);
|
||||||
|
document.l10n.setAttributes(this._titleElement, id, args);
|
||||||
|
await document.l10n.translateElements([this._titleElement]);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateCurrentBrowser(aForceUpdate) {
|
updateCurrentBrowser(aForceUpdate) {
|
||||||
|
|
|
@ -1004,10 +1004,14 @@ class Window extends WindowBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitlePreface(titlePreface) {
|
setTitlePreface(titlePreface) {
|
||||||
this.window.document.documentElement.setAttribute(
|
if (!titlePreface) {
|
||||||
"titlepreface",
|
this.window.document.documentElement.removeAttribute("titlepreface");
|
||||||
titlePreface
|
} else {
|
||||||
);
|
this.window.document.documentElement.setAttribute(
|
||||||
|
"titlepreface",
|
||||||
|
titlePreface
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get focused() {
|
get focused() {
|
||||||
|
|
|
@ -378,7 +378,7 @@ this.windows = class extends ExtensionAPI {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(windowId, updateInfo) {
|
update: async function(windowId, updateInfo) {
|
||||||
if (updateInfo.state !== null && updateInfo.state != "normal") {
|
if (updateInfo.state !== null && updateInfo.state != "normal") {
|
||||||
if (
|
if (
|
||||||
updateInfo.left !== null ||
|
updateInfo.left !== null ||
|
||||||
|
@ -415,12 +415,12 @@ this.windows = class extends ExtensionAPI {
|
||||||
|
|
||||||
if (updateInfo.titlePreface !== null) {
|
if (updateInfo.titlePreface !== null) {
|
||||||
win.setTitlePreface(updateInfo.titlePreface);
|
win.setTitlePreface(updateInfo.titlePreface);
|
||||||
win.window.gBrowser.updateTitlebar();
|
await win.window.gBrowser.updateTitlebar();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: All the other properties, focused=false...
|
// TODO: All the other properties, focused=false...
|
||||||
|
|
||||||
return Promise.resolve(win.convert());
|
return win.convert();
|
||||||
},
|
},
|
||||||
|
|
||||||
remove: function(windowId) {
|
remove: function(windowId) {
|
||||||
|
|
|
@ -3,6 +3,48 @@
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
|
||||||
|
# This is the default window title in case there is no content
|
||||||
|
# title to be displayed.
|
||||||
|
#
|
||||||
|
# Depending on the $mode, the string will look like this (in en-US):
|
||||||
|
#
|
||||||
|
# "default" - "Mozilla Firefox"
|
||||||
|
# "private" - "Mozilla Firefox (Private Browsing)"
|
||||||
|
#
|
||||||
|
# Variables
|
||||||
|
# $mode (String) - "private" in case of a private browsing mode, "default" otherwise.
|
||||||
|
browser-main-window-title = { $mode ->
|
||||||
|
[private] { -brand-full-name } (Private Browsing)
|
||||||
|
*[default] { -brand-full-name }
|
||||||
|
}
|
||||||
|
|
||||||
|
## This is the default window title in case there is content
|
||||||
|
## title to be displayed.
|
||||||
|
##
|
||||||
|
## On macOS the title doesn't include the brand name, on all other
|
||||||
|
## platforms it does.
|
||||||
|
##
|
||||||
|
## For example, in private mode on Windows, the title will be:
|
||||||
|
## "Example Title - Mozilla Firefox (Private Browsing)"
|
||||||
|
##
|
||||||
|
## while on macOS in default mode it will be:
|
||||||
|
## "Example Title"
|
||||||
|
##
|
||||||
|
## Variables
|
||||||
|
## $title (String) - Content title string.
|
||||||
|
|
||||||
|
browser-main-window-content-title-default = { PLATFORM() ->
|
||||||
|
[macos] { $title }
|
||||||
|
*[other] { $title } - { -brand-full-name }
|
||||||
|
}
|
||||||
|
|
||||||
|
browser-main-window-content-title-private = { PLATFORM() ->
|
||||||
|
[macos] { $title } - (Private Browsing)
|
||||||
|
*[other] { $title } - { -brand-full-name } (Private Browsing)
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
urlbar-identity-button =
|
urlbar-identity-button =
|
||||||
.aria-label = View site information
|
.aria-label = View site information
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,6 @@
|
||||||
<!-- LOCALIZATION NOTE : FILE This file contains the browser main menu items -->
|
<!-- LOCALIZATION NOTE : FILE This file contains the browser main menu items -->
|
||||||
<!-- LOCALIZATION NOTE : FILE Do not translate commandkeys -->
|
<!-- LOCALIZATION NOTE : FILE Do not translate commandkeys -->
|
||||||
|
|
||||||
<!-- LOCALIZATION NOTE (mainWindow.title): DONT_TRANSLATE -->
|
|
||||||
<!ENTITY mainWindow.title "&brandFullName;">
|
|
||||||
<!-- LOCALIZATION NOTE (mainWindow.titlemodifier) : DONT_TRANSLATE -->
|
|
||||||
<!ENTITY mainWindow.titlemodifier "&brandFullName;">
|
|
||||||
<!-- LOCALIZATION NOTE (mainWindow.titlemodifiermenuseparator): DONT_TRANSLATE -->
|
|
||||||
<!ENTITY mainWindow.titlemodifiermenuseparator " - ">
|
|
||||||
<!-- LOCALIZATION NOTE (mainWindow.titlePrivateBrowsingSuffix): This will be appended to the window's title
|
|
||||||
inside the private browsing mode -->
|
|
||||||
<!ENTITY mainWindow.titlePrivateBrowsingSuffix "(Private Browsing)">
|
|
||||||
|
|
||||||
<!ENTITY appmenu.tooltip "Open menu">
|
<!ENTITY appmenu.tooltip "Open menu">
|
||||||
<!ENTITY navbarOverflow.label "More tools…">
|
<!ENTITY navbarOverflow.label "More tools…">
|
||||||
|
|
||||||
|
|
|
@ -247,12 +247,19 @@ PreviewController.prototype = {
|
||||||
// don't discard the cache of previews.
|
// don't discard the cache of previews.
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTitleAndTooltip() {
|
async updateTitleAndTooltip() {
|
||||||
let title = this.win.tabbrowser.getWindowTitleForBrowser(
|
let { id, args } = this.win.tabbrowser.getWindowTitleForBrowser(
|
||||||
this.linkedBrowser
|
this.linkedBrowser
|
||||||
);
|
);
|
||||||
this.preview.title = title;
|
let title = await this.win.tabbrowser.ownerDocument.l10n.formatValue(
|
||||||
this.preview.tooltip = title;
|
id,
|
||||||
|
args
|
||||||
|
);
|
||||||
|
// Since the previous call is async, the `this.preview` may become empty.
|
||||||
|
if (this.preview) {
|
||||||
|
this.preview.title = title;
|
||||||
|
this.preview.tooltip = title;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// nsITaskbarPreviewController
|
// nsITaskbarPreviewController
|
||||||
|
|
Загрузка…
Ссылка в новой задаче