Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/CompositorViewHolder.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/CompositorViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/CompositorViewHolder.java |
index 49d94a65db23ae1f957b81169c0e7a1cd290ba69..a5a08e38a5f3a91c9be7c5906a611df50550566c 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/CompositorViewHolder.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/CompositorViewHolder.java |
@@ -112,7 +112,7 @@ public class CompositorViewHolder extends CoordinatorLayout |
private Tab mTabVisible; |
/** The currently attached View. */ |
- private View mView; |
+ private TabContentViewParent mView; |
private TabObserver mTabObserver; |
private boolean mEnableCompositorTabStrip; |
@@ -789,10 +789,10 @@ public class CompositorViewHolder extends CoordinatorLayout |
} |
if (show) { |
if (mView.getParent() != this) { |
- // Make sure the view isn't a child of something else before we attempt to add it. |
- if (mView.getParent() instanceof ViewGroup) { |
- ((ViewGroup) mView.getParent()).removeView(mView); |
- } |
+ // During tab creation, we temporarily add the new tab's view to a FrameLayout to |
+ // measure and lay it out. This way we could show the animation in the stack view. |
+ // Therefore we should remove the view from that temporary FrameLayout here. |
+ UiUtils.removeViewFromParent(mView); |
for (int i = 0; i < sCachedCVCList.size(); i++) { |
ContentViewCore content = sCachedCVCList.get(i); |
@@ -803,19 +803,14 @@ public class CompositorViewHolder extends CoordinatorLayout |
} |
} |
- CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams( |
- LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
- if (mView.getLayoutParams() instanceof MarginLayoutParams) { |
- MarginLayoutParams existingLayoutParams = |
- (MarginLayoutParams) mView.getLayoutParams(); |
- layoutParams.leftMargin = existingLayoutParams.leftMargin; |
- layoutParams.rightMargin = existingLayoutParams.rightMargin; |
- layoutParams.topMargin = existingLayoutParams.topMargin; |
- layoutParams.bottomMargin = existingLayoutParams.bottomMargin; |
- } |
- if (mView instanceof TabContentViewParent) { |
- layoutParams.setBehavior(((TabContentViewParent) mView).getBehavior()); |
+ CoordinatorLayout.LayoutParams layoutParams; |
+ if (mView.getLayoutParams() instanceof CoordinatorLayout.LayoutParams) { |
+ layoutParams = (CoordinatorLayout.LayoutParams) mView.getLayoutParams(); |
+ } else { |
+ layoutParams = new CoordinatorLayout.LayoutParams( |
+ LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
} |
+ layoutParams.setBehavior(mView.getBehavior()); |
// CompositorView has index of 0; TabContentViewParent has index of 1; Snackbar (if |
// any) has index of 2. Setting index here explicitly to avoid TabContentViewParent |
// hiding the snackbar. |
@@ -863,7 +858,7 @@ public class CompositorViewHolder extends CoordinatorLayout |
private void setTab(Tab tab) { |
if (tab != null) tab.loadIfNeeded(); |
- View newView = tab != null ? tab.getView() : null; |
+ TabContentViewParent newView = tab != null ? tab.getView() : null; |
if (mView == newView) return; |
// TODO(dtrainor): Look into changing this only if the views differ, but still parse the |