Bug 1341275 - review: Add comment explaining FaviconView.getWidth non-zero values. r=trivial draft
authorMichael Comella <michael.l.comella@gmail.com>
Mon, 17 Jul 2017 11:37:45 -0700
changeset 609897 67c86ec7135f293de3ca742674ddcdb60987a4f5
parent 609851 2511fde68599e5a1ae2096ee186704e064426754
child 637718 e1ad15baa61d581885ce4251d5d9a0a36ccacfa3
push id68734
push usermichael.l.comella@gmail.com
push dateMon, 17 Jul 2017 18:39:58 +0000
reviewerstrivial
bugs1341275
milestone56.0a1
Bug 1341275 - review: Add comment explaining FaviconView.getWidth non-zero values. r=trivial MozReview-Commit-ID: 33RXaB4gCkK
mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
--- a/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
@@ -143,16 +143,20 @@ public class FaviconView extends ImageVi
 
     /**
      * Formats the image for display, if the prerequisite data are available. Upscales tiny Favicons to
      * normal sized ones, replaces null bitmaps with the default Favicon, and fills all remaining space
      * in this view with the coloured background.
      */
     private void formatImage() {
         // Both onSizeChanged and updateImage have to be called before an image can be shown.
+        //
+        // Note: getWidth/Height get their non-zero values during layout, at which point onSizeChanged will be called.
+        // Since we block for onSizeChanged (getWidth/Height != 0) and we only call getWidth/Height from this method
+        // and the ones it calls, we should have no problems with zero values for `getWidth/Height`.
         final boolean canImageBeShown = (mIconBitmap != null && getWidth() != 0 && getHeight() != 0);
         if (!canImageBeShown) {
             showNoImage();
             return;
         }
 
         mShouldShowImage = true;