Chromium Code Reviews| 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, |