| Index: content/browser/renderer_host/render_widget_host_view_aura.cc
|
| diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
|
| index d75bbcebcbf063366004be10f09c48a1f1b86c45..29dbf0e05eeaea48a459ddb91a06193f17cd4805 100644
|
| --- a/content/browser/renderer_host/render_widget_host_view_aura.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
|
| @@ -74,6 +74,7 @@
|
| #include "ui/gfx/geometry/size_conversions.h"
|
| #include "ui/gfx/screen.h"
|
| #include "ui/gfx/skia_util.h"
|
| +#include "ui/touch_selection/touch_selection_controller_aura.h"
|
| #include "ui/wm/public/activation_client.h"
|
| #include "ui/wm/public/scoped_tooltip_disabler.h"
|
| #include "ui/wm/public/tooltip_client.h"
|
| @@ -436,7 +437,6 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host,
|
| legacy_window_destroyed_(false),
|
| #endif
|
| has_snapped_to_boundary_(false),
|
| - touch_editing_client_(NULL),
|
| is_guest_view_hack_(is_guest_view_hack),
|
| weak_ptr_factory_(this) {
|
| if (!is_guest_view_hack_)
|
| @@ -781,6 +781,8 @@ void RenderWidgetHostViewAura::Focus() {
|
|
|
| void RenderWidgetHostViewAura::Blur() {
|
| window_->Blur();
|
| + if (selection_controller_)
|
| + selection_controller_->HideAndDisallowShowingAutomatically();
|
| }
|
|
|
| bool RenderWidgetHostViewAura::HasFocus() const {
|
| @@ -848,8 +850,9 @@ void RenderWidgetHostViewAura::TextInputTypeChanged(
|
| text_input_flags_ = flags;
|
| if (GetInputMethod())
|
| GetInputMethod()->OnTextInputTypeChanged(this);
|
| - if (touch_editing_client_)
|
| - touch_editing_client_->OnTextInputTypeChanged(text_input_type_);
|
| + const bool is_editable_node = type != ui::TEXT_INPUT_TYPE_NONE;
|
| + if (selection_controller_)
|
| + selection_controller_->OnSelectionEditable(is_editable_node);
|
| }
|
| }
|
|
|
| @@ -906,6 +909,9 @@ void RenderWidgetHostViewAura::SelectionChanged(const base::string16& text,
|
| const gfx::Range& range) {
|
| RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
|
|
|
| + if (selection_controller_)
|
| + selection_controller_->OnSelectionEmpty(text.empty());
|
| +
|
| #if defined(USE_X11) && !defined(OS_CHROMEOS)
|
| if (text.empty() || range.is_empty())
|
| return;
|
| @@ -930,47 +936,7 @@ gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const {
|
|
|
| void RenderWidgetHostViewAura::SelectionBoundsChanged(
|
| const ViewHostMsg_SelectionBounds_Params& params) {
|
| - ui::SelectionBound anchor_bound, focus_bound;
|
| - anchor_bound.SetEdge(params.anchor_rect.origin(),
|
| - params.anchor_rect.bottom_left());
|
| - focus_bound.SetEdge(params.focus_rect.origin(),
|
| - params.focus_rect.bottom_left());
|
| -
|
| - if (params.anchor_rect == params.focus_rect) {
|
| - anchor_bound.set_type(ui::SelectionBound::CENTER);
|
| - focus_bound.set_type(ui::SelectionBound::CENTER);
|
| - } else {
|
| - // Whether text is LTR at the anchor handle.
|
| - bool anchor_LTR = params.anchor_dir == blink::WebTextDirectionLeftToRight;
|
| - // Whether text is LTR at the focus handle.
|
| - bool focus_LTR = params.focus_dir == blink::WebTextDirectionLeftToRight;
|
| -
|
| - if ((params.is_anchor_first && anchor_LTR) ||
|
| - (!params.is_anchor_first && !anchor_LTR)) {
|
| - anchor_bound.set_type(ui::SelectionBound::LEFT);
|
| - } else {
|
| - anchor_bound.set_type(ui::SelectionBound::RIGHT);
|
| - }
|
| - if ((params.is_anchor_first && focus_LTR) ||
|
| - (!params.is_anchor_first && !focus_LTR)) {
|
| - focus_bound.set_type(ui::SelectionBound::RIGHT);
|
| - } else {
|
| - focus_bound.set_type(ui::SelectionBound::LEFT);
|
| - }
|
| - }
|
| -
|
| - if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
|
| - return;
|
| -
|
| - selection_anchor_ = anchor_bound;
|
| - selection_focus_ = focus_bound;
|
| - if (GetInputMethod())
|
| - GetInputMethod()->OnCaretBoundsChanged(this);
|
| -
|
| - if (touch_editing_client_) {
|
| - touch_editing_client_->OnSelectionOrCursorChanged(
|
| - anchor_bound, focus_bound);
|
| - }
|
| + NOTREACHED() << "Selection bounds should be routed through the compositor.";
|
| }
|
|
|
| void RenderWidgetHostViewAura::CopyFromCompositingSurface(
|
| @@ -1059,6 +1025,8 @@ void RenderWidgetHostViewAura::OnSwapCompositorFrame(
|
| frame->delegated_frame_data.Pass(),
|
| frame->metadata.device_scale_factor,
|
| frame->metadata.latency_info);
|
| + SelectionBoundsUpdated(ui::SelectionBound(frame->metadata.selection_start),
|
| + ui::SelectionBound(frame->metadata.selection_end));
|
| return;
|
| }
|
|
|
| @@ -1072,8 +1040,8 @@ void RenderWidgetHostViewAura::OnSwapCompositorFrame(
|
| }
|
|
|
| void RenderWidgetHostViewAura::DidStopFlinging() {
|
| - if (touch_editing_client_)
|
| - touch_editing_client_->DidStopFlinging();
|
| + if (selection_controller_)
|
| + selection_controller_->OnFlingCompleted();
|
| }
|
|
|
| #if defined(OS_WIN)
|
| @@ -1153,9 +1121,6 @@ void RenderWidgetHostViewAura::WheelEventAck(
|
| void RenderWidgetHostViewAura::GestureEventAck(
|
| const blink::WebGestureEvent& event,
|
| InputEventAckState ack_result) {
|
| - if (touch_editing_client_)
|
| - touch_editing_client_->GestureEventAck(event.type);
|
| -
|
| if (overscroll_controller_) {
|
| overscroll_controller_->ReceivedEventACK(
|
| event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result));
|
| @@ -1526,9 +1491,12 @@ gfx::Rect RenderWidgetHostViewAura::ConvertRectFromScreen(
|
| }
|
|
|
| gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
|
| - gfx::Rect rect =
|
| - ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_);
|
| - return ConvertRectToScreen(rect);
|
| + if (selection_controller_) {
|
| + const ui::SelectionBound& start = selection_controller_->start();
|
| + const ui::SelectionBound& end = selection_controller_->end();
|
| + return ConvertRectToScreen(ui::RectBetweenSelectionBounds(start, end));
|
| + }
|
| + return gfx::Rect();
|
| }
|
|
|
| bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
|
| @@ -1727,8 +1695,8 @@ bool RenderWidgetHostViewAura::CanFocus() {
|
|
|
| void RenderWidgetHostViewAura::OnCaptureLost() {
|
| host_->LostCapture();
|
| - if (touch_editing_client_)
|
| - touch_editing_client_->EndTouchEditing(false);
|
| + if (selection_controller_)
|
| + selection_controller_->HideAndDisallowShowingAutomatically();
|
| }
|
|
|
| void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) {
|
| @@ -1811,8 +1779,6 @@ void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const {
|
|
|
| void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
|
| TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent");
|
| - if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
|
| - return;
|
|
|
| if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
|
| popup_child_host_view_->OnKeyEvent(event);
|
| @@ -1859,9 +1825,6 @@ void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
|
| void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) {
|
| TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent");
|
|
|
| - if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
|
| - return;
|
| -
|
| if (mouse_locked_) {
|
| aura::client::CursorClient* cursor_client =
|
| aura::client::GetCursorClient(window_->GetRootWindow());
|
| @@ -2000,8 +1963,6 @@ void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) {
|
|
|
| void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
|
| TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent");
|
| - if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
|
| - return;
|
|
|
| if (event->type() == ui::ET_SCROLL) {
|
| #if !defined(OS_WIN)
|
| @@ -2030,8 +1991,12 @@ void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
|
|
|
| void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
|
| TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent");
|
| - if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
|
| - return;
|
| +
|
| + if (selection_controller_) {
|
| + selection_controller_->HandleTouchEvent(event);
|
| + if (event->handled())
|
| + return;
|
| + }
|
|
|
| // Update the touch event first.
|
| if (!pointer_state_.OnTouch(*event)) {
|
| @@ -2059,6 +2024,13 @@ void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
|
|
|
| void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
|
| TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent");
|
| +
|
| + if (selection_controller_) {
|
| + selection_controller_->HandleGestureEvent(event);
|
| + if (event->handled())
|
| + return;
|
| + }
|
| +
|
| if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
|
| event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
|
| event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
|
| @@ -2066,9 +2038,6 @@ void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
|
| return;
|
| }
|
|
|
| - if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
|
| - return;
|
| -
|
| // Confirm existing composition text on TAP gesture, to make sure the input
|
| // caret won't be moved with an ongoing composition text.
|
| if (event->type() == ui::ET_GESTURE_TAP)
|
| @@ -2191,8 +2160,8 @@ void RenderWidgetHostViewAura::OnWindowFocused(aura::Window* gained_focus,
|
| DetachFromInputMethod();
|
| host_->SetInputMethodActive(false);
|
|
|
| - if (touch_editing_client_)
|
| - touch_editing_client_->EndTouchEditing(false);
|
| + if (selection_controller_)
|
| + selection_controller_->HideAndDisallowShowingAutomatically();
|
|
|
| if (overscroll_controller_)
|
| overscroll_controller_->Cancel();
|
| @@ -2249,9 +2218,8 @@ void RenderWidgetHostViewAura::OnHostMoved(const aura::WindowTreeHost* host,
|
| // RenderWidgetHostViewAura, private:
|
|
|
| RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
|
| - if (touch_editing_client_)
|
| - touch_editing_client_->OnViewDestroyed();
|
| -
|
| + selection_controller_.reset();
|
| + selection_controller_client_.reset();
|
| delegated_frame_host_.reset();
|
| window_observer_.reset();
|
| if (window_->GetHost())
|
| @@ -2401,6 +2369,14 @@ void RenderWidgetHostViewAura::SetOverscrollControllerEnabled(bool enabled) {
|
| overscroll_controller_.reset(new OverscrollController());
|
| }
|
|
|
| +void RenderWidgetHostViewAura::InitSelectionController(
|
| + ui::TouchSelectionControllerAuraClient* selection_controller_client) {
|
| + DCHECK(!selection_controller_client_);
|
| + selection_controller_client_.reset(selection_controller_client);
|
| + selection_controller_.reset(
|
| + new ui::TouchSelectionControllerAura(selection_controller_client));
|
| +}
|
| +
|
| void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() {
|
| // The top left corner of our view in window coordinates might not land on a
|
| // device pixel boundary if we have a non-integer device scale. In that case,
|
| @@ -2433,10 +2409,6 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
|
| window_->SetBounds(rect);
|
| host_->WasResized();
|
| delegated_frame_host_->WasResized();
|
| - if (touch_editing_client_) {
|
| - touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_,
|
| - selection_focus_);
|
| - }
|
| #if defined(OS_WIN)
|
| // Create the legacy dummy window which corresponds to the bounds of the
|
| // webcontents. This will be passed as the container window for windowless
|
| @@ -2580,6 +2552,15 @@ SkColorType RenderWidgetHostViewAura::PreferredReadbackFormat() {
|
| return kN32_SkColorType;
|
| }
|
|
|
| +void RenderWidgetHostViewAura::SelectionBoundsUpdated(
|
| + const ui::SelectionBound& start,
|
| + const ui::SelectionBound& end) {
|
| + if (selection_controller_)
|
| + selection_controller_->OnSelectionBoundsUpdated(start, end);
|
| + if (GetInputMethod())
|
| + GetInputMethod()->OnCaretBoundsChanged(this);
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // DelegatedFrameHost, public:
|
|
|
|
|