Postpone hiding old tab during tab switch until new tab is ready
When switching tabs, postpone hiding the old tab until the
new tab is ready. Also postpone destroying a tab if it is
waiting to be hidden.
Change-Id: I0989c7b28f928829bd95ef9d0679493e25be0d83
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 4889efe..26f9152 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -1360,6 +1360,11 @@
* Destroy the tab's main WebView and subWindow if any
*/
void destroy() {
+ if (mPostponeDestroy) {
+ mShouldDestroy = true;
+ return;
+ }
+ mShouldDestroy = false;
if (mMainView != null) {
dismissSubWindow();
// save the WebView to call destroy() after detach it from the tab
@@ -1369,6 +1374,20 @@
}
}
+ private boolean mPostponeDestroy = false;
+ private boolean mShouldDestroy = false;
+
+ public void postponeDestroy() {
+ mPostponeDestroy = true;
+ }
+
+ public void performPostponedDestroy() {
+ mPostponeDestroy = false;
+ if (mShouldDestroy) {
+ destroy();
+ }
+ }
+
/**
* Remove the tab from the parent
*/