зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1602808 - Revert Window Title to use DTD. r=fluent-reviewers,Gijs
Differential Revision: https://phabricator.services.mozilla.com/D68661 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e20bf355f2
Коммит
329298b6fc
|
@ -8369,6 +8369,13 @@ var gPrivateBrowsingUI = {
|
|||
|
||||
// Adjust the window's title
|
||||
let docElement = document.documentElement;
|
||||
if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
||||
docElement.title = docElement.getAttribute("title_privatebrowsing");
|
||||
docElement.setAttribute(
|
||||
"titlemodifier",
|
||||
docElement.getAttribute("titlemodifier_privatebrowsing")
|
||||
);
|
||||
}
|
||||
docElement.setAttribute(
|
||||
"privatebrowsingmode",
|
||||
PrivateBrowsingUtils.permanentPrivateBrowsing ? "permanent" : "temporary"
|
||||
|
|
|
@ -40,12 +40,26 @@
|
|||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
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
|
||||
chromemargin="0,2,2,2"
|
||||
#else
|
||||
chromemargin="0,-1,-1,-1"
|
||||
#endif
|
||||
tabsintitlebar="true"
|
||||
titlemenuseparator="&mainWindow.titlemodifiermenuseparator;"
|
||||
windowtype="navigator:browser"
|
||||
macanimationtype="document"
|
||||
screenX="4" screenY="4"
|
||||
|
@ -69,9 +83,7 @@
|
|||
<link rel="localization" href="preview/interventions.ftl"/>
|
||||
<link rel="localization" href="browser/sidebarMenu.ftl"/>
|
||||
|
||||
<title
|
||||
data-l10n-id="browser-main-window-title"
|
||||
data-l10n-args='{"mode": "default"}'></title>
|
||||
<title>&mainWindow.title;</title>
|
||||
|
||||
# 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
|
||||
|
|
|
@ -208,13 +208,6 @@
|
|||
*/
|
||||
_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,
|
||||
|
||||
/**
|
||||
|
@ -920,9 +913,32 @@
|
|||
},
|
||||
|
||||
getWindowTitleForBrowser(aBrowser) {
|
||||
let title = "";
|
||||
var newTitle = "";
|
||||
var docElement = document.documentElement;
|
||||
var sep = docElement.getAttribute("titlemenuseparator");
|
||||
let tab = this.getTabForBrowser(aBrowser);
|
||||
let docTitle;
|
||||
|
||||
let docElement = document.documentElement;
|
||||
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.
|
||||
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,
|
||||
// add the scheme and host to the title to prevent spoofing.
|
||||
|
@ -930,69 +946,30 @@
|
|||
try {
|
||||
if (docElement.getAttribute("chromehidden").includes("location")) {
|
||||
const uri = Services.io.createExposableURI(aBrowser.currentURI);
|
||||
let prefix = uri.prePath;
|
||||
if (uri.scheme == "about") {
|
||||
prefix = uri.spec;
|
||||
} else if (uri.scheme == "moz-extension") {
|
||||
if (uri.scheme === "about") {
|
||||
newTitle = `${uri.spec}${sep}${newTitle}`;
|
||||
} else if (uri.scheme === "moz-extension") {
|
||||
const ext = WebExtensionPolicy.getByHostname(uri.host);
|
||||
if (ext && ext.name) {
|
||||
let extensionLabel = document.getElementById(
|
||||
"urlbar-label-extension"
|
||||
);
|
||||
prefix = `${extensionLabel.value} (${ext.name})`;
|
||||
const prefix = document.querySelector("#urlbar-label-extension")
|
||||
.value;
|
||||
newTitle = `${prefix} (${ext.name})${sep}${newTitle}`;
|
||||
} else {
|
||||
newTitle = `${uri.prePath}${sep}${newTitle}`;
|
||||
}
|
||||
} else {
|
||||
newTitle = `${uri.prePath}${sep}${newTitle}`;
|
||||
}
|
||||
title = prefix + " - ";
|
||||
}
|
||||
} catch (e) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
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,
|
||||
},
|
||||
};
|
||||
return newTitle;
|
||||
},
|
||||
|
||||
async updateTitlebar() {
|
||||
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]);
|
||||
updateTitlebar() {
|
||||
document.title = this.getWindowTitleForBrowser(this.selectedBrowser);
|
||||
},
|
||||
|
||||
updateCurrentBrowser(aForceUpdate) {
|
||||
|
|
|
@ -1004,14 +1004,10 @@ class Window extends WindowBase {
|
|||
}
|
||||
|
||||
setTitlePreface(titlePreface) {
|
||||
if (!titlePreface) {
|
||||
this.window.document.documentElement.removeAttribute("titlepreface");
|
||||
} else {
|
||||
this.window.document.documentElement.setAttribute(
|
||||
"titlepreface",
|
||||
titlePreface
|
||||
);
|
||||
}
|
||||
this.window.document.documentElement.setAttribute(
|
||||
"titlepreface",
|
||||
titlePreface
|
||||
);
|
||||
}
|
||||
|
||||
get focused() {
|
||||
|
|
|
@ -378,7 +378,7 @@ this.windows = class extends ExtensionAPI {
|
|||
});
|
||||
},
|
||||
|
||||
update: async function(windowId, updateInfo) {
|
||||
update: function(windowId, updateInfo) {
|
||||
if (updateInfo.state !== null && updateInfo.state != "normal") {
|
||||
if (
|
||||
updateInfo.left !== null ||
|
||||
|
@ -415,12 +415,12 @@ this.windows = class extends ExtensionAPI {
|
|||
|
||||
if (updateInfo.titlePreface !== null) {
|
||||
win.setTitlePreface(updateInfo.titlePreface);
|
||||
await win.window.gBrowser.updateTitlebar();
|
||||
win.window.gBrowser.updateTitlebar();
|
||||
}
|
||||
|
||||
// TODO: All the other properties, focused=false...
|
||||
|
||||
return win.convert();
|
||||
return Promise.resolve(win.convert());
|
||||
},
|
||||
|
||||
remove: function(windowId) {
|
||||
|
|
|
@ -3,48 +3,6 @@
|
|||
# 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 =
|
||||
.aria-label = View site information
|
||||
|
||||
|
|
|
@ -5,6 +5,16 @@
|
|||
<!-- LOCALIZATION NOTE : FILE This file contains the browser main menu items -->
|
||||
<!-- 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 navbarOverflow.label "More tools…">
|
||||
|
||||
|
|
|
@ -247,19 +247,12 @@ PreviewController.prototype = {
|
|||
// don't discard the cache of previews.
|
||||
},
|
||||
|
||||
async updateTitleAndTooltip() {
|
||||
let { id, args } = this.win.tabbrowser.getWindowTitleForBrowser(
|
||||
updateTitleAndTooltip() {
|
||||
let title = this.win.tabbrowser.getWindowTitleForBrowser(
|
||||
this.linkedBrowser
|
||||
);
|
||||
let title = await this.win.tabbrowser.ownerDocument.l10n.formatValue(
|
||||
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;
|
||||
}
|
||||
this.preview.title = title;
|
||||
this.preview.tooltip = title;
|
||||
},
|
||||
|
||||
// nsITaskbarPreviewController
|
||||
|
|
Загрузка…
Ссылка в новой задаче