Index: content/browser/renderer_host/render_widget_host_view_base.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc |
index 8b8907e262a95b8790a6b404c8ed0ccef5bc2a1e..61d4a8685b2278b5219e992b7cad078b37a71dfe 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_base.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_base.cc |
@@ -36,14 +36,17 @@ RenderWidgetHostViewBase::RenderWidgetHostViewBase() |
background_color_(SK_ColorWHITE), |
mouse_locked_(false), |
showing_context_menu_(false), |
+#if !defined(USE_AURA) |
selection_text_offset_(0), |
selection_range_(gfx::Range::InvalidRange()), |
+#endif |
current_device_scale_factor_(0), |
current_display_rotation_(display::Display::ROTATE_0), |
pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), |
text_input_manager_(nullptr), |
renderer_frame_number_(0), |
- weak_factory_(this) {} |
+ weak_factory_(this) { |
+} |
RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { |
DCHECK(!mouse_locked_); |
@@ -111,10 +114,18 @@ void RenderWidgetHostViewBase::SelectionBoundsChanged( |
void RenderWidgetHostViewBase::SelectionChanged(const base::string16& text, |
size_t offset, |
const gfx::Range& range) { |
+// TODO(ekaramad): Use TextInputManager code paths for IME on other platforms. |
+// Also, remove the following local variables when that happens |
+// (https://crbug.com/578168 and https://crbug.com/602427). |
+#if defined(USE_AURA) |
+ if (GetTextInputManager()) |
+ GetTextInputManager()->SelectionChanged(this, text, offset, range); |
+#else |
selection_text_ = text; |
selection_text_offset_ = offset; |
selection_range_.set_start(range.start()); |
selection_range_.set_end(range.end()); |
+#endif |
} |
gfx::Size RenderWidgetHostViewBase::GetRequestedRendererSize() const { |
@@ -136,11 +147,28 @@ void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { |
} |
base::string16 RenderWidgetHostViewBase::GetSelectedText() { |
+// TODO(ekaramad): Use TextInputManager code paths for IME onother platforms. |
Charlie Reis
2016/07/20 23:00:30
nit: on other
EhsanK
2016/07/21 16:52:55
Done. Thanks!
|
+// Also, remove the following local variables when that happens |
+// (https://crbug.com/578168 and https://crbug.com/602427). |
+#if defined(USE_AURA) |
+ if (!GetTextInputManager()) |
+ return base::string16(); |
+ |
+ const TextInputManager::TextSelection* selection = |
+ GetTextInputManager()->GetTextSelection(this); |
+ |
+ if (!selection || !selection->range.IsValid()) |
+ return base::string16(); |
+ |
+ return selection->text.substr(selection->range.GetMin() - selection->offset, |
+ selection->range.length()); |
+#else |
if (!selection_range_.IsValid()) |
return base::string16(); |
return selection_text_.substr( |
selection_range_.GetMin() - selection_text_offset_, |
selection_range_.length()); |
+#endif |
} |
bool RenderWidgetHostViewBase::IsMouseLocked() { |