Commit 8fab3ad6 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chrome: makes SwipableOverlayView only attach listener when necessary

SwipableOverlayView makes use of GestureListenerManager, which is
currently rather broke. This is because GestureListenerManager needs
to see cc::RenderFrameMetadata on every frame, which it currently isn't.
Making GestureListenerManager get render-frame-metadata on every frame
is quite costly. I'm in the process of making GestureListenerManager
get every frame only when listeners are attached. This patch changes
SwipableOverlayView to only attach a listener when it actually needs
the information.

Patch that makes GestureListenerManager get cc::RenderFrameMetadata is
here: https://chromium-review.googlesource.com/c/chromium/src/+/2222623
(it's a work in progress that I'll be doing right after this).

BUG=1087480
TEST=none

Change-Id: Ib22f1d1ac1caefece5fb1c6059cdd37da72b4618
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225139Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773745}
parent d3567e90
......@@ -113,7 +113,8 @@ public abstract class SwipableOverlayView extends FrameLayout {
}
mWebContents = webContents;
if (mWebContents != null) {
// See comment in onLayout() as to why the listener is only attached if mTotalHeight is > 0.
if (mWebContents != null && mTotalHeight > 0) {
GestureListenerManager.fromWebContents(mWebContents).addListener(mGestureStateListener);
}
}
......@@ -183,6 +184,18 @@ public abstract class SwipableOverlayView extends FrameLayout {
MarginLayoutParams params = (MarginLayoutParams) getLayoutParams();
mTotalHeight = getMeasuredHeight() + params.topMargin + params.bottomMargin;
// Adding a listener to GestureListenerManager results in extra IPCs on every frame, which
// is very costly. Only attach the listener if needed.
if (mWebContents != null) {
if (mTotalHeight > 0) {
GestureListenerManager.fromWebContents(mWebContents)
.addListener(mGestureStateListener);
} else {
GestureListenerManager.fromWebContents(mWebContents)
.removeListener(mGestureStateListener);
}
}
super.onLayout(changed, l, t, r, b);
}
......
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