Bug 1551232 - Removes legacy-urlbar binding and simplifies gURLBarHandler. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D36231

--HG--
extra : moz-landing-system : lando
This commit is contained in:
harry 2019-07-09 21:29:53 +00:00
Родитель 3d6d3a153b
Коммит 38c5e18846
3 изменённых файлов: 13 добавлений и 1875 удалений

Просмотреть файл

@ -529,9 +529,6 @@ toolbar:not(#TabsToolbar) > #personal-bookmarks {
min-width: 1px;
}
#urlbar[quantumbar="false"] {
-moz-binding: url(chrome://browser/content/urlbarBindings.xml#legacy-urlbar);
}
#urlbar[quantumbar="true"] {
-moz-binding: url(chrome://browser/content/urlbarBindings.xml#urlbar);

Просмотреть файл

@ -300,60 +300,30 @@ XPCOMUtils.defineLazyGetter(this, "gURLBar", () => gURLBarHandler.urlbar);
/**
* Tracks the urlbar object, allowing to reinitiate it when necessary, e.g. on
* customization or when the quantumbar pref changes.
* customization.
*/
var gURLBarHandler = {
toggleQuantumBarAttribute() {
this.textbox = document.getElementById("urlbar");
this.textbox.setAttribute("quantumbar", this.quantumbar);
},
/**
* The urlbar binding or object.
*/
get urlbar() {
if (!this._urlbar) {
if (this.quantumbar) {
this._urlbar = new UrlbarInput({ textbox: this.textbox });
if (this._lastValue) {
this._urlbar.value = this._lastValue;
delete this._lastValue;
}
} else {
this._urlbar = this.textbox;
let textbox = document.getElementById("urlbar");
this._urlbar = new UrlbarInput({ textbox });
if (this._lastValue) {
this._urlbar.value = this._lastValue;
delete this._lastValue;
}
gBrowser.tabContainer.addEventListener("TabSelect", this._urlbar);
}
return this._urlbar;
},
/**
* Forwards to gURLBar.formatValue(), if the binding has been applied already.
* This is necessary until the Quantum Bar is not the default and we allow
* to dynamically switch between it and the legacy implementation, because the
* binding is only applied before the initial xul layout.
*/
formatValue() {
if (this.quantumbar) {
this.urlbar.formatValue();
} else if (typeof this.textbox.formatValue == "function") {
this.textbox.formatValue();
}
},
/**
* Invoked when the quantumbar pref changes.
*/
handlePrefChange() {
this._updateBinding();
this._reset();
},
/**
* Invoked by CustomizationHandler when a customization starts.
*/
customizeStart() {
if (this._urlbar && this._urlbar.constructor.name == "UrlbarInput") {
if (this._urlbar) {
this._urlbar.removeCopyCutController();
}
},
@ -365,44 +335,20 @@ var gURLBarHandler = {
this._reset();
},
/**
* Rebuilds the textbox binding by detaching the element when necessary.
*/
_updateBinding() {
let quantumbarApplied = this.textbox.getAttribute("quantumbar") == "true";
if (quantumbarApplied != this.quantumbar) {
let placeholder = document.createXULElement("toolbarpaletteitem");
let parent = this.textbox.parentNode;
parent.replaceChild(placeholder, this.textbox);
this.textbox.setAttribute("quantumbar", this.quantumbar);
parent.replaceChild(this.textbox, placeholder);
}
},
/**
* Used to reset the gURLBar value.
*/
_reset() {
if (this._urlbar) {
gBrowser.tabContainer.removeEventListener("TabSelect", this._urlbar);
if (this._urlbar.constructor.name == "UrlbarInput") {
this._lastValue = this._urlbar.value;
this._urlbar.uninit();
}
this._lastValue = this._urlbar.value;
this._urlbar.uninit();
delete this._urlbar;
gURLBar = this.urlbar;
}
},
};
XPCOMUtils.defineLazyPreferenceGetter(
gURLBarHandler,
"quantumbar",
"browser.urlbar.quantumbar",
false,
gURLBarHandler.handlePrefChange.bind(gURLBarHandler)
);
XPCOMUtils.defineLazyGetter(this, "ReferrerInfo", () =>
Components.Constructor(
"@mozilla.org/referrer-info;1",
@ -1674,8 +1620,9 @@ var gBrowserInit = {
},
onBeforeInitialXULLayout() {
// Dynamically switch on-off the Quantum Bar based on prefs.
gURLBarHandler.toggleQuantumBarAttribute();
// Turn on QuantumBar. This can be removed once the quantumbar attribute is gone.
let urlbar = document.getElementById("urlbar");
urlbar.setAttribute("quantumbar", true);
// Set a sane starting width/height for all resolutions on new profiles.
if (Services.prefs.getBoolPref("privacy.resistFingerprinting")) {
@ -5838,7 +5785,7 @@ var XULBrowserWindow = {
// Make sure the "https" part of the URL is striked out or not,
// depending on the current mixed active content blocking state.
gURLBarHandler.formatValue();
gURLBar.formatValue();
try {
uri = Services.uriFixup.createExposableURI(uri);

Разница между файлами не показана из-за своего большого размера Загрузить разницу