Chromium Code Reviews| Index: content/browser/web_contents/web_contents_view_aura.cc |
| diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc |
| index da9af68e420cdc09215582c10653ba5f9c4bb620..b7317b8fab1a7cde405948e71c53b69cc5eff20c 100644 |
| --- a/content/browser/web_contents/web_contents_view_aura.cc |
| +++ b/content/browser/web_contents/web_contents_view_aura.cc |
| @@ -24,7 +24,7 @@ |
| #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" |
| #include "content/browser/web_contents/aura/shadow_layer_delegate.h" |
| #include "content/browser/web_contents/aura/window_slider.h" |
| -#include "content/browser/web_contents/touch_editable_impl_aura.h" |
| +#include "content/browser/web_contents/touch_selection_controller_aura_client_impl.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/public/browser/content_browser_client.h" |
| #include "content/public/browser/notification_observer.h" |
| @@ -68,6 +68,7 @@ |
| #include "ui/gfx/image/image_png_rep.h" |
| #include "ui/gfx/image/image_skia.h" |
| #include "ui/gfx/screen.h" |
| +#include "ui/touch_selection/touch_selection_controller_aura.h" |
| #include "ui/wm/public/drag_drop_client.h" |
| #include "ui/wm/public/drag_drop_delegate.h" |
| @@ -616,8 +617,12 @@ class WebContentsViewAura::WindowObserver |
| const gfx::Rect& new_bounds) override { |
| if (window == host_window_ || window == view_->window_) { |
| SendScreenRects(); |
| - if (view_->touch_editable_) |
| - view_->touch_editable_->UpdateEditingController(); |
| + if (old_bounds.origin() != new_bounds.origin()) { |
| + ui::TouchSelectionControllerAura* selection_controller = |
| + view_->GetSelectionController(); |
| + if (selection_controller) |
| + selection_controller->OnWindowMoved(); |
| + } |
| #if defined(OS_WIN) |
| } else { |
| UpdateConstrainedWindows(NULL); |
| @@ -736,7 +741,6 @@ WebContentsViewAura::WebContentsViewAura( |
| overscroll_change_brightness_(false), |
| current_overscroll_gesture_(OVERSCROLL_NONE), |
| completed_overscroll_gesture_(OVERSCROLL_NONE), |
| - touch_editable_(TouchEditableImplAura::Create()), |
| is_or_was_visible_(false) { |
| } |
| @@ -755,12 +759,6 @@ WebContentsViewAura::~WebContentsViewAura() { |
| window_.reset(); |
| } |
| -void WebContentsViewAura::SetTouchEditableForTest( |
| - TouchEditableImplAura* touch_editable) { |
| - touch_editable_.reset(touch_editable); |
| - AttachTouchEditableToRenderView(); |
| -} |
| - |
| void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { |
| if (web_contents_->GetInterstitialPage()) |
| web_contents_->GetInterstitialPage()->SetSize(size); |
| @@ -974,20 +972,19 @@ void WebContentsViewAura::UpdateOverscrollWindowBrightness(float delta_x) { |
| window->layer()->SetLayerBrightness(brightness); |
| } |
| -void WebContentsViewAura::AttachTouchEditableToRenderView() { |
| - if (!touch_editable_) |
| - return; |
| - RenderWidgetHostViewAura* rwhva = ToRenderWidgetHostViewAura( |
| - web_contents_->GetRenderWidgetHostView()); |
| - touch_editable_->AttachToView(rwhva); |
| -} |
| - |
| void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate( |
| float delta_y) { |
| if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled()) |
| web_contents_->GetDelegate()->OverscrollUpdate(delta_y); |
| } |
| +ui::TouchSelectionControllerAura* |
| +WebContentsViewAura::GetSelectionController() { |
| + RenderWidgetHostViewAura* view = |
| + ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView()); |
| + return view ? view->selection_controller() : nullptr; |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // WebContentsViewAura, WebContentsView implementation: |
| @@ -1127,6 +1124,10 @@ RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget( |
| RenderWidgetHostViewAura* view = |
| new RenderWidgetHostViewAura(render_widget_host, is_guest_view_hack); |
| + TouchSelectionControllerAuraClientImpl* selection_controller_client = |
| + new TouchSelectionControllerAuraClientImpl(view); |
| + view->InitSelectionController(selection_controller_client); |
|
sadrul
2015/03/05 12:37:03
Why can't RWHVA itself create this?
mfomitchev
2015/03/05 16:07:54
Because TouchSelectionControllerAuraClientImpl is
|
| + |
| view->InitAsChild(NULL); |
| GetNativeView()->AddChild(view->GetNativeView()); |
| @@ -1149,7 +1150,6 @@ RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget( |
| InstallOverscrollControllerDelegate(view); |
| } |
| - AttachTouchEditableToRenderView(); |
| return view; |
| } |
| @@ -1168,7 +1168,6 @@ void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) { |
| void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) { |
| if (navigation_overlay_.get() && navigation_overlay_->has_window()) |
| navigation_overlay_->StartObserving(); |
| - AttachTouchEditableToRenderView(); |
| } |
| void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { |
| @@ -1191,9 +1190,10 @@ void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { |
| void WebContentsViewAura::ShowContextMenu(RenderFrameHost* render_frame_host, |
| const ContextMenuParams& params) { |
| - if (touch_editable_) { |
| - touch_editable_->EndTouchEditing(false); |
| - } |
| + ui::TouchSelectionControllerAura* selection_controller = |
| + GetSelectionController(); |
| + if (selection_controller) |
| + selection_controller->HideAndDisallowShowingAutomatically(); |
| if (delegate_) { |
| delegate_->ShowContextMenu(render_frame_host, params); |
| // WARNING: we may have been deleted during the call to ShowContextMenu(). |
| @@ -1212,9 +1212,10 @@ void WebContentsViewAura::StartDragging( |
| return; |
| } |
| - if (touch_editable_) |
| - touch_editable_->EndTouchEditing(false); |
| - |
| + ui::TouchSelectionControllerAura* selection_controller = |
| + GetSelectionController(); |
| + if (selection_controller) |
| + selection_controller->HideAndDisallowShowingAutomatically(); |
| ui::OSExchangeData::Provider* provider = ui::OSExchangeData::CreateProvider(); |
| PrepareDragData(drop_data, provider, web_contents_); |
| @@ -1346,9 +1347,12 @@ void WebContentsViewAura::OnOverscrollModeChange(OverscrollMode old_mode, |
| if (old_mode == OVERSCROLL_NORTH || old_mode == OVERSCROLL_SOUTH) |
| OverscrollUpdateForWebContentsDelegate(0); |
| - if (new_mode != OVERSCROLL_NONE && touch_editable_) |
| - touch_editable_->OverscrollStarted(); |
| - |
| + if (new_mode != OVERSCROLL_NONE) { |
| + ui::TouchSelectionControllerAura* selection_controller = |
| + GetSelectionController(); |
| + if (selection_controller) |
| + selection_controller->OnOverscrollStarted(); |
| + } |
| if (new_mode == OVERSCROLL_NONE || |
| !GetContentNativeView() || |
| ((new_mode == OVERSCROLL_EAST || new_mode == OVERSCROLL_WEST) && |
| @@ -1389,8 +1393,10 @@ void WebContentsViewAura::OnImplicitAnimationsCompleted() { |
| web_contents_->GetController().GoBack(); |
| PrepareOverscrollNavigationOverlay(); |
| } else { |
| - if (touch_editable_) |
| - touch_editable_->OverscrollCompleted(); |
| + ui::TouchSelectionControllerAura* selection_controller = |
| + GetSelectionController(); |
| + if (selection_controller) |
| + selection_controller->OnOverscrollCompleted(); |
| } |
| aura::Window* content = GetContentNativeView(); |