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

Unified Diff: content/renderer/render_view.cc

Issue 7528009: This is the exact same CL as in http://codereview.chromium.org/7570001 . (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « 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 a0bea3caca4c6b27dad46e9e4b4ab199b4c6168f..972349f99357ff3f7c6cac7319e352f3c04c2599 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -361,7 +361,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),
+ handling_select_range_(false) {
routing_id_ = routing_id;
if (opener_id != MSG_ROUTING_NONE)
opener_id_ = opener_id;
@@ -614,6 +615,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_SelectRange, OnSelectRange)
IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
@@ -979,6 +981,15 @@ void RenderView::OnSelectAll() {
WebString::fromUTF8("SelectAll"));
}
+void RenderView::OnSelectRange(const gfx::Point& start, const gfx::Point& end) {
+ if (!webview())
+ return;
+
+ handling_select_range_ = true;
+ webview()->focusedFrame()->selectRange(start, end);
+ handling_select_range_ = false;
+}
+
void RenderView::OnSetInitialFocus(bool reverse) {
if (!webview())
return;
@@ -1515,8 +1526,9 @@ bool RenderView::isSelectTrailingWhitespaceEnabled() {
void RenderView::didChangeSelection(bool is_empty_selection) {
#if defined(OS_POSIX)
- if (!handling_input_event_)
+ if (!handling_input_event_ && !handling_select_range_)
return;
+ handling_select_range_ = false;
if (is_empty_selection) {
last_selection_.clear();
@@ -1537,7 +1549,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;
+ 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));
#endif // defined(OS_POSIX)
}
« 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