Bug 1409784 - Remove mStringBundle from tabbrowser binding and expose gTabBrowserBundle instead;r=dao
MozReview-Commit-ID: 2P0OIuQwQv1
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -134,16 +134,19 @@ if (AppConstants.MOZ_CRASHREPORTER) {
XPCOMUtils.defineLazyServiceGetter(this, "gCrashReporter",
"@mozilla.org/xre/app-info;1",
"nsICrashReporter");
}
XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", function() {
return Services.strings.createBundle("chrome://browser/locale/browser.properties");
});
+XPCOMUtils.defineLazyGetter(this, "gTabBrowserBundle", function() {
+ return Services.strings.createBundle("chrome://browser/locale/tabbrowser.properties");
+});
XPCOMUtils.defineLazyGetter(this, "gCustomizeMode", function() {
let scope = {};
Cu.import("resource:///modules/CustomizeMode.jsm", scope);
return new scope.CustomizeMode(window);
});
XPCOMUtils.defineLazyGetter(this, "gPrefService", function() {
@@ -8948,18 +8951,18 @@ TabModalPromptBox.prototype = {
try {
hostForAllowFocusCheckbox = principalToAllowFocusFor.URI.host;
} catch (ex) { /* Ignore exceptions for host-less URIs */ }
if (hostForAllowFocusCheckbox) {
let allowFocusRow = document.createElementNS(XUL_NS, "row");
allowFocusCheckbox = document.createElementNS(XUL_NS, "checkbox");
let spacer = document.createElementNS(XUL_NS, "spacer");
allowFocusRow.appendChild(spacer);
- let label = gBrowser.mStringBundle.getFormattedString("tabs.allowTabFocusByPromptForSite",
- [hostForAllowFocusCheckbox]);
+ let label = gTabBrowserBundle.formatStringFromName("tabs.allowTabFocusByPromptForSite",
+ [hostForAllowFocusCheckbox], 1);
allowFocusCheckbox.setAttribute("label", label);
allowFocusRow.appendChild(allowFocusCheckbox);
newPrompt.appendChild(allowFocusRow);
}
let tab = gBrowser.getTabForBrowser(browser);
let closeCB = this._promptCloseCallback.bind(null, onCloseCallback, principalToAllowFocusFor,
allowFocusCheckbox);
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -12,17 +12,16 @@
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="tabbrowser">
<resources>
<stylesheet src="chrome://browser/content/tabbrowser.css"/>
</resources>
<content>
- <xul:stringbundle anonid="tbstringbundle" src="chrome://browser/locale/tabbrowser.properties"/>
<xul:tabbox anonid="tabbox" class="tabbrowser-tabbox"
flex="1" eventnode="document" xbl:inherits="handleCtrlPageUpDown,tabcontainer"
onselect="if (event.target.localName == 'tabpanels') this.parentNode.updateCurrentBrowser();">
<xul:tabpanels flex="1" class="plain" selectedIndex="0" anonid="panelcontainer">
<xul:notificationbox flex="1" notificationside="top">
<xul:hbox flex="1" class="browserSidebarContainer">
<xul:vbox flex="1" class="browserContainer">
<xul:stack flex="1" class="browserStack" anonid="browserStack">
@@ -71,19 +70,16 @@
.getService(Components.interfaces.mozIPlacesAutoComplete);
</field>
<field name="mTabBox" readonly="true">
document.getAnonymousElementByAttribute(this, "anonid", "tabbox");
</field>
<field name="mPanelContainer" readonly="true">
document.getAnonymousElementByAttribute(this, "anonid", "panelcontainer");
</field>
- <field name="mStringBundle">
- document.getAnonymousElementByAttribute(this, "anonid", "tbstringbundle");
- </field>
<field name="mCurrentTab">
null
</field>
<field name="_lastRelatedTabMap">
new WeakMap();
</field>
<field name="mCurrentBrowser">
null
@@ -1627,17 +1623,17 @@
try {
var characterSet = browser.characterSet;
const textToSubURI = Components.classes["@mozilla.org/intl/texttosuburi;1"]
.getService(Components.interfaces.nsITextToSubURI);
title = textToSubURI.unEscapeNonAsciiURI(characterSet, title);
} catch (ex) { /* Do nothing. */ }
} else {
// Still no title? Fall back to our untitled string.
- title = this.mStringBundle.getString("tabs.emptyTabTitle");
+ title = gTabBrowserBundle.GetStringFromName("tabs.emptyTabTitle");
}
}
return this._setTabLabel(aTab, title, { isContentTitle });
]]>
</body>
</method>
@@ -2640,17 +2636,17 @@
lazyBrowserURI = aURIObject;
aURI = "about:blank";
}
var uriIsAboutBlank = aURI == "about:blank";
if (!aNoInitialLabel) {
if (isBlankPageURL(aURI)) {
- t.setAttribute("label", this.mStringBundle.getString("tabs.emptyTabTitle"));
+ t.setAttribute("label", gTabBrowserBundle.GetStringFromName("tabs.emptyTabTitle"));
} else {
// Set URL as label so that the tab isn't empty initially.
this.setInitialTabTitle(t, aURI, { beforeTabOpen: true });
}
}
if (aIsPrerendered) {
t.setAttribute("hidden", "true");
@@ -2908,37 +2904,36 @@
var shouldPrompt = Services.prefs.getBoolPref(pref);
if (!shouldPrompt)
return true;
var ps = Services.prompt;
// default to true: if it were false, we wouldn't get this far
var warnOnClose = { value: true };
- var bundle = this.mStringBundle;
// focus the window before prompting.
// this will raise any minimized window, which will
// make it obvious which window the prompt is for and will
// solve the problem of windows "obscuring" the prompt.
// see bug #350299 for more details
window.focus();
var warningMessage =
- PluralForm.get(tabsToClose, bundle.getString("tabs.closeWarningMultiple"))
+ PluralForm.get(tabsToClose, gTabBrowserBundle.GetStringFromName("tabs.closeWarningMultiple"))
.replace("#1", tabsToClose);
var buttonPressed =
ps.confirmEx(window,
- bundle.getString("tabs.closeWarningTitle"),
+ gTabBrowserBundle.GetStringFromName("tabs.closeWarningTitle"),
warningMessage,
(ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_0)
+ (ps.BUTTON_TITLE_CANCEL * ps.BUTTON_POS_1),
- bundle.getString("tabs.closeButtonMultiple"),
+ gTabBrowserBundle.GetStringFromName("tabs.closeButtonMultiple"),
null, null,
aCloseTabs == this.closingTabsEnum.ALL ?
- bundle.getString("tabs.closeWarningPromptMe") : null,
+ gTabBrowserBundle.GetStringFromName("tabs.closeWarningPromptMe") : null,
warnOnClose);
var reallyClose = (buttonPressed == 0);
// don't set the pref unless they press OK and it's false
if (aCloseTabs == this.closingTabsEnum.ALL && reallyClose && !warnOnClose.value)
Services.prefs.setBoolPref(pref, false);
return reallyClose;
@@ -5511,55 +5506,55 @@
if (tab.localName != "tab") {
event.preventDefault();
return;
}
let stringWithShortcut = (stringId, keyElemId) => {
let keyElem = document.getElementById(keyElemId);
let shortcut = ShortcutUtils.prettifyShortcut(keyElem);
- return this.mStringBundle.getFormattedString(stringId, [shortcut]);
+ return gTabBrowserBundle.formatStringFromName(stringId, [shortcut], 1);
};
var label;
if (tab.mOverCloseButton) {
label = tab.selected ?
stringWithShortcut("tabs.closeSelectedTab.tooltip", "key_close") :
- this.mStringBundle.getString("tabs.closeTab.tooltip");
+ gTabBrowserBundle.GetStringFromName("tabs.closeTab.tooltip");
} else if (tab._overPlayingIcon) {
let stringID;
if (tab.selected) {
stringID = tab.linkedBrowser.audioMuted ?
"tabs.unmuteAudio.tooltip" :
"tabs.muteAudio.tooltip";
label = stringWithShortcut(stringID, "key_toggleMute");
} else {
if (tab.hasAttribute("activemedia-blocked")) {
stringID = "tabs.unblockAudio.tooltip";
} else {
stringID = tab.linkedBrowser.audioMuted ?
"tabs.unmuteAudio.background.tooltip" :
"tabs.muteAudio.background.tooltip";
}
- label = this.mStringBundle.getString(stringID);
+ label = gTabBrowserBundle.GetStringFromName(stringID);
}
} else {
label = tab._fullLabel || tab.getAttribute("label");
if (AppConstants.E10S_TESTING_ONLY &&
tab.linkedBrowser &&
tab.linkedBrowser.isRemoteBrowser) {
label += " - e10s";
if (tab.linkedBrowser.frameLoader &&
Services.appinfo.maxWebProcessCount > 1) {
label += " (" + tab.linkedBrowser.frameLoader.tabParent.osPid + ")";
}
}
if (tab.userContextId) {
- label = this.mStringBundle.getFormattedString("tabs.containers.tooltip", [label, ContextualIdentityService.getUserContextLabel(tab.userContextId)]);
+ label = gTabBrowserBundle.formatStringFromName("tabs.containers.tooltip", [label, ContextualIdentityService.getUserContextLabel(tab.userContextId)], 2);
}
}
event.target.setAttribute("label", label);
]]></body>
</method>
<method name="handleEvent">
@@ -6367,20 +6362,20 @@
</content>
<implementation implements="nsIDOMEventListener, nsIObserver">
<constructor>
<![CDATA[
this.mTabClipWidth = Services.prefs.getIntPref("browser.tabs.tabClipWidth");
let { restoreTabsButton } = this;
- restoreTabsButton.setAttribute("label", this.tabbrowser.mStringBundle.getString("tabs.restoreLastTabs"));
+ restoreTabsButton.setAttribute("label", gTabBrowserBundle.GetStringFromName("tabs.restoreLastTabs"));
var tab = this.firstChild;
- tab.label = this.tabbrowser.mStringBundle.getString("tabs.emptyTabTitle");
+ tab.label = gTabBrowserBundle.GetStringFromName("tabs.emptyTabTitle");
tab.setAttribute("onerror", "this.removeAttribute('image');");
window.addEventListener("resize", this);
window.addEventListener("load", this);
Services.prefs.addObserver("privacy.userContext", this);
this.observe(null, "nsPref:changed", "privacy.userContext.enabled");
@@ -6611,17 +6606,17 @@
</property>
<method name="_propagateVisibility">
<body><![CDATA[
let visible = this.visible;
document.getElementById("menu_closeWindow").hidden = !visible;
document.getElementById("menu_close").setAttribute("label",
- this.tabbrowser.mStringBundle.getString(visible ? "tabs.closeTab" : "tabs.close"));
+ gTabBrowserBundle.GetStringFromName(visible ? "tabs.closeTab" : "tabs.close"));
TabsInTitlebar.allowedBy("tabs-visible", visible);
]]></body>
</method>
<method name="updateVisibility">
<body><![CDATA[
if (this.childNodes.length - this.tabbrowser._removingTabs.length == 1)