Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1902)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java

Issue 1129193007: aw: Ensure synchronization of PopupWindow handle visibility/position (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Slightly simpler visibility fix Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java b/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java
index 720534c628e6c35b71cb89f5870c755ce41a07f1..2b86bd81598296132c69f93952f12e75947f86c7 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java
@@ -68,6 +68,13 @@ public class PopupTouchHandleDrawable extends View {
private boolean mVisible;
private boolean mTemporarilyHidden;
+ // There are no guarantees that the side effects of setting the position of
+ // the PopupWindow and the visibility of its content View will be realized
+ // in the same frame. Thus, to ensure the PopupWindow is seen in the right
+ // location, when the PopupWindow reappears we delay the visibility update
+ // by one frame after setting the position.
+ private boolean mDelayVisibilityUpdateWAR;
+
// Deferred runnable to avoid invalidating outside of frame dispatch,
// in turn avoiding issues with sync barrier insertion.
private Runnable mInvalidationRunnable;
@@ -205,8 +212,20 @@ public class PopupTouchHandleDrawable extends View {
}
private void updateVisibility() {
- boolean visible = mVisible && !mTemporarilyHidden;
- setVisibility(visible ? VISIBLE : INVISIBLE);
+ int newVisibility = mVisible && !mTemporarilyHidden ? VISIBLE : INVISIBLE;
+
+ // When regaining visibility, delay the visibility update by one frame
+ // to ensure the PopupWindow has first been positioned properly.
+ if (newVisibility == VISIBLE && getVisibility() != VISIBLE) {
+ if (!mDelayVisibilityUpdateWAR) {
+ mDelayVisibilityUpdateWAR = true;
+ scheduleInvalidate();
+ return;
+ }
+ }
+ mDelayVisibilityUpdateWAR = false;
+
+ setVisibility(newVisibility);
}
private void updateAlpha() {
@@ -225,8 +244,8 @@ public class PopupTouchHandleDrawable extends View {
private void doInvalidate() {
if (!mContainer.isShowing()) return;
- updatePosition();
updateVisibility();
+ updatePosition();
invalidate();
}

Powered by Google App Engine
This is Rietveld 408576698