| 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 4477c564e870c21b0fc43c7cc8fc4b7459dca608..c9b1b06caf20e742a4d66c7a022492c72e24f180 100644
|
| --- a/content/browser/renderer_host/render_widget_host_view_aura.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
|
| @@ -28,6 +28,7 @@
|
| #include "content/public/browser/render_view_host.h"
|
| #include "content/public/browser/user_metrics.h"
|
| #include "content/public/common/content_switches.h"
|
| +#include "grit/ui_strings.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
|
| @@ -948,6 +949,21 @@ void RenderWidgetHostViewAura::SelectionBoundsChanged(
|
|
|
| if (GetInputMethod())
|
| GetInputMethod()->OnCaretBoundsChanged(this);
|
| + if (touch_selection_controller_.get())
|
| + touch_selection_controller_->SelectionChanged();
|
| +}
|
| +
|
| +void RenderWidgetHostViewAura::TouchEditingHandlesVisibilityChanged(
|
| + bool visible) {
|
| + if (visible && !touch_selection_controller_.get()) {
|
| + touch_selection_controller_.reset(
|
| + ui::TouchSelectionController::create(this));
|
| + }
|
| + if (!visible)
|
| + touch_selection_controller_.reset();
|
| +
|
| + if (touch_selection_controller_.get())
|
| + touch_selection_controller_->SelectionChanged();
|
| }
|
|
|
| void RenderWidgetHostViewAura::ScrollOffsetChanged() {
|
| @@ -1649,6 +1665,9 @@ void RenderWidgetHostViewAura::OnBoundsChanged(const gfx::Rect& old_bounds,
|
| // WebContentsViewAura in other cases.
|
| if (is_fullscreen_)
|
| SetSize(new_bounds.size());
|
| +
|
| + if (touch_selection_controller_.get())
|
| + touch_selection_controller_->SelectionChanged();
|
| }
|
|
|
| gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) {
|
| @@ -2149,6 +2168,125 @@ void RenderWidgetHostViewAura::OnLostResources() {
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| +// RenderWidgetHostViewAura, ui::TouchEditable implementation:
|
| +
|
| +void RenderWidgetHostViewAura::SelectRect(const gfx::Point& start,
|
| + const gfx::Point& end) {
|
| + // Since we draw selection handles in WebKit, we should never get here.
|
| + NOTREACHED();
|
| +}
|
| +
|
| +void RenderWidgetHostViewAura::GetSelectionEndPoints(gfx::Rect* p1,
|
| + gfx::Rect* p2) {
|
| + *p1 = selection_anchor_rect_;
|
| + *p2 = selection_focus_rect_;
|
| +}
|
| +
|
| +gfx::Rect RenderWidgetHostViewAura::GetBounds() {
|
| + gfx::Rect bounds = GetViewBounds();
|
| + // We are supposed to return bounds in local coordinates, but GetViewBounds()
|
| + // gives bounds in screen space. So we convert.
|
| + gfx::Point origin = bounds.origin();
|
| + ConvertPointFromScreen(&origin);
|
| + bounds.set_origin(origin);
|
| + return bounds;
|
| +}
|
| +
|
| +gfx::NativeView RenderWidgetHostViewAura::GetNativeView() {
|
| + return window_->GetRootWindow();
|
| +}
|
| +
|
| +void RenderWidgetHostViewAura::ConvertPointToScreen(gfx::Point* point) {
|
| + aura::client::ScreenPositionClient* screen_position_client =
|
| + aura::client::GetScreenPositionClient(window_->GetRootWindow());
|
| + if (screen_position_client)
|
| + screen_position_client->ConvertPointToScreen(window_, point);
|
| +}
|
| +
|
| +void RenderWidgetHostViewAura::ConvertPointFromScreen(gfx::Point* point) {
|
| + aura::client::ScreenPositionClient* screen_position_client =
|
| + aura::client::GetScreenPositionClient(window_->GetRootWindow());
|
| + if (screen_position_client)
|
| + screen_position_client->ConvertPointFromScreen(window_, point);
|
| +}
|
| +
|
| +bool RenderWidgetHostViewAura::DrawsHandles() {
|
| + return true;
|
| +}
|
| +
|
| +void RenderWidgetHostViewAura::OpenContextMenu(const gfx::Point anchor) {
|
| + WebKit::WebMouseEvent mouse_event;
|
| + mouse_event.button = WebKit::WebMouseEvent::ButtonRight;
|
| + mouse_event.type = WebKit::WebInputEvent::MouseDown;
|
| + gfx::Point local_anchor = anchor;
|
| + ConvertPointFromScreen(&local_anchor);
|
| +
|
| + mouse_event.windowX = mouse_event.x = local_anchor.x();
|
| + mouse_event.windowY = mouse_event.y = local_anchor.y();
|
| + mouse_event.globalX = anchor.x();
|
| + mouse_event.globalY = anchor.y();
|
| + host_->ForwardMouseEvent(mouse_event);
|
| + touch_selection_controller_.reset();
|
| +}
|
| +
|
| +bool RenderWidgetHostViewAura::IsCommandIdChecked(int command_id) const {
|
| + NOTREACHED();
|
| + return false;
|
| +}
|
| +
|
| +bool RenderWidgetHostViewAura::IsCommandIdEnabled(int command_id) const {
|
| + bool editable = text_input_type_ != ui::TEXT_INPUT_TYPE_NONE;
|
| + bool has_selection = !selection_range_.is_empty();
|
| + string16 result;
|
| + switch (command_id) {
|
| + case IDS_APP_CUT:
|
| + return editable && has_selection;
|
| + case IDS_APP_COPY:
|
| + return has_selection;
|
| + case IDS_APP_PASTE:
|
| + ui::Clipboard::GetForCurrentThread()->ReadText(
|
| + ui::Clipboard::BUFFER_STANDARD, &result);
|
| + return editable && !result.empty();
|
| + case IDS_APP_DELETE:
|
| + return editable && has_selection;
|
| + case IDS_APP_SELECT_ALL:
|
| + return true;
|
| + default:
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +bool RenderWidgetHostViewAura::GetAcceleratorForCommandId(
|
| + int command_id,
|
| + ui::Accelerator* accelerator) {
|
| + return false;
|
| +}
|
| +
|
| +void RenderWidgetHostViewAura::ExecuteCommand(int command_id) {
|
| + switch (command_id) {
|
| + case IDS_APP_CUT:
|
| + host_->Cut();
|
| + break;
|
| + case IDS_APP_COPY:
|
| + host_->Copy();
|
| + break;
|
| + case IDS_APP_PASTE:
|
| + host_->Paste();
|
| + break;
|
| + case IDS_APP_DELETE:
|
| + host_->Delete();
|
| + break;
|
| + case IDS_APP_SELECT_ALL:
|
| + host_->SelectAll();
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| + }
|
| + touch_selection_controller_.reset();
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| // RenderWidgetHostViewAura, private:
|
|
|
| RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
|
|
|