Bug 1179479 - Invalidate Themed* after refreshing drawable state. r=mhaigh
authorMichael Comella <michael.l.comella@gmail.com>
Wed, 05 Aug 2015 14:17:49 -0700
changeset 257118 ecb79b9ae0f9a4e1b8605bca88a313760a9b89f5
parent 257117 b163bf0c487ff9f219b1bf9256bcc13dda7c85e9
child 257119 52f19dfa18a5c79599b417291a843095ce8fc225
push id14573
push usermichael.l.comella@gmail.com
push dateMon, 10 Aug 2015 22:14:07 +0000
treeherderfx-team@4b9d1ec3213d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh
bugs1179479
milestone43.0a1
Bug 1179479 - Invalidate Themed* after refreshing drawable state. r=mhaigh afaict, refreshDrawableState only sets the appropriate back-end bits to change the state but does not request a redraw. For example, refreshDrawableState eventually calls Drawable.setState, whose docs specify: If the new state you are supplying causes the appearance of the Drawable to change, then it is responsible for calling invalidateSelf in order to have itself redrawn, and true will be returned from this function. Notably, there are no other calls to invalidate in the call hierarchy so I added one. The reason this (sometimes) worked before is because the views would be invalidated in some other way, e.g. setDrawable would be called. Without this patch, the next patch would update the reload menu icon on press (i.e. another invalidate call) but not when the tab was switched from non-private to private.
mobile/android/base/widget/ThemedEditText.java
mobile/android/base/widget/ThemedImageButton.java
mobile/android/base/widget/ThemedImageView.java
mobile/android/base/widget/ThemedLinearLayout.java
mobile/android/base/widget/ThemedRelativeLayout.java
mobile/android/base/widget/ThemedTextSwitcher.java
mobile/android/base/widget/ThemedTextView.java
mobile/android/base/widget/ThemedView.java
mobile/android/base/widget/ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedEditText.java
+++ b/mobile/android/base/widget/ThemedEditText.java
@@ -106,40 +106,43 @@ public class ThemedEditText extends andr
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedImageButton.java
+++ b/mobile/android/base/widget/ThemedImageButton.java
@@ -106,40 +106,43 @@ public class ThemedImageButton extends a
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedImageView.java
+++ b/mobile/android/base/widget/ThemedImageView.java
@@ -106,40 +106,43 @@ public class ThemedImageView extends and
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedLinearLayout.java
+++ b/mobile/android/base/widget/ThemedLinearLayout.java
@@ -101,40 +101,43 @@ public class ThemedLinearLayout extends 
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedRelativeLayout.java
+++ b/mobile/android/base/widget/ThemedRelativeLayout.java
@@ -106,40 +106,43 @@ public class ThemedRelativeLayout extend
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedTextSwitcher.java
+++ b/mobile/android/base/widget/ThemedTextSwitcher.java
@@ -101,40 +101,43 @@ public class ThemedTextSwitcher extends 
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedTextView.java
+++ b/mobile/android/base/widget/ThemedTextView.java
@@ -106,40 +106,43 @@ public class ThemedTextView extends andr
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedView.java
+++ b/mobile/android/base/widget/ThemedView.java
@@ -106,40 +106,43 @@ public class ThemedView extends android.
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedView.java.frag
+++ b/mobile/android/base/widget/ThemedView.java.frag
@@ -109,40 +109,43 @@ public class Themed@VIEW_NAME_SUFFIX@ ex
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }