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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 19 matching lines...) Expand all
30 #include "ui/aura/client/aura_constants.h" 30 #include "ui/aura/client/aura_constants.h"
31 #include "ui/aura/client/cursor_client.h" 31 #include "ui/aura/client/cursor_client.h"
32 #include "ui/aura/client/screen_position_client.h" 32 #include "ui/aura/client/screen_position_client.h"
33 #include "ui/aura/client/stacking_client.h" 33 #include "ui/aura/client/stacking_client.h"
34 #include "ui/aura/client/tooltip_client.h" 34 #include "ui/aura/client/tooltip_client.h"
35 #include "ui/aura/client/window_types.h" 35 #include "ui/aura/client/window_types.h"
36 #include "ui/aura/env.h" 36 #include "ui/aura/env.h"
37 #include "ui/aura/root_window.h" 37 #include "ui/aura/root_window.h"
38 #include "ui/aura/window.h" 38 #include "ui/aura/window.h"
39 #include "ui/aura/window_observer.h" 39 #include "ui/aura/window_observer.h"
40 #include "ui/base/clipboard/scoped_clipboard_writer.h"
40 #include "ui/base/events/event.h" 41 #include "ui/base/events/event.h"
41 #include "ui/base/gestures/gesture_recognizer.h" 42 #include "ui/base/gestures/gesture_recognizer.h"
42 #include "ui/base/hit_test.h" 43 #include "ui/base/hit_test.h"
43 #include "ui/base/ime/input_method.h" 44 #include "ui/base/ime/input_method.h"
44 #include "ui/base/ui_base_types.h" 45 #include "ui/base/ui_base_types.h"
45 #include "ui/compositor/compositor.h" 46 #include "ui/compositor/compositor.h"
46 #include "ui/compositor/layer.h" 47 #include "ui/compositor/layer.h"
47 #include "ui/gfx/canvas.h" 48 #include "ui/gfx/canvas.h"
48 #include "ui/gfx/display.h" 49 #include "ui/gfx/display.h"
49 #include "ui/gfx/screen.h" 50 #include "ui/gfx/screen.h"
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 delete window_; 519 delete window_;
519 } 520 }
520 521
521 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) { 522 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) {
522 tooltip_ = tooltip_text; 523 tooltip_ = tooltip_text;
523 aura::RootWindow* root_window = window_->GetRootWindow(); 524 aura::RootWindow* root_window = window_->GetRootWindow();
524 if (aura::client::GetTooltipClient(root_window)) 525 if (aura::client::GetTooltipClient(root_window))
525 aura::client::GetTooltipClient(root_window)->UpdateTooltip(window_); 526 aura::client::GetTooltipClient(root_window)->UpdateTooltip(window_);
526 } 527 }
527 528
529 void RenderWidgetHostViewAura::SelectionChanged(const string16& text,
530 size_t offset,
531 const ui::Range& range) {
532 RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
533
534 #if defined(USE_X11) && !defined(OS_CHROMEOS)
535 if (text.empty() || range.is_empty())
536 return;
537 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
538 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
539
540 DCHECK(pos + n <= text.length()) << "The text can not fully cover range.";
541 if (pos >= text.length()) {
542 NOTREACHED() << "The text can not cover range.";
543 return;
544 }
545
546 // Set the BUFFER_SELECTION to the ui::Clipboard.
547 ui::ScopedClipboardWriter clipboard_writer(
548 ui::Clipboard::GetForCurrentThread(),
549 ui::Clipboard::BUFFER_SELECTION);
550 clipboard_writer.WriteText(text);
551 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
552 }
553
528 void RenderWidgetHostViewAura::SelectionBoundsChanged( 554 void RenderWidgetHostViewAura::SelectionBoundsChanged(
529 const gfx::Rect& start_rect, 555 const gfx::Rect& start_rect,
530 WebKit::WebTextDirection start_direction, 556 WebKit::WebTextDirection start_direction,
531 const gfx::Rect& end_rect, 557 const gfx::Rect& end_rect,
532 WebKit::WebTextDirection end_direction) { 558 WebKit::WebTextDirection end_direction) {
533 if (selection_start_rect_ == start_rect && selection_end_rect_ == end_rect) 559 if (selection_start_rect_ == start_rect && selection_end_rect_ == end_rect)
534 return; 560 return;
535 561
536 selection_start_rect_ = start_rect; 562 selection_start_rect_ = start_rect;
537 selection_end_rect_ = end_rect; 563 selection_end_rect_ = end_rect;
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 RenderWidgetHost* widget) { 1782 RenderWidgetHost* widget) {
1757 return new RenderWidgetHostViewAura(widget); 1783 return new RenderWidgetHostViewAura(widget);
1758 } 1784 }
1759 1785
1760 // static 1786 // static
1761 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 1787 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
1762 GetScreenInfoForWindow(results, NULL); 1788 GetScreenInfoForWindow(results, NULL);
1763 } 1789 }
1764 1790
1765 } // namespace content 1791 } // namespace content
OLDNEW
« 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