OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) | 570 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) |
571 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) | 571 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) |
572 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) | 572 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) |
573 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) | 573 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) |
574 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) | 574 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) |
575 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) | 575 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) |
576 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) | 576 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) |
577 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) | 577 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) |
578 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) | 578 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) |
579 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect) | 579 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect) |
| 580 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) |
| 581 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) |
580 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) | 582 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) |
581 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, | 583 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, |
582 OnJavaScriptExecuteRequest) | 584 OnJavaScriptExecuteRequest) |
583 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets, | 585 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets, |
584 OnSetEditableSelectionOffsets) | 586 OnSetEditableSelectionOffsets) |
585 IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText, | 587 IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText, |
586 OnSetCompositionFromExistingText) | 588 OnSetCompositionFromExistingText) |
587 IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete, | 589 IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete, |
588 OnExtendSelectionAndDelete) | 590 OnExtendSelectionAndDelete) |
589 #if defined(OS_MACOSX) | 591 #if defined(OS_MACOSX) |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 | 988 |
987 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 989 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
988 frame_->selectRange(start, end); | 990 frame_->selectRange(start, end); |
989 } | 991 } |
990 | 992 |
991 void RenderFrameImpl::OnUnselect() { | 993 void RenderFrameImpl::OnUnselect() { |
992 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 994 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
993 frame_->executeCommand(WebString::fromUTF8("Unselect"), GetFocusedElement()); | 995 frame_->executeCommand(WebString::fromUTF8("Unselect"), GetFocusedElement()); |
994 } | 996 } |
995 | 997 |
| 998 void RenderFrameImpl::OnReplace(const base::string16& text) { |
| 999 if (!frame_->hasSelection()) |
| 1000 frame_->selectWordAroundCaret(); |
| 1001 |
| 1002 frame_->replaceSelection(text); |
| 1003 } |
| 1004 |
| 1005 void RenderFrameImpl::OnReplaceMisspelling(const base::string16& text) { |
| 1006 if (!frame_->hasSelection()) |
| 1007 return; |
| 1008 |
| 1009 frame_->replaceMisspelledRange(text); |
| 1010 } |
| 1011 |
996 void RenderFrameImpl::OnCSSInsertRequest(const std::string& css) { | 1012 void RenderFrameImpl::OnCSSInsertRequest(const std::string& css) { |
997 frame_->document().insertStyleSheet(WebString::fromUTF8(css)); | 1013 frame_->document().insertStyleSheet(WebString::fromUTF8(css)); |
998 } | 1014 } |
999 | 1015 |
1000 void RenderFrameImpl::OnJavaScriptExecuteRequest( | 1016 void RenderFrameImpl::OnJavaScriptExecuteRequest( |
1001 const base::string16& jscript, | 1017 const base::string16& jscript, |
1002 int id, | 1018 int id, |
1003 bool notify_result) { | 1019 bool notify_result) { |
1004 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequest", | 1020 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequest", |
1005 TRACE_EVENT_SCOPE_THREAD); | 1021 TRACE_EVENT_SCOPE_THREAD); |
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2965 selection_text_offset_ = offset; | 2981 selection_text_offset_ = offset; |
2966 selection_range_ = range; | 2982 selection_range_ = range; |
2967 // This IPC is dispatched by RenderWidetHost, so use its routing ID. | 2983 // This IPC is dispatched by RenderWidetHost, so use its routing ID. |
2968 Send(new ViewHostMsg_SelectionChanged( | 2984 Send(new ViewHostMsg_SelectionChanged( |
2969 GetRenderWidget()->routing_id(), text, offset, range)); | 2985 GetRenderWidget()->routing_id(), text, offset, range)); |
2970 } | 2986 } |
2971 GetRenderWidget()->UpdateSelectionBounds(); | 2987 GetRenderWidget()->UpdateSelectionBounds(); |
2972 } | 2988 } |
2973 | 2989 |
2974 } // namespace content | 2990 } // namespace content |
OLD | NEW |