Commit 6c926818 authored by Changwan Ryu's avatar Changwan Ryu Committed by Commit Bot

Add debugging messages for selection handles and magnifier

These were frequently used debugging messages when investigating
magnifier and selection handle issues, so adding the code controlled
by a hard-coded flag.

Bug: 1134492
Change-Id: I801492d1a47089247237d459ae33acc53bd9eb41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2453789Reviewed-by: default avatarShimi Zhang <ctzsm@chromium.org>
Commit-Queue: Changwan Ryu <changwan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814312}
parent a9b71113
......@@ -7,11 +7,16 @@ package org.chromium.content.browser.selection;
import android.animation.ValueAnimator;
import android.view.animation.LinearInterpolator;
import org.chromium.base.Log;
/**
* MagnifierAnimator adds animation to MagnifierWrapper when there is a change in y direction.
* MagnifierWrapper class isolated P APIs out so we could write test for MagnifierAnimator.
*/
public class MagnifierAnimator implements SelectionInsertionHandleObserver {
private static final boolean DEBUG = false;
private static final String TAG = "Magnifier";
private static final long DURATION_MS = 100;
private MagnifierWrapper mMagnifier;
......@@ -46,6 +51,11 @@ public class MagnifierAnimator implements SelectionInsertionHandleObserver {
@Override
public void handleDragStartedOrMoved(float x, float y) {
if (!mMagnifier.isAvailable()) return;
if (DEBUG) {
Log.i(TAG,
"handleDragStartedOrMoved: "
+ "(" + x + ", " + y + ")");
}
// We only do animation if this is not the first time to show magnifier and y coordinate
// is different from last target.
if (mMagnifierIsShowing && y != mTargetY) {
......
......@@ -8,11 +8,16 @@ import android.annotation.SuppressLint;
import android.view.View;
import android.widget.Magnifier;
import org.chromium.base.Log;
/**
* Implements MagnifierWrapper interface.
*/
@SuppressLint("NewApi") // Magnifier requires API level 28.
public class MagnifierWrapperImpl implements MagnifierWrapper {
private static final boolean DEBUG = false;
private static final String TAG = "Magnifier";
private Magnifier mMagnifier;
private SelectionPopupControllerImpl.ReadbackViewCallback mCallback;
......@@ -28,12 +33,14 @@ public class MagnifierWrapperImpl implements MagnifierWrapper {
View view = mCallback.getReadbackView();
if (view == null) return;
if (mMagnifier == null) mMagnifier = new Magnifier(view);
if (DEBUG) Log.i(TAG, "show (" + x + ", " + y + ")");
mMagnifier.show(x, y);
}
@Override
public void dismiss() {
if (mMagnifier != null) {
if (DEBUG) Log.i(TAG, "dismiss");
mMagnifier.dismiss();
mMagnifier = null;
}
......
......@@ -80,6 +80,7 @@ public class SelectionPopupControllerImpl extends ActionModeCallbackHelper
implements ImeEventObserver, SelectionPopupController, WindowEventObserver, HideablePopup,
ContainerViewObserver, UserData {
private static final String TAG = "SelectionPopupCtlr"; // 20 char limit
private static final boolean DEBUG = false;
/**
* Android Intent size limitations prevent sending over a megabyte of data. Limit
......@@ -1286,6 +1287,11 @@ public class SelectionPopupControllerImpl extends ActionModeCallbackHelper
@CalledByNative
void onSelectionEvent(
@SelectionEventType int eventType, int left, int top, int right, int bottom) {
if (DEBUG) {
Log.i(TAG,
"onSelectionEvent: " + eventType + "[(" + left + ", " + top + ")-(" + right
+ ", " + bottom + ")]");
}
// Ensure the provided selection coordinates form a non-empty rect, as required by
// the selection action mode.
// NOTE: the native side ensures the rectangle is not empty, but that's done using floating
......
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