Commit 8e2434c2 authored by aruslan's avatar aruslan Committed by Commit bot

Allow adding an overlay not attached to the tab layer

Currently any overlay ContentViewCore added to the Tab is
automatically added to the Tab CC layer.

This CL introduces a new parameter to allow romaing overlays.

BUG=453121

Review URL: https://codereview.chromium.org/1026983002

Cr-Commit-Position: refs/heads/master@{#322269}
parent aa274831
...@@ -1398,24 +1398,35 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener, ...@@ -1398,24 +1398,35 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
} }
/** /**
* Adds a {@link ContentViewCore} to this {@link Tab} as an overlay object. This * Adds a {@link ContentViewCore} to this {@link Tab} as an overlay object.
* {@link ContentViewCore} will be attached to the CC layer hierarchy and have all layout events * If attachLayer is set, the {@link ContentViewCore} will be attached to CC layer hierarchy.
* propagated to it. This {@link ContentViewCore} can be removed via * This {@link ContentViewCore} will have all layout events propagated to it.
* This {@link ContentViewCore} can be removed via
* {@link #detachOverlayContentViewCore(ContentViewCore)}. * {@link #detachOverlayContentViewCore(ContentViewCore)}.
* @param content The {@link ContentViewCore} to attach. * @param content The {@link ContentViewCore} to attach.
* @param visible Whether or not to make the content visible. * @param visible Whether or not to make the content visible.
* @param attachLayer Whether or not to attach the content view to the CC layer hierarchy.
*/ */
public void attachOverlayContentViewCore(ContentViewCore content, boolean visible) { public void attachOverlayContentViewCore(
ContentViewCore content, boolean visible, boolean attachLayer) {
if (content == null) return; if (content == null) return;
assert !mOverlayContentViewCores.contains(content); assert !mOverlayContentViewCores.contains(content);
mOverlayContentViewCores.add(content); mOverlayContentViewCores.add(content);
nativeAttachOverlayContentViewCore(mNativeTabAndroid, content, visible); if (attachLayer) nativeAttachOverlayContentViewCore(mNativeTabAndroid, content, visible);
for (TabObserver observer : mObservers) { for (TabObserver observer : mObservers) {
observer.onOverlayContentViewCoreAdded(this, content); observer.onOverlayContentViewCoreAdded(this, content);
} }
} }
/**
* TODO(aruslan): remove this.
* Temporary overload to avoid 2-way commit.
*/
public void attachOverlayContentViewCore(ContentViewCore content, boolean visible) {
attachOverlayContentViewCore(content, visible, true);
}
/** /**
* Removes a {@link ContentViewCore} overlay object from this {@link Tab}. This * Removes a {@link ContentViewCore} overlay object from this {@link Tab}. This
* {@link ContentViewCore} must have previously been added via * {@link ContentViewCore} must have previously been added via
......
...@@ -612,7 +612,7 @@ public class TransitionPageHelper extends EmptyTabObserver { ...@@ -612,7 +612,7 @@ public class TransitionPageHelper extends EmptyTabObserver {
mTransitionObserver = createTransitionObserver(); mTransitionObserver = createTransitionObserver();
if (mTab != null) mTab.attachOverlayContentViewCore(mTransitionContentViewCore, true); if (mTab != null) mTab.attachOverlayContentViewCore(mTransitionContentViewCore, true, true);
nativeSetWebContents(mNativeTransitionPageHelperPtr, mTransitionContentViewCore); nativeSetWebContents(mNativeTransitionPageHelperPtr, mTransitionContentViewCore);
setTransitionOpacity(0.0f); setTransitionOpacity(0.0f);
......
...@@ -844,7 +844,8 @@ void TabAndroid::DetachOverlayContentViewCore(JNIEnv* env, ...@@ -844,7 +844,8 @@ void TabAndroid::DetachOverlayContentViewCore(JNIEnv* env,
jcontent_view_core); jcontent_view_core);
DCHECK(content_view_core); DCHECK(content_view_core);
content_view_core->GetLayer()->RemoveFromParent(); if (content_view_core->GetLayer()->parent() == content_layer_)
content_view_core->GetLayer()->RemoveFromParent();
} }
static void Init(JNIEnv* env, jobject obj) { static void Init(JNIEnv* env, jobject obj) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment