summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-18 21:20:54 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-18 21:20:54 +0000
commitd5d7b80087325be004284b7a77d0384f79093798 (patch)
treee33cdd1ee28a86a9c052f07cdd16fc7089a7aa51 /chrome
parentdd092159f3252df0afc3863ed052a417d1590d81 (diff)
downloadchromium_src-d5d7b80087325be004284b7a77d0384f79093798.zip
chromium_src-d5d7b80087325be004284b7a77d0384f79093798.tar.gz
chromium_src-d5d7b80087325be004284b7a77d0384f79093798.tar.bz2
Only send SelectionChanged events when the selection has actually changed.
Webkit's giving us too many respondToChangedSelection calls, so we keep claiming the X clipboard which messes with selection in other programs and the omnibox. http://crbug.com/11956 Review URL: http://codereview.chromium.org/115468 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/renderer/render_view.cc13
-rw-r--r--chrome/renderer/render_view.h3
2 files changed, 15 insertions, 1 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index d09b195..a8f8b5a 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2487,9 +2487,20 @@ void RenderView::SetTooltipText(WebView* webview,
void RenderView::DidChangeSelection(bool is_empty_selection) {
#if defined(OS_LINUX)
+ // 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) {
+ // 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()->GetFocusedFrame()->GetSelection(false);
+ if (this_selection == last_selection_)
+ return;
+
Send(new ViewHostMsg_SelectionChanged(routing_id_,
- webview()->GetFocusedFrame()->GetSelection(false)));
+ this_selection));
+ last_selection_ = this_selection;
}
#endif
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index ee03c7a..936adae 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -798,6 +798,9 @@ class RenderView : public RenderWidget,
// If true, we send IPC messages when the preferred width changes.
bool send_preferred_width_changes_;
+ // The text selection the last time DidChangeSelection got called.
+ std::string last_selection_;
+
DISALLOW_COPY_AND_ASSIGN(RenderView);
};