Bug 938153 - Selectively display the globe favicon placeholder when favicon fetches take long enough to be noticeable. r=mfinkle
authorRichard Newman <rnewman@mozilla.com>
Wed, 18 Dec 2013 11:37:41 -0800
changeset 161162 7ef525f0c865ce6a0fe0d417681ae4e6bdff5467
parent 161161 90699ba761fb5291698f2b5664dc7bf042d8e53c
child 161163 cb31b40dd8f3c2f2ab2f8bafdf0d7cc84717fed1
push id4076
push userrnewman@mozilla.com
push dateThu, 19 Dec 2013 03:35:50 +0000
treeherderfx-team@cb31b40dd8f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs938153
milestone29.0a1
Bug 938153 - Selectively display the globe favicon placeholder when favicon fetches take long enough to be noticeable. r=mfinkle
mobile/android/base/BrowserApp.java
mobile/android/base/toolbar/BrowserToolbar.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1403,17 +1403,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
@@ -957,16 +957,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.");