| Index: content/browser/renderer_host/input/touch_selection_controller_client_aura.cc
|
| diff --git a/content/browser/renderer_host/input/touch_selection_controller_client_aura.cc b/content/browser/renderer_host/input/touch_selection_controller_client_aura.cc
|
| index b07e3adb4aca2e4d9258d31f622678dd86411881..d9d142aa834341bcda966ca450633630589e0571 100644
|
| --- a/content/browser/renderer_host/input/touch_selection_controller_client_aura.cc
|
| +++ b/content/browser/renderer_host/input/touch_selection_controller_client_aura.cc
|
| @@ -112,6 +112,9 @@ void TouchSelectionControllerClientAura::EnvPreTargetHandler::OnScrollEvent(
|
| TouchSelectionControllerClientAura::TouchSelectionControllerClientAura(
|
| RenderWidgetHostViewAura* rwhva)
|
| : rwhva_(rwhva),
|
| + internal_client_(rwhva),
|
| + active_client_(&internal_client_),
|
| + active_menu_client_(this),
|
| quick_menu_timer_(
|
| FROM_HERE,
|
| base::TimeDelta::FromMilliseconds(kQuickMenuDelayInMs),
|
| @@ -127,6 +130,8 @@ TouchSelectionControllerClientAura::TouchSelectionControllerClientAura(
|
| }
|
|
|
| TouchSelectionControllerClientAura::~TouchSelectionControllerClientAura() {
|
| + for (auto& observer : observers_)
|
| + observer.OnManagerWillDestroy(this);
|
| }
|
|
|
| void TouchSelectionControllerClientAura::OnWindowMoved() {
|
| @@ -169,9 +174,63 @@ bool TouchSelectionControllerClientAura::HandleContextMenu(
|
| return false;
|
| }
|
|
|
| +void TouchSelectionControllerClientAura::UpdateClientSelectionBounds(
|
| + const gfx::SelectionBound& start,
|
| + const gfx::SelectionBound& end) {
|
| + UpdateClientSelectionBounds(start, end, &internal_client_, this);
|
| +}
|
| +
|
| +void TouchSelectionControllerClientAura::UpdateClientSelectionBounds(
|
| + const gfx::SelectionBound& start,
|
| + const gfx::SelectionBound& end,
|
| + ui::TouchSelectionControllerClient* client,
|
| + ui::TouchSelectionMenuClient* menu_client) {
|
| + if (client != active_client_ &&
|
| + (start.type() == gfx::SelectionBound::EMPTY || !start.visible()) &&
|
| + (end.type() == gfx::SelectionBound::EMPTY || !end.visible()) &&
|
| + (manager_selection_start_.type() != gfx::SelectionBound::EMPTY ||
|
| + manager_selection_end_.type() != gfx::SelectionBound::EMPTY)) {
|
| + return;
|
| + }
|
| +
|
| + active_client_ = client;
|
| + active_menu_client_ = menu_client;
|
| + manager_selection_start_ = start;
|
| + manager_selection_end_ = end;
|
| + // Notify TouchSelectionController if anything should change here. Only
|
| + // update if the client is different and not making a change to empty, or
|
| + // is the same client.
|
| + GetTouchSelectionController()->OnSelectionBoundsChanged(start, end);
|
| +}
|
| +
|
| +void TouchSelectionControllerClientAura::InvalidateClient(
|
| + ui::TouchSelectionControllerClient* client) {
|
| + DCHECK(client != &internal_client_);
|
| + if (client == active_client_) {
|
| + active_client_ = &internal_client_;
|
| + active_menu_client_ = this;
|
| + }
|
| +}
|
| +
|
| +ui::TouchSelectionController*
|
| +TouchSelectionControllerClientAura::GetTouchSelectionController() {
|
| + return rwhva_->selection_controller();
|
| +}
|
| +
|
| +void TouchSelectionControllerClientAura::AddObserver(
|
| + TouchSelectionControllerClientManager::Observer* observer) {
|
| + observers_.AddObserver(observer);
|
| +}
|
| +
|
| +void TouchSelectionControllerClientAura::RemoveObserver(
|
| + TouchSelectionControllerClientManager::Observer* observer) {
|
| + observers_.RemoveObserver(observer);
|
| +}
|
| +
|
| bool TouchSelectionControllerClientAura::IsQuickMenuAvailable() const {
|
| return ui::TouchSelectionMenuRunner::GetInstance() &&
|
| - ui::TouchSelectionMenuRunner::GetInstance()->IsMenuAvailable(this);
|
| + ui::TouchSelectionMenuRunner::GetInstance()->IsMenuAvailable(
|
| + active_menu_client_);
|
| }
|
|
|
| void TouchSelectionControllerClientAura::ShowQuickMenu() {
|
| @@ -202,7 +261,7 @@ void TouchSelectionControllerClientAura::ShowQuickMenu() {
|
|
|
| aura::Window* parent = rwhva_->GetNativeView();
|
| ui::TouchSelectionMenuRunner::GetInstance()->OpenMenu(
|
| - this, ConvertRectToScreen(parent, anchor_rect),
|
| + active_menu_client_, ConvertRectToScreen(parent, anchor_rect),
|
| gfx::ToRoundedSize(max_handle_size), parent->GetToplevelWindow());
|
| }
|
|
|
| @@ -232,6 +291,14 @@ void TouchSelectionControllerClientAura::UpdateQuickMenu() {
|
| }
|
|
|
| bool TouchSelectionControllerClientAura::SupportsAnimation() const {
|
| + // We don't pass this to the active client, since it is assumed it will have
|
| + // the same behaviour as the Aura client.
|
| + return false;
|
| +}
|
| +
|
| +bool TouchSelectionControllerClientAura::InternalClient::SupportsAnimation()
|
| + const {
|
| + NOTREACHED();
|
| return false;
|
| }
|
|
|
| @@ -239,8 +306,17 @@ void TouchSelectionControllerClientAura::SetNeedsAnimate() {
|
| NOTREACHED();
|
| }
|
|
|
| +void TouchSelectionControllerClientAura::InternalClient::SetNeedsAnimate() {
|
| + NOTREACHED();
|
| +}
|
| +
|
| void TouchSelectionControllerClientAura::MoveCaret(
|
| const gfx::PointF& position) {
|
| + active_client_->MoveCaret(position);
|
| +}
|
| +
|
| +void TouchSelectionControllerClientAura::InternalClient::MoveCaret(
|
| + const gfx::PointF& position) {
|
| RenderWidgetHostImpl* host =
|
| RenderWidgetHostImpl::From(rwhva_->GetRenderWidgetHost());
|
| host->MoveCaret(gfx::ToRoundedPoint(position));
|
| @@ -248,6 +324,11 @@ void TouchSelectionControllerClientAura::MoveCaret(
|
|
|
| void TouchSelectionControllerClientAura::MoveRangeSelectionExtent(
|
| const gfx::PointF& extent) {
|
| + active_client_->MoveRangeSelectionExtent(extent);
|
| +}
|
| +
|
| +void TouchSelectionControllerClientAura::InternalClient::
|
| + MoveRangeSelectionExtent(const gfx::PointF& extent) {
|
| RenderWidgetHostDelegate* host_delegate =
|
| RenderWidgetHostImpl::From(rwhva_->GetRenderWidgetHost())->delegate();
|
| if (host_delegate)
|
| @@ -257,6 +338,12 @@ void TouchSelectionControllerClientAura::MoveRangeSelectionExtent(
|
| void TouchSelectionControllerClientAura::SelectBetweenCoordinates(
|
| const gfx::PointF& base,
|
| const gfx::PointF& extent) {
|
| + active_client_->SelectBetweenCoordinates(base, extent);
|
| +}
|
| +
|
| +void TouchSelectionControllerClientAura::InternalClient::
|
| + SelectBetweenCoordinates(const gfx::PointF& base,
|
| + const gfx::PointF& extent) {
|
| RenderWidgetHostDelegate* host_delegate =
|
| RenderWidgetHostImpl::From(rwhva_->GetRenderWidgetHost())->delegate();
|
| if (host_delegate) {
|
| @@ -267,6 +354,8 @@ void TouchSelectionControllerClientAura::SelectBetweenCoordinates(
|
|
|
| void TouchSelectionControllerClientAura::OnSelectionEvent(
|
| ui::SelectionEventType event) {
|
| + // This function (implicitly) uses active_menu_client_, so we don't go to the
|
| + // active view for this.
|
| switch (event) {
|
| case ui::SELECTION_HANDLES_SHOWN:
|
| quick_menu_requested_ = true;
|
| @@ -303,12 +392,26 @@ void TouchSelectionControllerClientAura::OnSelectionEvent(
|
| };
|
| }
|
|
|
| +void TouchSelectionControllerClientAura::InternalClient::OnSelectionEvent(
|
| + ui::SelectionEventType event) {
|
| + NOTREACHED();
|
| +}
|
| +
|
| std::unique_ptr<ui::TouchHandleDrawable>
|
| TouchSelectionControllerClientAura::CreateDrawable() {
|
| + // This function is purely related to the top-level view's window, so it
|
| + // is always handled here and never in
|
| + // TouchSelectionControllerClientChildFrame.
|
| return std::unique_ptr<ui::TouchHandleDrawable>(
|
| new ui::TouchHandleDrawableAura(rwhva_->GetNativeView()));
|
| }
|
|
|
| +std::unique_ptr<ui::TouchHandleDrawable>
|
| +TouchSelectionControllerClientAura::InternalClient::CreateDrawable() {
|
| + NOTREACHED();
|
| + return nullptr;
|
| +}
|
| +
|
| bool TouchSelectionControllerClientAura::IsCommandIdEnabled(
|
| int command_id) const {
|
| bool editable = rwhva_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE;
|
|
|