Bug 938153 - Selectively display the globe favicon placeholder when favicon fetches take long enough to be noticeable. r=mfinkle, a=bajaj
authorRichard Newman <rnewman@mozilla.com>
Wed, 18 Dec 2013 11:37:41 -0800
changeset 175739 54b3b3fa8bbe27c31d9a453d57b572e5fc0e9f52
parent 175738 a7735f4df76628b2a1c846fab9ea78df6af1a6ba
child 175740 f660b6d2ea1aeb5c793f390e7d2e9b15850963d0
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, bajaj
bugs938153
milestone28.0a2
Bug 938153 - Selectively display the globe favicon placeholder when favicon fetches take long enough to be noticeable. r=mfinkle, a=bajaj
mobile/android/base/BrowserApp.java
mobile/android/base/toolbar/BrowserToolbar.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1425,17 +1425,25 @@ abstract public class BrowserApp extends
 
     private void loadFavicon(final Tab tab) {
         maybeCancelFaviconLoad(tab);
 
         final int tabFaviconSize = getResources().getDimensionPixelSize(R.dimen.browser_toolbar_favicon_size);
 
         int flags = (tab.isPrivate() || tab.getErrorType() != Tab.ErrorType.NONE) ? 0 : LoadFaviconTask.FLAG_PERSIST;
         int id = Favicons.getFaviconForSize(tab.getURL(), tab.getFaviconURL(), tabFaviconSize, flags, sFaviconLoadedListener);
+
         tab.setFaviconLoadId(id);
+        if (id != Favicons.LOADED &&
+            Tabs.getInstance().isSelectedTab(tab)) {
+            // We're loading the current tab's favicon from somewhere
+            // other than the cache.
+            // Display the globe favicon until then.
+            mBrowserToolbar.showDefaultFavicon();
+        }
     }
 
     private void maybeCancelFaviconLoad(Tab tab) {
         int faviconLoadId = tab.getFaviconLoadId();
 
         if (Favicons.NOT_LOADING == faviconLoadId) {
             return;
         }
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -929,16 +929,21 @@ public class BrowserToolbar extends Geck
                 builder.setSpan(tab.isPrivate() ? mPrivateDomainColor : mDomainColor, index, index+baseDomain.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
                 title = builder;
             }
         }
 
         setTitle(title);
     }
 
+    public void showDefaultFavicon() {
+        mFavicon.setImageResource(R.drawable.favicon);
+        mLastFavicon = null;
+    }
+
     private void setFavicon(Bitmap image) {
         Log.d(LOGTAG, "setFavicon(" + image + ")");
         if (Tabs.getInstance().getSelectedTab().getState() == Tab.STATE_LOADING) {
             return;
         }
 
         if (image == mLastFavicon) {
             Log.d(LOGTAG, "Ignoring favicon set: new favicon is identical to previous favicon.");