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

Unified Diff: content/renderer/render_view.cc

Issue 6289009: [Mac] Implement the system dictionary popup by implementing NSTextInput methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Clang Created 9 years, 8 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/content_common.gypi ('k') | content/renderer/render_widget.cc » ('j') | 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 489ad2ba3077f6b1aad5ef8be03c7c9483dfa1d6..6c68dc7cd0546fede2bb13c755821e68537cf720 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -1432,25 +1432,27 @@ void RenderView::didChangeSelection(bool is_empty_selection) {
#if defined(OS_POSIX)
if (!handling_input_event_)
return;
- // TODO(estade): investigate incremental updates to the selection so that we
- // don't send the entire selection over IPC every time.
- if (!is_empty_selection) {
+
+ if (is_empty_selection) {
+ last_selection_.clear();
+ } else {
// Sometimes we get repeated didChangeSelection calls from webkit when
// the selection hasn't actually changed. We don't want to report these
// because it will cause us to continually claim the X clipboard.
- const std::string& this_selection =
- webview()->focusedFrame()->selectionAsText().utf8();
+ WebFrame* frame = webview()->focusedFrame();
+ const std::string& this_selection = frame->selectionAsText().utf8();
if (this_selection == last_selection_)
return;
-
- Send(new ViewHostMsg_SelectionChanged(routing_id_,
- this_selection));
last_selection_ = this_selection;
- } else {
- last_selection_.clear();
- Send(new ViewHostMsg_SelectionChanged(routing_id_,
- last_selection_));
}
+
+ ui::Range range(ui::Range::InvalidRange());
+ size_t location, length;
+ if (webview()->caretOrSelectionRange(&location, &length)) {
+ range.set_start(location);
+ range.set_end(location + length);
+ }
+ Send(new ViewHostMsg_SelectionChanged(routing_id_, last_selection_, range));
#endif // defined(OS_POSIX)
}
« no previous file with comments | « content/content_common.gypi ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698