| 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 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 OnCustomContextMenuAction) | 1002 OnCustomContextMenuAction) |
| 1003 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) | 1003 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) |
| 1004 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) | 1004 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) |
| 1005 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) | 1005 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) |
| 1006 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) | 1006 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) |
| 1007 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) | 1007 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) |
| 1008 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) | 1008 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) |
| 1009 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) | 1009 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) |
| 1010 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) | 1010 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) |
| 1011 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) | 1011 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) |
| 1012 IPC_MESSAGE_HANDLER(InputMsg_AdjustSelectionByCharacterOffset, |
| 1013 OnAdjustSelectionByCharacterOffset) |
| 1012 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect) | 1014 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect) |
| 1013 IPC_MESSAGE_HANDLER(InputMsg_MoveRangeSelectionExtent, | 1015 IPC_MESSAGE_HANDLER(InputMsg_MoveRangeSelectionExtent, |
| 1014 OnMoveRangeSelectionExtent) | 1016 OnMoveRangeSelectionExtent) |
| 1015 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) | 1017 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) |
| 1016 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) | 1018 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) |
| 1017 IPC_MESSAGE_HANDLER(InputMsg_ExtendSelectionAndDelete, | 1019 IPC_MESSAGE_HANDLER(InputMsg_ExtendSelectionAndDelete, |
| 1018 OnExtendSelectionAndDelete) | 1020 OnExtendSelectionAndDelete) |
| 1019 IPC_MESSAGE_HANDLER(InputMsg_SetCompositionFromExistingText, | 1021 IPC_MESSAGE_HANDLER(InputMsg_SetCompositionFromExistingText, |
| 1020 OnSetCompositionFromExistingText) | 1022 OnSetCompositionFromExistingText) |
| 1021 IPC_MESSAGE_HANDLER(InputMsg_ExecuteNoValueEditCommand, | 1023 IPC_MESSAGE_HANDLER(InputMsg_ExecuteNoValueEditCommand, |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 | 1320 |
| 1319 void RenderFrameImpl::OnSelectRange(const gfx::Point& base, | 1321 void RenderFrameImpl::OnSelectRange(const gfx::Point& base, |
| 1320 const gfx::Point& extent) { | 1322 const gfx::Point& extent) { |
| 1321 // This IPC is dispatched by RenderWidgetHost, so use its routing id. | 1323 // This IPC is dispatched by RenderWidgetHost, so use its routing id. |
| 1322 Send(new InputHostMsg_SelectRange_ACK(GetRenderWidget()->routing_id())); | 1324 Send(new InputHostMsg_SelectRange_ACK(GetRenderWidget()->routing_id())); |
| 1323 | 1325 |
| 1324 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 1326 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
| 1325 frame_->selectRange(base, extent); | 1327 frame_->selectRange(base, extent); |
| 1326 } | 1328 } |
| 1327 | 1329 |
| 1330 void RenderFrameImpl::OnAdjustSelectionByCharacterOffset(int start_adjust, |
| 1331 int end_adjust) { |
| 1332 size_t start, length; |
| 1333 if (!GetRenderWidget()->webwidget()->caretOrSelectionRange( |
| 1334 &start, &length)) { |
| 1335 return; |
| 1336 } |
| 1337 |
| 1338 // Sanity checks to disallow empty and out of range selections. |
| 1339 if (start_adjust - end_adjust < length || -start_adjust > start) { |
| 1340 return; |
| 1341 } |
| 1342 |
| 1343 // A negative adjust amount moves the selection towards the beginning of |
| 1344 // the document, a positive amount moves the selection towards the end of |
| 1345 // the document. |
| 1346 start += start_adjust; |
| 1347 length += end_adjust - start_adjust; |
| 1348 |
| 1349 frame_->selectRange(WebRange::fromDocumentRange(frame_, start, length)); |
| 1350 } |
| 1351 |
| 1328 void RenderFrameImpl::OnUnselect() { | 1352 void RenderFrameImpl::OnUnselect() { |
| 1329 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 1353 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
| 1330 frame_->executeCommand(WebString::fromUTF8("Unselect"), GetFocusedElement()); | 1354 frame_->executeCommand(WebString::fromUTF8("Unselect"), GetFocusedElement()); |
| 1331 } | 1355 } |
| 1332 | 1356 |
| 1333 void RenderFrameImpl::OnMoveRangeSelectionExtent(const gfx::Point& point) { | 1357 void RenderFrameImpl::OnMoveRangeSelectionExtent(const gfx::Point& point) { |
| 1334 // This IPC is dispatched by RenderWidgetHost, so use its routing id. | 1358 // This IPC is dispatched by RenderWidgetHost, so use its routing id. |
| 1335 Send(new InputHostMsg_MoveRangeSelectionExtent_ACK( | 1359 Send(new InputHostMsg_MoveRangeSelectionExtent_ACK( |
| 1336 GetRenderWidget()->routing_id())); | 1360 GetRenderWidget()->routing_id())); |
| 1337 | 1361 |
| (...skipping 3667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5005 void RenderFrameImpl::RegisterMojoServices() { | 5029 void RenderFrameImpl::RegisterMojoServices() { |
| 5006 // Only main frame have ImageDownloader service. | 5030 // Only main frame have ImageDownloader service. |
| 5007 if (!frame_->parent()) { | 5031 if (!frame_->parent()) { |
| 5008 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( | 5032 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( |
| 5009 base::Bind(&ImageDownloaderImpl::CreateMojoService, | 5033 base::Bind(&ImageDownloaderImpl::CreateMojoService, |
| 5010 base::Unretained(this))); | 5034 base::Unretained(this))); |
| 5011 } | 5035 } |
| 5012 } | 5036 } |
| 5013 | 5037 |
| 5014 } // namespace content | 5038 } // namespace content |
| OLD | NEW |