Commit 2929de50 authored by Stephane Zermatten's avatar Stephane Zermatten Committed by Commit Bot

[Autofill Assistant] Fix to avoid overlay drawing on top of top bar.

With this change, TouchEventFilterView sets a clip rectangle that
avoids the top and bottom bars when drawing.

This avoids ever drawing on top of either bars and is also more
efficient than the previous implementation, which would draw then
clear out some section.

Additionally, it uses the top visible offset for drawing, instead
of the top content offset. There's a difference of a few pixel,
which is visible now because of the presence of the blue border.

This change also address the CanvasSize lint warning and stops
using canvas.getWidth(), as recommended.

Bug: b/125245127
Change-Id: I0ced7df06f1ace285525f9b7328204cc79bbad3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1505944
Commit-Queue: Stephane Zermatten <szermatt@chromium.org>
Reviewed-by: default avatarJordan Demeulenaere <jdemeulenaere@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638533}
parent 0db91fa2
...@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.autofill_assistant.overlay; ...@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.autofill_assistant.overlay;
import android.animation.TimeInterpolator; import android.animation.TimeInterpolator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
...@@ -526,36 +525,33 @@ public class TouchEventFilterView ...@@ -526,36 +525,33 @@ public class TouchEventFilterView
/** Returns the origin of the visual viewport in this view. */ /** Returns the origin of the visual viewport in this view. */
@Override @Override
@SuppressLint("CanvasSize")
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
super.onDraw(canvas); super.onDraw(canvas);
if (mCurrentState == AssistantOverlayState.HIDDEN) { if (mCurrentState == AssistantOverlayState.HIDDEN) {
return; return;
} }
canvas.drawPaint(mBackground);
int width = canvas.getWidth(); int width = getWidth();
int yTop = getVisualViewportTop();
if (yTop > 0) {
canvas.drawRect(0, 0, width, yTop, mClear);
}
int yBottom = getVisualViewportBottom(); int yBottom = getVisualViewportBottom();
if (yBottom > 0) {
canvas.drawRect(0, yBottom, width, canvas.getHeight(), mClear); // Don't draw over the top or bottom bars.
if (mFullscreenManager != null) {
canvas.clipRect(0, mFullscreenManager.getTopVisibleContentOffset() - mMarginTop, width,
yBottom);
} }
canvas.drawPaint(mBackground);
if (mCurrentState != AssistantOverlayState.PARTIAL) { if (mCurrentState != AssistantOverlayState.PARTIAL) {
return; return;
} }
int yTop = getVisualViewportTop();
int height = yBottom - yTop; int height = yBottom - yTop;
float boxesAlpha = (mCurrentBoxesAnimator != null && mCurrentBoxesAnimator.isRunning()) float boxesAlpha = (mCurrentBoxesAnimator != null && mCurrentBoxesAnimator.isRunning())
? ((float) mCurrentBoxesAnimator.getAnimatedValue()) ? ((float) mCurrentBoxesAnimator.getAnimatedValue())
: 0f; : 0f;
mBoxStroke.setAlpha((int) (0xff * (1.0 - boxesAlpha))); mBoxStroke.setAlpha((int) (0xff * (1.0 - boxesAlpha)));
mBoxFill.setAlpha((int) (BACKGROUND_ALPHA * boxesAlpha)); mBoxFill.setAlpha((int) (BACKGROUND_ALPHA * boxesAlpha));
for (RectF rect : mTouchableArea) { for (RectF rect : mTouchableArea) {
mDrawRect.left = rect.left * width - mPaddingPx; mDrawRect.left = rect.left * width - mPaddingPx;
mDrawRect.top = mDrawRect.top =
......
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