Commit 4e87004c authored by Matt Jones's avatar Matt Jones Committed by Commit Bot

Move text selection dismissal when BottomSheet is open to glue

Since text selection is no longer the responsibility of the
BottomSheet, the dependency on tab and tab provider have been removed
as well.

Bug: 986310
Change-Id: I827607ee610bf994a1205ad5b89c81b7bbff1813
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1927222Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717694}
parent f7a6e0cc
...@@ -1487,6 +1487,14 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent> ...@@ -1487,6 +1487,14 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
@Override @Override
public void onSheetOpened(int reason) { public void onSheetOpened(int reason) {
Tab activeTab = mActivityTabProvider.get();
if (activeTab != null) {
WebContents webContents = activeTab.getWebContents();
if (webContents != null) {
SelectionPopupController.fromWebContents(webContents).clearSelection();
}
}
BottomSheetContent content = mBottomSheetController.getCurrentSheetContent(); BottomSheetContent content = mBottomSheetController.getCurrentSheetContent();
// Content with a custom scrim lifecycle should not obscure the tab. The feature // Content with a custom scrim lifecycle should not obscure the tab. The feature
// is responsible for adding itself to the list of obscuring views when applicable. // is responsible for adding itself to the list of obscuring views when applicable.
......
...@@ -24,17 +24,12 @@ import androidx.annotation.Nullable; ...@@ -24,17 +24,12 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.ObserverList; import org.chromium.base.ObserverList;
import org.chromium.base.Supplier;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.util.AccessibilityUtil; import org.chromium.chrome.browser.util.AccessibilityUtil;
import org.chromium.chrome.browser.util.MathUtils; import org.chromium.chrome.browser.util.MathUtils;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetContent.HeightMode; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetContent.HeightMode;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController.SheetState; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController.SheetState;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController.StateChangeReason; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController.StateChangeReason;
import org.chromium.content_public.browser.SelectionPopupController;
import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.KeyboardVisibilityDelegate; import org.chromium.ui.KeyboardVisibilityDelegate;
/** /**
...@@ -119,9 +114,6 @@ class BottomSheet extends FrameLayout ...@@ -119,9 +114,6 @@ class BottomSheet extends FrameLayout
@SheetState @SheetState
private int mTargetState = SheetState.NONE; private int mTargetState = SheetState.NONE;
/** Used for getting the current tab. */
protected Supplier<Tab> mTabSupplier;
/** A handle to the content being shown by the sheet. */ /** A handle to the content being shown by the sheet. */
@Nullable @Nullable
protected BottomSheetContent mSheetContent; protected BottomSheetContent mSheetContent;
...@@ -256,14 +248,11 @@ class BottomSheet extends FrameLayout ...@@ -256,14 +248,11 @@ class BottomSheet extends FrameLayout
* Adds layout change listeners to the views that the bottom sheet depends on. Namely the * Adds layout change listeners to the views that the bottom sheet depends on. Namely the
* heights of the root view and control container are important as they are used in many of the * heights of the root view and control container are important as they are used in many of the
* calculations in this class. * calculations in this class.
* @param tabProvider A means of accessing the active tab.
* @param window Android window for getting insets. * @param window Android window for getting insets.
* @param keyboardDelegate Delegate for hiding the keyboard. * @param keyboardDelegate Delegate for hiding the keyboard.
*/ */
public void init(ActivityTabProvider tabProvider, Window window, public void init(Window window, KeyboardVisibilityDelegate keyboardDelegate) {
KeyboardVisibilityDelegate keyboardDelegate) {
View root = (View) getParent(); View root = (View) getParent();
mTabSupplier = tabProvider;
mToolbarHolder = mToolbarHolder =
(TouchRestrictingFrameLayout) findViewById(R.id.bottom_sheet_toolbar_container); (TouchRestrictingFrameLayout) findViewById(R.id.bottom_sheet_toolbar_container);
...@@ -491,7 +480,6 @@ class BottomSheet extends FrameLayout ...@@ -491,7 +480,6 @@ class BottomSheet extends FrameLayout
mIsSheetOpen = true; mIsSheetOpen = true;
dismissSelectedText();
for (BottomSheetObserver o : mObservers) o.onSheetOpened(reason); for (BottomSheetObserver o : mObservers) o.onSheetOpened(reason);
} }
...@@ -641,18 +629,6 @@ class BottomSheet extends FrameLayout ...@@ -641,18 +629,6 @@ class BottomSheet extends FrameLayout
} }
} }
/**
* Deselects any text in the active tab's web contents and dismisses the text controls.
*/
private void dismissSelectedText() {
Tab activeTab = mTabSupplier != null ? mTabSupplier.get() : null;
if (activeTab == null) return;
WebContents webContents = activeTab.getWebContents();
if (webContents == null) return;
SelectionPopupController.fromWebContents(webContents).clearSelection();
}
/** /**
* This is the same as {@link #setSheetOffsetFromBottom(float, int)} but exclusively for * This is the same as {@link #setSheetOffsetFromBottom(float, int)} but exclusively for
* testing. * testing.
......
...@@ -239,7 +239,7 @@ public class BottomSheetController implements Destroyable { ...@@ -239,7 +239,7 @@ public class BottomSheetController implements Destroyable {
final ScrimView scrim, Supplier<View> bottomSheetViewSupplier, Window window, final ScrimView scrim, Supplier<View> bottomSheetViewSupplier, Window window,
KeyboardVisibilityDelegate keyboardDelegate) { KeyboardVisibilityDelegate keyboardDelegate) {
mBottomSheet = (BottomSheet) bottomSheetViewSupplier.get(); mBottomSheet = (BottomSheet) bottomSheetViewSupplier.get();
mBottomSheet.init(mTabProvider, window, keyboardDelegate); mBottomSheet.init(window, keyboardDelegate);
// Initialize the queue with a comparator that checks content priority. // Initialize the queue with a comparator that checks content priority.
mContentQueue = new PriorityQueue<>(INITIAL_QUEUE_CAPACITY, mContentQueue = new PriorityQueue<>(INITIAL_QUEUE_CAPACITY,
......
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