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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 10917270: linux_aura: Make X11 selection buffers work on text in both direction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/browser/renderer_host/render_widget_host_view_aura.h ('k') | ui/base/clipboard/clipboard.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index a590fd7651d3557fdba3279b0a49084723275d96..b6816721a5615b20ade25162d986c87967c0666b 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -37,6 +37,7 @@
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
+#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/base/events/event.h"
#include "ui/base/gestures/gesture_recognizer.h"
#include "ui/base/hit_test.h"
@@ -525,6 +526,31 @@ void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) {
aura::client::GetTooltipClient(root_window)->UpdateTooltip(window_);
}
+void RenderWidgetHostViewAura::SelectionChanged(const string16& text,
+ size_t offset,
+ const ui::Range& range) {
+ RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
+
+#if defined(USE_X11) && !defined(OS_CHROMEOS)
+ if (text.empty() || range.is_empty())
+ return;
+ size_t pos = range.GetMin() - offset;
Daniel Erat 2012/09/14 18:33:15 is there any danger of negative overflow here?
Elliot Glaysher 2012/09/14 20:16:16 I believe so. This check was added by penghuang@ i
Daniel Erat 2012/09/14 20:38:17 sorry -- i meant, should there also be: if (off
+ size_t n = range.length();
Daniel Erat 2012/09/14 18:33:15 nit: you'll end up with the same number of lines b
+
+ DCHECK(pos + n <= text.length()) << "The text can not fully cover range.";
+ if (pos >= text.length()) {
+ NOTREACHED() << "The text can not cover range.";
+ return;
+ }
+
+ // Set the BUFFER_SELECTION to the ui::Clipboard.
+ ui::ScopedClipboardWriter clipboard_writer(
+ ui::Clipboard::GetForCurrentThread(),
+ ui::Clipboard::BUFFER_SELECTION);
+ clipboard_writer.WriteText(text);
+#endif // defined(USE_X11) && !defined(OS_CHROMEOS)
+}
+
void RenderWidgetHostViewAura::SelectionBoundsChanged(
const gfx::Rect& start_rect,
WebKit::WebTextDirection start_direction,
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | ui/base/clipboard/clipboard.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698