Bug 456084, display url in address field when the title is blank
authorNeil Deakin <neil@mozilla.com>
Sat, 27 Sep 2008 10:07:04 -0400
changeset 64932 d28134684fce8643c05ea640f30a5948ecab282f
parent 64931 b91612ed74484ee2cdd63176151ddd7b0bd611aa
child 64933 8436d7c0f80862feee628c3b18c4217e18949fde
push idunknown
push userunknown
push dateunknown
bugs456084
Bug 456084, display url in address field when the title is blank
mobile/chrome/content/browser-ui.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -95,17 +95,23 @@ var BrowserUI = {
     return parseInt(gContentBox.style.marginTop);
   },
 
   _titleChanged : function(aDocument) {
     var browser = Browser.currentBrowser;
     if (browser && aDocument != browser.contentDocument)
       return;
 
-    this._caption.value = aDocument.title;
+    var caption = aDocument.title;
+    if (!caption) {
+      caption = this.getDisplayURI(browser);
+      if (caption == "about:blank")
+        caption = "";
+    }
+    this._caption.value = caption;
 
     var docElem = document.documentElement;
     var title = "";
     if (aDocument.title)
       title = aDocument.title + docElem.getAttribute("titleseparator");
     document.title = title + docElem.getAttribute("titlemodifier");
   },
 
@@ -515,16 +521,29 @@ var BrowserUI = {
       this._throbber.removeAttribute("loading");
       if (this._faviconAdded == false) {
         var faviconURI = aBrowser.currentURI.prePath + "/favicon.ico";
         this._setIcon(faviconURI);
       }
     }
   },
 
+  getDisplayURI : function(browser) {
+    var uri = browser.currentURI;
+
+    if (!this._URIFixup)
+      this._URIFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
+
+    try {
+      uri = this._URIFixup.createExposableURI(uri);
+    } catch (ex) {}
+
+    return uri.spec;
+  },
+
   /* Set the location to the current content */
   setURI : function() {
     var browser = Browser.currentBrowser;
 
     // FIXME: deckbrowser should not fire TebSelect on the initial tab (bug 454028)
     if (!browser.currentURI)
       return;
 
@@ -538,26 +557,17 @@ var BrowserUI = {
     var star = document.getElementById("tool-star");
     if (PlacesUtils.getMostRecentBookmarkForURI(browser.currentURI) != -1) {
       star.setAttribute("starred", "true");
     }
     else {
       star.removeAttribute("starred");
     }
 
-    var uri = browser.currentURI;
-
-    if (!this._URIFixup)
-      this._URIFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
-
-    try {
-      uri = this._URIFixup.createExposableURI(uri);
-    } catch (ex) {}
-
-    var urlString = uri.spec;
+    var urlString = this.getDisplayURI(browser);
     if (urlString == "about:blank") {
       urlString = "";
       this.show(UIMODE_URLEDIT);
     }
 
     this._caption.value = urlString;
     this._edit.value = urlString;
   },