Bug 883390 - Part 1.4 - Update urlbar more intelligently, use tasks in doOpenSearch like we do in goToURI. r=sfoster

--HG--
extra : rebase_source : 18cd879a7ca42ed197de49759574ea66cfb27e5d
This commit is contained in:
Jonathan Wilde 2013-07-15 11:27:28 -07:00
parent 36a547693c
commit 4308a5abec
3 changed files with 31 additions and 36 deletions

View File

@ -84,8 +84,10 @@ const WebProgress = {
let spec = aJson.location;
let location = spec.split("#")[0]; // Ignore fragment identifier changes.
if (aTab == Browser.selectedTab)
if (aTab == Browser.selectedTab) {
BrowserUI.updateURI();
BrowserUI.update();
}
let locationHasChanged = (location != aTab.browser.lastLocation);
if (locationHasChanged) {
@ -123,22 +125,15 @@ const WebProgress = {
_networkStart: function _networkStart(aJson, aTab) {
aTab.startLoading();
if (aTab == Browser.selectedTab) {
if (aTab == Browser.selectedTab)
BrowserUI.update(TOOLBARSTATE_LOADING);
// We should at least show something in the URLBar until
// the load has progressed further along
if (aTab.browser.currentURI.spec == "about:blank")
BrowserUI.updateURI({ captionOnly: true });
}
},
_networkStop: function _networkStop(aJson, aTab) {
aTab.endLoading();
if (aTab == Browser.selectedTab) {
if (aTab == Browser.selectedTab)
BrowserUI.update(TOOLBARSTATE_LOADED);
}
},
_windowStart: function _windowStart(aJson, aTab) {
@ -162,7 +157,7 @@ const WebProgress = {
// 'Whoosh' in
this._progressCount = kProgressMarginStart;
Elements.progress.style.width = this._progressCount + "%";
Elements.progress.style.width = this._progressCount + "%";
Elements.progress.removeAttribute("fade");
// Create a pulse timer to keep things moving even if we don't
@ -204,7 +199,7 @@ const WebProgress = {
_progressStop: function _progressStop(aJson, aTab) {
this._progressActive = false;
// 'Whoosh out' and fade
Elements.progress.style.width = "100%";
Elements.progress.style.width = "100%";
Elements.progress.setAttribute("fade", true);
},
@ -213,7 +208,7 @@ const WebProgress = {
return;
// Close out fade finished, reset
if (data.propertyName == "opacity") {
Elements.progress.style.width = "0px";
Elements.progress.style.width = "0px";
Elements.progressContainer.setAttribute("collapsed", true);
}
},

View File

@ -294,10 +294,22 @@ var BrowserUI = {
* Navigation
*/
/* Updates the overall state of the toolbar, but not the URL bar. */
update: function(aState) {
let uri = this.getDisplayURI(Browser.selectedBrowser);
StartUI.update(uri);
this._updateButtons();
this._updateToolbar();
},
/* Updates the URL bar. */
updateURI: function(aOptions) {
let uri = this.getDisplayURI(Browser.selectedBrowser);
let cleanURI = Util.isURLEmpty(uri) ? "" : uri;
this._edit.value = cleanURI;
},
getDisplayURI: function(browser) {
let uri = browser.currentURI;
let spec = uri.spec;
@ -316,23 +328,6 @@ var BrowserUI = {
return spec;
},
/* Set the location to the current content */
updateURI: function(aOptions) {
aOptions = aOptions || {};
let uri = this.getDisplayURI(Browser.selectedBrowser);
let cleanURI = Util.isURLEmpty(uri) ? "" : uri;
this._edit.value = cleanURI;
if ("captionOnly" in aOptions && aOptions.captionOnly)
return;
StartUI.update(uri);
this._updateButtons();
this._updateToolbar();
},
goToURI: function(aURI) {
aURI = aURI || this._edit.value;
if (!aURI)
@ -344,7 +339,7 @@ var BrowserUI = {
Util.forceOnline();
BrowserUI.showContent(aURI);
content.focus();
Browser.selectedBrowser.focus();
Task.spawn(function() {
let postData = {};
@ -371,13 +366,17 @@ var BrowserUI = {
// Make sure we're online before attempting to load
Util.forceOnline();
BrowserUI.showContent();
Browser.selectedBrowser.focus();
Browser.loadURI(submission.uri.spec, { postData: submission.postData });
Task.spawn(function () {
Browser.loadURI(submission.uri.spec, { postData: submission.postData });
// loadURI may open a new tab, so get the selectedBrowser afterward.
Browser.selectedBrowser.userTypedValue = submission.uri.spec;
this._titleChanged(Browser.selectedBrowser);
// loadURI may open a new tab, so get the selectedBrowser afterward.
Browser.selectedBrowser.userTypedValue = submission.uri.spec;
BrowserUI._titleChanged(Browser.selectedBrowser);
});
},
/*********************************

View File

@ -574,6 +574,7 @@ var Browser = {
} else {
// Update all of our UI to reflect the new tab's location
BrowserUI.updateURI();
BrowserUI.update();
let event = document.createEvent("Events");
event.initEvent("TabSelect", true, false);
@ -1578,7 +1579,7 @@ Tab.prototype = {
// Ensure that history is initialized
history.QueryInterface(Ci.nsISHistoryInternal);
for (let i = 0, length = otherHistory.index; i <= length; i++)
history.addEntry(otherHistory.getEntryAtIndex(i, false), true);
},