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

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: Fixed java tests 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 OnCustomContextMenuAction) 1006 OnCustomContextMenuAction)
1007 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) 1007 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo)
1008 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) 1008 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo)
1009 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) 1009 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut)
1010 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) 1010 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy)
1011 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) 1011 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste)
1012 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) 1012 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
1013 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) 1013 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete)
1014 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) 1014 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll)
1015 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) 1015 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange)
1016 IPC_MESSAGE_HANDLER(InputMsg_AdjustSelectionByCharacterOffset,
1017 OnAdjustSelectionByCharacterOffset)
1016 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect) 1018 IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect)
1017 IPC_MESSAGE_HANDLER(InputMsg_MoveRangeSelectionExtent, 1019 IPC_MESSAGE_HANDLER(InputMsg_MoveRangeSelectionExtent,
1018 OnMoveRangeSelectionExtent) 1020 OnMoveRangeSelectionExtent)
1019 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) 1021 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace)
1020 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) 1022 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling)
1021 IPC_MESSAGE_HANDLER(InputMsg_ExtendSelectionAndDelete, 1023 IPC_MESSAGE_HANDLER(InputMsg_ExtendSelectionAndDelete,
1022 OnExtendSelectionAndDelete) 1024 OnExtendSelectionAndDelete)
1023 IPC_MESSAGE_HANDLER(InputMsg_SetCompositionFromExistingText, 1025 IPC_MESSAGE_HANDLER(InputMsg_SetCompositionFromExistingText,
1024 OnSetCompositionFromExistingText) 1026 OnSetCompositionFromExistingText)
1025 IPC_MESSAGE_HANDLER(InputMsg_ExecuteNoValueEditCommand, 1027 IPC_MESSAGE_HANDLER(InputMsg_ExecuteNoValueEditCommand,
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 1321
1320 void RenderFrameImpl::OnSelectRange(const gfx::Point& base, 1322 void RenderFrameImpl::OnSelectRange(const gfx::Point& base,
1321 const gfx::Point& extent) { 1323 const gfx::Point& extent) {
1322 // This IPC is dispatched by RenderWidgetHost, so use its routing id. 1324 // This IPC is dispatched by RenderWidgetHost, so use its routing id.
1323 Send(new InputHostMsg_SelectRange_ACK(GetRenderWidget()->routing_id())); 1325 Send(new InputHostMsg_SelectRange_ACK(GetRenderWidget()->routing_id()));
1324 1326
1325 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); 1327 base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
1326 frame_->selectRange(base, extent); 1328 frame_->selectRange(base, extent);
1327 } 1329 }
1328 1330
1331 void RenderFrameImpl::OnAdjustSelectionByCharacterOffset(int start_adjust,
1332 int end_adjust) {
1333 size_t start, length;
1334 if (!GetRenderWidget()->webwidget()->caretOrSelectionRange(
1335 &start, &length)) {
1336 return;
1337 }
1338
1339 // Sanity checks to disallow empty and out of range selections.
1340 if (start_adjust - end_adjust > static_cast<int>(length)
1341 || static_cast<int>(start) + start_adjust < 0) {
1342 return;
1343 }
1344
1345 // A negative adjust amount moves the selection towards the beginning of
1346 // the document, a positive amount moves the selection towards the end of
1347 // the document.
1348 start += start_adjust;
1349 length += end_adjust - start_adjust;
1350
1351 frame_->selectRange(WebRange::fromDocumentRange(frame_, start, length));
1352 }
1353
1329 void RenderFrameImpl::OnUnselect() { 1354 void RenderFrameImpl::OnUnselect() {
1330 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); 1355 base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
1331 frame_->executeCommand(WebString::fromUTF8("Unselect"), GetFocusedElement()); 1356 frame_->executeCommand(WebString::fromUTF8("Unselect"), GetFocusedElement());
1332 } 1357 }
1333 1358
1334 void RenderFrameImpl::OnMoveRangeSelectionExtent(const gfx::Point& point) { 1359 void RenderFrameImpl::OnMoveRangeSelectionExtent(const gfx::Point& point) {
1335 // This IPC is dispatched by RenderWidgetHost, so use its routing id. 1360 // This IPC is dispatched by RenderWidgetHost, so use its routing id.
1336 Send(new InputHostMsg_MoveRangeSelectionExtent_ACK( 1361 Send(new InputHostMsg_MoveRangeSelectionExtent_ACK(
1337 GetRenderWidget()->routing_id())); 1362 GetRenderWidget()->routing_id()));
1338 1363
(...skipping 3683 matching lines...) Expand 10 before | Expand all | Expand 10 after
5022 void RenderFrameImpl::RegisterMojoServices() { 5047 void RenderFrameImpl::RegisterMojoServices() {
5023 // Only main frame have ImageDownloader service. 5048 // Only main frame have ImageDownloader service.
5024 if (!frame_->parent()) { 5049 if (!frame_->parent()) {
5025 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( 5050 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>(
5026 base::Bind(&ImageDownloaderImpl::CreateMojoService, 5051 base::Bind(&ImageDownloaderImpl::CreateMojoService,
5027 base::Unretained(this))); 5052 base::Unretained(this)));
5028 } 5053 }
5029 } 5054 }
5030 5055
5031 } // namespace content 5056 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698