Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Contextual Search] Remove layers when no longer needed.
Browse files Browse the repository at this point in the history
Now that there can be multiple Overlays Panels being used,
a few bugs are happening due to the Panel's cc::Layer not
being properly removed.

This CL fixes the problem by removing the layer when a
OverlayPanel shows up when another one is being displayed.

Also, this CL removed the OverlayPanel layer from the
StaticLayout whenever that layout gets hidden (see
dettachViews method).

BUG=539847

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

Cr-Commit-Position: refs/heads/master@{#363092}
(cherry picked from commit a53e46e)

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

Cr-Commit-Position: refs/branch-heads/2564@{#242}
Cr-Branched-From: 1283eca-refs/heads/master@{#359700}
  • Loading branch information
Pedro Simonetti Garcia committed Dec 4, 2015
1 parent eb90a79 commit a9c0375
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ public boolean isExpanded() {

@Override
public void closePanel(StateChangeReason reason, boolean animate) {
if (!isShowing()) return;

super.closePanel(reason, animate);

// If the close action is animated, the Layout will be hidden when
Expand All @@ -173,6 +175,8 @@ public void closePanel(StateChangeReason reason, boolean animate) {
* @param reason The reason the panel is being shown.
*/
public void requestPanelShow(StateChangeReason reason) {
if (isShowing()) return;

if (mPanelManager != null) {
mPanelManager.requestPanelShow(this, reason);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,24 @@ void StaticTabSceneLayer::SetContentSceneLayer(JNIEnv* env,
jobject jobj,
jobject jcontent_scene_layer) {
SceneLayer* content_scene_layer = FromJavaObject(env, jcontent_scene_layer);
if (content_scene_layer && content_scene_layer->layer()) {
content_scene_layer_ = content_scene_layer->layer();
if (content_scene_layer_.get())
layer_->AddChild(content_scene_layer_);
} else if (content_scene_layer_) {
scoped_refptr<cc::Layer> layer = content_scene_layer ?
content_scene_layer->layer() : nullptr;

if (content_scene_layer_ && content_scene_layer_ != layer) {
content_scene_layer_->RemoveFromParent();
content_scene_layer_ = nullptr;
}

// TODO(pedrosimonetti): Consider being smarter with regards to when to
// add the layer to the hierarchy. For now, we need to keep adding the
// content_scene_layer on every frame because the content_layer is also
// added on every frame. This means that if we only add it once, the
// content_layer will be added again on the next frame and will
// occlude the content_scene_layer.
if (layer) {
content_scene_layer_ = layer;
layer_->AddChild(layer);
}
}

static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
Expand Down

0 comments on commit a9c0375

Please sign in to comment.