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

Unified Diff: content/renderer/render_view.cc

Issue 7570001: Implement touch selection for RWHVV. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
« content/common/view_messages.h ('K') | « content/renderer/render_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view.cc
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index d5cedecc75361a1cc01d7992f845905efaf8d6a4..5112423a8b96e9ab72985118664635a098d562d1 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -360,7 +360,8 @@ RenderView::RenderView(RenderThreadBase* render_thread,
accessibility_ack_pending_(false),
p2p_socket_dispatcher_(NULL),
devtools_agent_(NULL),
- session_storage_namespace_id_(session_storage_namespace_id) {
+ session_storage_namespace_id_(session_storage_namespace_id),
+ selection_ack_pending_(false) {
routing_id_ = routing_id;
if (opener_id != MSG_ROUTING_NONE)
opener_id_ = opener_id;
@@ -613,6 +614,7 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace)
IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
+ IPC_MESSAGE_HANDLER(ViewMsg_SelectRect, OnSelectRect)
IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
@@ -978,6 +980,15 @@ void RenderView::OnSelectAll() {
WebString::fromUTF8("SelectAll"));
}
+void RenderView::OnSelectRect(const gfx::Point& start, const gfx::Point& end) {
+ if (!webview())
+ return;
+
+ selection_ack_pending_ = true;
+ webview()->focusedFrame()->selectRange(WebPoint(start.x(), start.y()),
sky 2011/08/03 17:38:29 What happens if this doesn't result in a selection
varunjain 2011/08/03 18:38:41 I think selectRange() knows whether selection has
varunjain 2011/08/03 19:55:46 nevermind my previous comment. I realized I can si
+ WebPoint(end.x(), end.y()));
+}
+
void RenderView::OnSetInitialFocus(bool reverse) {
if (!webview())
return;
@@ -1513,8 +1524,9 @@ bool RenderView::isSelectTrailingWhitespaceEnabled() {
void RenderView::didChangeSelection(bool is_empty_selection) {
#if defined(OS_POSIX)
- if (!handling_input_event_)
+ if (!handling_input_event_ && !selection_ack_pending_)
sky 2011/08/03 17:38:29 Can the selection change be initiated on the webki
varunjain 2011/08/03 18:38:41 As I understand, any selection change (whether ori
sky 2011/08/03 20:25:47 With this patch any change originating from webkit
return;
+ selection_ack_pending_ = false;
if (is_empty_selection) {
last_selection_.clear();
@@ -1535,7 +1547,22 @@ void RenderView::didChangeSelection(bool is_empty_selection) {
range.set_start(location);
range.set_end(location + length);
}
- Send(new ViewHostMsg_SelectionChanged(routing_id_, last_selection_, range));
+
+ WebKit::WebPoint start, end;
sky 2011/08/03 17:38:29 I'm not familiar enough with the webkit side to sa
varunjain 2011/08/03 18:38:41 added darin
+ webview()->selectionRange(start, end);
+
+ // Webkit gives an offset of 1 between start and end even if there is no
+ // selection. So we need to check against that.
+ // TODO(varunjain): remove this check once that is fixed.
+ gfx::Point p1, p2;
+ if (std::abs(start.x - end.x) > 1 || std::abs(start.y - end.y) > 1) {
+ gfx::Point scroll_offset = GetScrollOffset();
+ p1.SetPoint(start.x + scroll_offset.x(), start.y + scroll_offset.y());
+ p2.SetPoint(end.x + scroll_offset.x(), end.y + scroll_offset.y());
+ }
+ // TODO(varunjain): add other hooks for SelectionChanged.
+ Send(new ViewHostMsg_SelectionChanged(routing_id_, last_selection_, range,
+ p1, p2));
sky 2011/08/03 17:38:29 nit: indent one more space.
varunjain 2011/08/03 18:38:41 intent is to indent 4 spaces.. not align with the
#endif // defined(OS_POSIX)
}
« content/common/view_messages.h ('K') | « content/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698