| Index: content/renderer/render_view_impl.cc
|
| diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
|
| index 6f1b764f5eaba05664aa4c254707fbb66d410ece..136fe6bd52fd004ec44e39a12c8a2377e55cec47 100644
|
| --- a/content/renderer/render_view_impl.cc
|
| +++ b/content/renderer/render_view_impl.cc
|
| @@ -35,6 +35,7 @@
|
| #include "content/common/fileapi/file_system_dispatcher.h"
|
| #include "content/common/fileapi/webfilesystem_callback_dispatcher.h"
|
| #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
|
| +#include "content/common/input_messages.h"
|
| #include "content/common/java_bridge_messages.h"
|
| #include "content/common/pepper_messages.h"
|
| #include "content/common/pepper_plugin_registry.h"
|
| @@ -1000,31 +1001,35 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
|
| bool handled = true;
|
| bool msg_is_ok = true;
|
| IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok)
|
| + IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy)
|
| + IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut)
|
| + IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete)
|
| + IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand)
|
| + IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret)
|
| + IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste)
|
| + IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
|
| + IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo)
|
| + IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace)
|
| + IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling)
|
| + IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect,
|
| + OnScrollFocusedEditableNodeIntoRect)
|
| + IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll)
|
| + IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange)
|
| + IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent,
|
| + OnSetEditCommandsForNextKeyEvent)
|
| + IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo)
|
| + IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect)
|
| IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate)
|
| IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop)
|
| IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_ReplaceMisspelling, OnReplaceMisspelling)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
|
| IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_Unselect, OnUnselect)
|
| IPC_MESSAGE_HANDLER(ViewMsg_SetEditableSelectionOffsets,
|
| OnSetEditableSelectionOffsets)
|
| IPC_MESSAGE_HANDLER(ViewMsg_SetCompositionFromExistingText,
|
| OnSetCompositionFromExistingText)
|
| IPC_MESSAGE_HANDLER(ViewMsg_ExtendSelectionAndDelete,
|
| OnExtendSelectionAndDelete)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_MoveCaret, OnMoveCaret)
|
| IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
|
| IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
|
| IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
|
| IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
|
| @@ -1047,8 +1052,6 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
|
| OnDragSourceSystemDragEnded)
|
| IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings)
|
| IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect,
|
| - OnScrollFocusedEditableNodeIntoRect)
|
| IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck)
|
| IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
|
| IPC_MESSAGE_HANDLER(ViewMsg_TimezoneChange, OnUpdateTimezone)
|
| @@ -1077,8 +1080,6 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
|
| OnOrientationChangeEvent)
|
| IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt)
|
| IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent,
|
| - OnSetEditCommandsForNextKeyEvent)
|
| IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction,
|
| OnCustomContextMenuAction)
|
| IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened)
|
| @@ -1101,7 +1102,7 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
|
| IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode)
|
| IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener)
|
| #if defined(OS_ANDROID)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_ActivateNearestFindResult,
|
| + IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult,
|
| OnActivateNearestFindResult)
|
| IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects)
|
| IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems)
|
| @@ -1110,7 +1111,7 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
|
| IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState,
|
| OnUpdateTopControlsState)
|
| #elif defined(OS_MACOSX)
|
| - IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard)
|
| + IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
|
| IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted,
|
| OnPluginImeCompositionCompleted)
|
| IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
|
| @@ -1360,15 +1361,6 @@ void RenderViewImpl::OnCopyImageAt(int x, int y) {
|
| webview()->copyImageAt(WebPoint(x, y));
|
| }
|
|
|
| -void RenderViewImpl::OnExecuteEditCommand(const std::string& name,
|
| - const std::string& value) {
|
| - if (!webview() || !webview()->focusedFrame())
|
| - return;
|
| -
|
| - webview()->focusedFrame()->executeCommand(
|
| - WebString::fromUTF8(name), WebString::fromUTF8(value));
|
| -}
|
| -
|
| void RenderViewImpl::OnUpdateTargetURLAck() {
|
| // Check if there is a targeturl waiting to be sent.
|
| if (target_url_status_ == TARGET_PENDING) {
|
| @@ -1379,52 +1371,47 @@ void RenderViewImpl::OnUpdateTargetURLAck() {
|
| target_url_status_ = TARGET_NONE;
|
| }
|
|
|
| -void RenderViewImpl::OnUndo() {
|
| +void RenderViewImpl::OnCopy() {
|
| if (!webview())
|
| return;
|
|
|
| - webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Undo"));
|
| + base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
|
| + webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy"),
|
| + context_menu_node_);
|
| }
|
|
|
| -void RenderViewImpl::OnRedo() {
|
| +void RenderViewImpl::OnCut() {
|
| if (!webview())
|
| return;
|
|
|
| - webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Redo"));
|
| + base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
|
| + webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut"));
|
| }
|
|
|
| -void RenderViewImpl::OnCut() {
|
| +void RenderViewImpl::OnDelete() {
|
| if (!webview())
|
| return;
|
|
|
| - base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
|
| - webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut"));
|
| + webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete"));
|
| }
|
|
|
| -void RenderViewImpl::OnCopy() {
|
| - if (!webview())
|
| +void RenderViewImpl::OnExecuteEditCommand(const std::string& name,
|
| + const std::string& value) {
|
| + if (!webview() || !webview()->focusedFrame())
|
| return;
|
|
|
| - base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
|
| - webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy"),
|
| - context_menu_node_);
|
| + webview()->focusedFrame()->executeCommand(
|
| + WebString::fromUTF8(name), WebString::fromUTF8(value));
|
| }
|
|
|
| -#if defined(OS_MACOSX)
|
| -void RenderViewImpl::OnCopyToFindPboard() {
|
| +void RenderViewImpl::OnMoveCaret(const gfx::Point& point) {
|
| if (!webview())
|
| return;
|
|
|
| - // Since the find pasteboard supports only plain text, this can be simpler
|
| - // than the |OnCopy()| case.
|
| - WebFrame* frame = webview()->focusedFrame();
|
| - if (frame->hasSelection()) {
|
| - string16 selection = frame->selectionAsText();
|
| - RenderThread::Get()->Send(
|
| - new ClipboardHostMsg_FindPboardWriteStringAsync(selection));
|
| - }
|
| + Send(new ViewHostMsg_MoveCaret_ACK(routing_id_));
|
| +
|
| + webview()->focusedFrame()->moveCaretSelectionTowardsWindowPoint(point);
|
| }
|
| -#endif
|
|
|
| void RenderViewImpl::OnPaste() {
|
| if (!webview())
|
| @@ -1443,6 +1430,13 @@ void RenderViewImpl::OnPasteAndMatchStyle() {
|
| WebString::fromUTF8("PasteAndMatchStyle"));
|
| }
|
|
|
| +void RenderViewImpl::OnRedo() {
|
| + if (!webview())
|
| + return;
|
| +
|
| + webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Redo"));
|
| +}
|
| +
|
| void RenderViewImpl::OnReplace(const string16& text) {
|
| if (!webview())
|
| return;
|
| @@ -1465,27 +1459,47 @@ void RenderViewImpl::OnReplaceMisspelling(const string16& text) {
|
| frame->replaceMisspelledRange(text);
|
| }
|
|
|
| -void RenderViewImpl::OnDelete() {
|
| +void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect(
|
| + const gfx::Rect& rect) {
|
| + WebKit::WebNode node = GetFocusedNode();
|
| + if (!node.isNull()) {
|
| + if (IsEditableNode(node)) {
|
| + webview()->saveScrollAndScaleState();
|
| + webview()->scrollFocusedNodeIntoRect(rect);
|
| + }
|
| + }
|
| +}
|
| +
|
| +void RenderViewImpl::OnSelectAll() {
|
| if (!webview())
|
| return;
|
|
|
| - webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete"));
|
| + base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
|
| + webview()->focusedFrame()->executeCommand(
|
| + WebString::fromUTF8("SelectAll"));
|
| }
|
|
|
| -void RenderViewImpl::OnSetName(const std::string& name) {
|
| +void RenderViewImpl::OnSelectRange(const gfx::Point& start,
|
| + const gfx::Point& end) {
|
| if (!webview())
|
| return;
|
|
|
| - webview()->mainFrame()->setName(WebString::fromUTF8(name));
|
| + Send(new ViewHostMsg_SelectRange_ACK(routing_id_));
|
| +
|
| + base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
|
| + webview()->focusedFrame()->selectRange(start, end);
|
| }
|
|
|
| -void RenderViewImpl::OnSelectAll() {
|
| +void RenderViewImpl::OnSetEditCommandsForNextKeyEvent(
|
| + const EditCommands& edit_commands) {
|
| + edit_commands_ = edit_commands;
|
| +}
|
| +
|
| +void RenderViewImpl::OnUndo() {
|
| if (!webview())
|
| return;
|
|
|
| - base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
|
| - webview()->focusedFrame()->executeCommand(
|
| - WebString::fromUTF8("SelectAll"));
|
| + webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Undo"));
|
| }
|
|
|
| void RenderViewImpl::OnUnselect() {
|
| @@ -1496,6 +1510,29 @@ void RenderViewImpl::OnUnselect() {
|
| webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect"));
|
| }
|
|
|
| +#if defined(OS_MACOSX)
|
| +void RenderViewImpl::OnCopyToFindPboard() {
|
| + if (!webview())
|
| + return;
|
| +
|
| + // Since the find pasteboard supports only plain text, this can be simpler
|
| + // than the |OnCopy()| case.
|
| + WebFrame* frame = webview()->focusedFrame();
|
| + if (frame->hasSelection()) {
|
| + string16 selection = frame->selectionAsText();
|
| + RenderThread::Get()->Send(
|
| + new ClipboardHostMsg_FindPboardWriteStringAsync(selection));
|
| + }
|
| +}
|
| +#endif
|
| +
|
| +void RenderViewImpl::OnSetName(const std::string& name) {
|
| + if (!webview())
|
| + return;
|
| +
|
| + webview()->mainFrame()->setName(WebString::fromUTF8(name));
|
| +}
|
| +
|
| void RenderViewImpl::OnSetEditableSelectionOffsets(int start, int end) {
|
| base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
|
| DCHECK(!handling_ime_event_);
|
| @@ -1527,26 +1564,6 @@ void RenderViewImpl::OnExtendSelectionAndDelete(int before, int after) {
|
| UpdateTextInputState(DO_NOT_SHOW_IME);
|
| }
|
|
|
| -void RenderViewImpl::OnSelectRange(const gfx::Point& start,
|
| - const gfx::Point& end) {
|
| - if (!webview())
|
| - return;
|
| -
|
| - Send(new ViewHostMsg_SelectRange_ACK(routing_id_));
|
| -
|
| - base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
|
| - webview()->focusedFrame()->selectRange(start, end);
|
| -}
|
| -
|
| -void RenderViewImpl::OnMoveCaret(const gfx::Point& point) {
|
| - if (!webview())
|
| - return;
|
| -
|
| - Send(new ViewHostMsg_MoveCaret_ACK(routing_id_));
|
| -
|
| - webview()->focusedFrame()->moveCaretSelectionTowardsWindowPoint(point);
|
| -}
|
| -
|
| void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length,
|
| int32 minimum_page_id) {
|
| DCHECK_GE(history_length, 0);
|
| @@ -1585,17 +1602,6 @@ void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) {
|
| }
|
| #endif
|
|
|
| -void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect(
|
| - const gfx::Rect& rect) {
|
| - WebKit::WebNode node = GetFocusedNode();
|
| - if (!node.isNull()) {
|
| - if (IsEditableNode(node)) {
|
| - webview()->saveScrollAndScaleState();
|
| - webview()->scrollFocusedNodeIntoRect(rect);
|
| - }
|
| - }
|
| -}
|
| -
|
| #if defined(OS_ANDROID)
|
| void RenderViewImpl::OnUndoScrollFocusedEditableNodeIntoRect() {
|
| const WebNode node = GetFocusedNode();
|
| @@ -5708,11 +5714,6 @@ void RenderViewImpl::OnPluginImeCompositionCompleted(const string16& text,
|
| }
|
| #endif // OS_MACOSX
|
|
|
| -void RenderViewImpl::OnSetEditCommandsForNextKeyEvent(
|
| - const EditCommands& edit_commands) {
|
| - edit_commands_ = edit_commands;
|
| -}
|
| -
|
| void RenderViewImpl::Close() {
|
| // We need to grab a pointer to the doomed WebView before we destroy it.
|
| WebView* doomed = webview();
|
|
|