Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1205033005: Adds selection expansion support for Contextual Search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: palmer's comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 OnCustomContextMenuAction) 1001 OnCustomContextMenuAction)
1002 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) 1002 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo)
1003 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) 1003 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo)
1004 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) 1004 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut)
1005 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) 1005 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy)
1006 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) 1006 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste)
1007 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) 1007 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
1008 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) 1008 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete)
1009 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) 1009 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll)
1010 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) 1010 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange)
1011 IPC_MESSAGE_HANDLER(InputMsg_AdjustSelectionByCharacterOffset,
1012 OnAdjustSelectionByCharacterOffset)
1011 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect) 1013 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect)
1012 IPC_MESSAGE_HANDLER(InputMsg_MoveRangeSelectionExtent, 1014 IPC_MESSAGE_HANDLER(InputMsg_MoveRangeSelectionExtent,
1013 OnMoveRangeSelectionExtent) 1015 OnMoveRangeSelectionExtent)
1014 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) 1016 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace)
1015 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) 1017 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling)
1016 IPC_MESSAGE_HANDLER(InputMsg_ExtendSelectionAndDelete, 1018 IPC_MESSAGE_HANDLER(InputMsg_ExtendSelectionAndDelete,
1017 OnExtendSelectionAndDelete) 1019 OnExtendSelectionAndDelete)
1018 IPC_MESSAGE_HANDLER(InputMsg_SetCompositionFromExistingText, 1020 IPC_MESSAGE_HANDLER(InputMsg_SetCompositionFromExistingText,
1019 OnSetCompositionFromExistingText) 1021 OnSetCompositionFromExistingText)
1020 IPC_MESSAGE_HANDLER(InputMsg_ExecuteNoValueEditCommand, 1022 IPC_MESSAGE_HANDLER(InputMsg_ExecuteNoValueEditCommand,
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 1316
1315 void RenderFrameImpl::OnSelectRange(const gfx::Point& base, 1317 void RenderFrameImpl::OnSelectRange(const gfx::Point& base,
1316 const gfx::Point& extent) { 1318 const gfx::Point& extent) {
1317 // This IPC is dispatched by RenderWidgetHost, so use its routing id. 1319 // This IPC is dispatched by RenderWidgetHost, so use its routing id.
1318 Send(new InputHostMsg_SelectRange_ACK(GetRenderWidget()->routing_id())); 1320 Send(new InputHostMsg_SelectRange_ACK(GetRenderWidget()->routing_id()));
1319 1321
1320 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); 1322 base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
1321 frame_->selectRange(base, extent); 1323 frame_->selectRange(base, extent);
1322 } 1324 }
1323 1325
1326 void RenderFrameImpl::OnAdjustSelectionByCharacterOffset(int start_adjust,
1327 int end_adjust) {
1328 size_t start, length;
1329 if (!GetRenderWidget()->webwidget()->caretOrSelectionRange(
1330 &start, &length)) {
1331 return;
1332 }
1333
1334 // Sanity checks to disallow empty and out of range selections.
1335 if (start_adjust - end_adjust > static_cast<int>(length)
1336 || static_cast<int>(start) + start_adjust < 0) {
1337 return;
1338 }
1339
1340 // A negative adjust amount moves the selection towards the beginning of
1341 // the document, a positive amount moves the selection towards the end of
1342 // the document.
1343 start += start_adjust;
1344 length += end_adjust - start_adjust;
1345
1346 frame_->selectRange(WebRange::fromDocumentRange(frame_, start, length));
1347 }
1348
1324 void RenderFrameImpl::OnUnselect() { 1349 void RenderFrameImpl::OnUnselect() {
1325 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); 1350 base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
1326 frame_->executeCommand(WebString::fromUTF8("Unselect"), GetFocusedElement()); 1351 frame_->executeCommand(WebString::fromUTF8("Unselect"), GetFocusedElement());
1327 } 1352 }
1328 1353
1329 void RenderFrameImpl::OnMoveRangeSelectionExtent(const gfx::Point& point) { 1354 void RenderFrameImpl::OnMoveRangeSelectionExtent(const gfx::Point& point) {
1330 // This IPC is dispatched by RenderWidgetHost, so use its routing id. 1355 // This IPC is dispatched by RenderWidgetHost, so use its routing id.
1331 Send(new InputHostMsg_MoveRangeSelectionExtent_ACK( 1356 Send(new InputHostMsg_MoveRangeSelectionExtent_ACK(
1332 GetRenderWidget()->routing_id())); 1357 GetRenderWidget()->routing_id()));
1333 1358
(...skipping 3687 matching lines...) Expand 10 before | Expand all | Expand 10 after
5021 void RenderFrameImpl::RegisterMojoServices() { 5046 void RenderFrameImpl::RegisterMojoServices() {
5022 // Only main frame have ImageDownloader service. 5047 // Only main frame have ImageDownloader service.
5023 if (!frame_->parent()) { 5048 if (!frame_->parent()) {
5024 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( 5049 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>(
5025 base::Bind(&ImageDownloaderImpl::CreateMojoService, 5050 base::Bind(&ImageDownloaderImpl::CreateMojoService,
5026 base::Unretained(this))); 5051 base::Unretained(this)));
5027 } 5052 }
5028 } 5053 }
5029 5054
5030 } // namespace content 5055 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698