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

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

Issue 1205033005: Adds selection expansion support for Contextual Search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix expansions 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) 1350 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
1351 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) 1351 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu)
1352 // TODO(viettrungluu): Move to a separate message filter. 1352 // TODO(viettrungluu): Move to a separate message filter.
1353 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryOffsetAndLength, 1353 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryOffsetAndLength,
1354 OnSetHistoryOffsetAndLength) 1354 OnSetHistoryOffsetAndLength)
1355 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 1355 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
1356 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, 1356 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1357 OnReleaseDisambiguationPopupBitmap) 1357 OnReleaseDisambiguationPopupBitmap)
1358 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) 1358 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
1359 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) 1359 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
1360 IPC_MESSAGE_HANDLER(ViewMsg_ExpandSelectionByCharacterOffset,
1361 OnExpandSelectionByCharacterOffset)
1360 #if defined(OS_ANDROID) 1362 #if defined(OS_ANDROID)
1361 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, 1363 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult,
1362 OnActivateNearestFindResult) 1364 OnActivateNearestFindResult)
1363 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) 1365 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects)
1364 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, 1366 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState,
1365 OnUpdateTopControlsState) 1367 OnUpdateTopControlsState)
1366 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) 1368 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData)
1367 #elif defined(OS_MACOSX) 1369 #elif defined(OS_MACOSX)
1368 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, 1370 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText,
1369 OnGetRenderedText) 1371 OnGetRenderedText)
(...skipping 16 matching lines...) Expand all
1386 1388
1387 void RenderViewImpl::OnSelectWordAroundCaret() { 1389 void RenderViewImpl::OnSelectWordAroundCaret() {
1388 if (!webview()) 1390 if (!webview())
1389 return; 1391 return;
1390 1392
1391 handling_input_event_ = true; 1393 handling_input_event_ = true;
1392 webview()->focusedFrame()->selectWordAroundCaret(); 1394 webview()->focusedFrame()->selectWordAroundCaret();
1393 handling_input_event_ = false; 1395 handling_input_event_ = false;
1394 } 1396 }
1395 1397
1398 void RenderViewImpl::OnExpandSelectionByCharacterOffset(int start_adjust,
1399 int end_adjust) {
1400 if (!webview())
1401 return;
1402
1403 handling_input_event_ = true;
1404 size_t start, length;
1405 if (webview()->caretOrSelectionRange(&start, &length)) {
1406 start -= start_adjust;
1407 length += end_adjust + start_adjust;
1408 WebLocalFrame* web_local_frame =
1409 webview()->focusedFrame()->toWebLocalFrame();
pedro (no code reviews) 2015/07/01 22:18:57 Please confirm with someone familiar with the WebV
aurimas (slooooooooow) 2015/07/01 23:05:44 Do you have suggestions about who to ask to review
pedro (no code reviews) 2015/07/02 00:09:57 I would say yoichio@ since he is the one who sugge
1410 web_local_frame->selectRange(WebRange::fromDocumentRange(web_local_frame,
1411 start,
1412 length));
1413 }
1414 handling_input_event_ = false;
1415 }
1416
1396 void RenderViewImpl::OnCopyImageAt(int x, int y) { 1417 void RenderViewImpl::OnCopyImageAt(int x, int y) {
1397 webview()->copyImageAt(WebPoint(x, y)); 1418 webview()->copyImageAt(WebPoint(x, y));
1398 } 1419 }
1399 1420
1400 void RenderViewImpl::OnSaveImageAt(int x, int y) { 1421 void RenderViewImpl::OnSaveImageAt(int x, int y) {
1401 webview()->saveImageAt(WebPoint(x, y)); 1422 webview()->saveImageAt(WebPoint(x, y));
1402 } 1423 }
1403 1424
1404 void RenderViewImpl::OnUpdateTargetURLAck() { 1425 void RenderViewImpl::OnUpdateTargetURLAck() {
1405 // Check if there is a targeturl waiting to be sent. 1426 // Check if there is a targeturl waiting to be sent.
(...skipping 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after
3796 std::vector<gfx::Size> sizes; 3817 std::vector<gfx::Size> sizes;
3797 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 3818 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
3798 if (!url.isEmpty()) 3819 if (!url.isEmpty())
3799 urls.push_back( 3820 urls.push_back(
3800 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 3821 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
3801 } 3822 }
3802 SendUpdateFaviconURL(urls); 3823 SendUpdateFaviconURL(urls);
3803 } 3824 }
3804 3825
3805 } // namespace content 3826 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698