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

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

Issue 7584021: Revert 95698 - Implement touch selection for RWHVV. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_view.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "content/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 target_url_status_(TARGET_NONE), 354 target_url_status_(TARGET_NONE),
355 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), 355 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)),
356 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), 356 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)),
357 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), 357 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
358 geolocation_dispatcher_(NULL), 358 geolocation_dispatcher_(NULL),
359 speech_input_dispatcher_(NULL), 359 speech_input_dispatcher_(NULL),
360 device_orientation_dispatcher_(NULL), 360 device_orientation_dispatcher_(NULL),
361 accessibility_ack_pending_(false), 361 accessibility_ack_pending_(false),
362 p2p_socket_dispatcher_(NULL), 362 p2p_socket_dispatcher_(NULL),
363 devtools_agent_(NULL), 363 devtools_agent_(NULL),
364 session_storage_namespace_id_(session_storage_namespace_id), 364 session_storage_namespace_id_(session_storage_namespace_id) {
365 handling_select_range_(false) {
366 routing_id_ = routing_id; 365 routing_id_ = routing_id;
367 if (opener_id != MSG_ROUTING_NONE) 366 if (opener_id != MSG_ROUTING_NONE)
368 opener_id_ = opener_id; 367 opener_id_ = opener_id;
369 368
370 webwidget_ = WebView::create(this); 369 webwidget_ = WebView::create(this);
371 370
372 if (counter) { 371 if (counter) {
373 shared_popup_counter_ = counter; 372 shared_popup_counter_ = counter;
374 shared_popup_counter_->data++; 373 shared_popup_counter_->data++;
375 decrement_shared_popup_at_destruction_ = true; 374 decrement_shared_popup_at_destruction_ = true;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) 607 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo)
609 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) 608 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut)
610 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) 609 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy)
611 #if defined(OS_MACOSX) 610 #if defined(OS_MACOSX)
612 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) 611 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard)
613 #endif 612 #endif
614 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) 613 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste)
615 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) 614 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace)
616 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) 615 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
617 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) 616 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
618 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange)
619 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 617 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
620 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) 618 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
621 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 619 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
622 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) 620 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
623 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) 621 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck)
624 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 622 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
625 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) 623 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel)
626 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 624 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
627 OnSetZoomLevelForLoadingURL) 625 OnSetZoomLevelForLoadingURL)
628 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 626 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 } 972 }
975 973
976 void RenderView::OnSelectAll() { 974 void RenderView::OnSelectAll() {
977 if (!webview()) 975 if (!webview())
978 return; 976 return;
979 977
980 webview()->focusedFrame()->executeCommand( 978 webview()->focusedFrame()->executeCommand(
981 WebString::fromUTF8("SelectAll")); 979 WebString::fromUTF8("SelectAll"));
982 } 980 }
983 981
984 void RenderView::OnSelectRange(const gfx::Point& start, const gfx::Point& end) {
985 if (!webview())
986 return;
987
988 handling_select_range_ = true;
989 webview()->focusedFrame()->selectRange(start, end);
990 handling_select_range_ = false;
991 }
992
993 void RenderView::OnSetInitialFocus(bool reverse) { 982 void RenderView::OnSetInitialFocus(bool reverse) {
994 if (!webview()) 983 if (!webview())
995 return; 984 return;
996 webview()->setInitialFocus(reverse); 985 webview()->setInitialFocus(reverse);
997 } 986 }
998 987
999 #if defined(OS_MACOSX) 988 #if defined(OS_MACOSX)
1000 void RenderView::OnSetInLiveResize(bool in_live_resize) { 989 void RenderView::OnSetInLiveResize(bool in_live_resize) {
1001 if (!webview()) 990 if (!webview())
1002 return; 991 return;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 bool RenderView::isSelectTrailingWhitespaceEnabled() { 1508 bool RenderView::isSelectTrailingWhitespaceEnabled() {
1520 #if defined(OS_WIN) 1509 #if defined(OS_WIN)
1521 return true; 1510 return true;
1522 #else 1511 #else
1523 return false; 1512 return false;
1524 #endif 1513 #endif
1525 } 1514 }
1526 1515
1527 void RenderView::didChangeSelection(bool is_empty_selection) { 1516 void RenderView::didChangeSelection(bool is_empty_selection) {
1528 #if defined(OS_POSIX) 1517 #if defined(OS_POSIX)
1529 if (!handling_input_event_ && !handling_select_range_) 1518 if (!handling_input_event_)
1530 return; 1519 return;
1531 handling_select_range_ = false;
1532 1520
1533 if (is_empty_selection) { 1521 if (is_empty_selection) {
1534 last_selection_.clear(); 1522 last_selection_.clear();
1535 } else { 1523 } else {
1536 // Sometimes we get repeated didChangeSelection calls from webkit when 1524 // Sometimes we get repeated didChangeSelection calls from webkit when
1537 // the selection hasn't actually changed. We don't want to report these 1525 // the selection hasn't actually changed. We don't want to report these
1538 // because it will cause us to continually claim the X clipboard. 1526 // because it will cause us to continually claim the X clipboard.
1539 WebFrame* frame = webview()->focusedFrame(); 1527 WebFrame* frame = webview()->focusedFrame();
1540 const std::string& this_selection = frame->selectionAsText().utf8(); 1528 const std::string& this_selection = frame->selectionAsText().utf8();
1541 if (this_selection == last_selection_) 1529 if (this_selection == last_selection_)
1542 return; 1530 return;
1543 last_selection_ = this_selection; 1531 last_selection_ = this_selection;
1544 } 1532 }
1545 1533
1546 ui::Range range(ui::Range::InvalidRange()); 1534 ui::Range range(ui::Range::InvalidRange());
1547 size_t location, length; 1535 size_t location, length;
1548 if (webview()->caretOrSelectionRange(&location, &length)) { 1536 if (webview()->caretOrSelectionRange(&location, &length)) {
1549 range.set_start(location); 1537 range.set_start(location);
1550 range.set_end(location + length); 1538 range.set_end(location + length);
1551 } 1539 }
1552 1540 Send(new ViewHostMsg_SelectionChanged(routing_id_, last_selection_, range));
1553 WebKit::WebPoint start, end;
1554 webview()->selectionRange(start, end);
1555
1556 // Webkit gives an offset of 1 between start and end even if there is no
1557 // selection. So we need to check against that.
1558 // TODO(varunjain): remove this check once that is fixed.
1559 gfx::Point p1, p2;
1560 if (std::abs(start.x - end.x) > 1 || std::abs(start.y - end.y) > 1) {
1561 gfx::Point scroll_offset = GetScrollOffset();
1562 p1.SetPoint(start.x + scroll_offset.x(), start.y + scroll_offset.y());
1563 p2.SetPoint(end.x + scroll_offset.x(), end.y + scroll_offset.y());
1564 }
1565 // TODO(varunjain): add other hooks for SelectionChanged.
1566 Send(new ViewHostMsg_SelectionChanged(routing_id_, last_selection_, range,
1567 p1, p2));
1568 #endif // defined(OS_POSIX) 1541 #endif // defined(OS_POSIX)
1569 } 1542 }
1570 1543
1571 void RenderView::didExecuteCommand(const WebString& command_name) { 1544 void RenderView::didExecuteCommand(const WebString& command_name) {
1572 const std::string& name = UTF16ToUTF8(command_name); 1545 const std::string& name = UTF16ToUTF8(command_name);
1573 if (StartsWithASCII(name, "Move", true) || 1546 if (StartsWithASCII(name, "Move", true) ||
1574 StartsWithASCII(name, "Insert", true) || 1547 StartsWithASCII(name, "Insert", true) ||
1575 StartsWithASCII(name, "Delete", true)) 1548 StartsWithASCII(name, "Delete", true))
1576 return; 1549 return;
1577 RenderThread::current()->Send( 1550 RenderThread::current()->Send(
(...skipping 2884 matching lines...) Expand 10 before | Expand all | Expand 10 after
4462 } 4435 }
4463 #endif 4436 #endif
4464 4437
4465 void RenderView::OnContextMenuClosed( 4438 void RenderView::OnContextMenuClosed(
4466 const webkit_glue::CustomContextMenuContext& custom_context) { 4439 const webkit_glue::CustomContextMenuContext& custom_context) {
4467 if (custom_context.is_pepper_menu) 4440 if (custom_context.is_pepper_menu)
4468 pepper_delegate_.OnContextMenuClosed(custom_context); 4441 pepper_delegate_.OnContextMenuClosed(custom_context);
4469 else 4442 else
4470 context_menu_node_.reset(); 4443 context_menu_node_.reset();
4471 } 4444 }
OLDNEW
« no previous file with comments | « content/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698