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

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

Issue 2130133004: Tracking text selection on the browser side in OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize/Clear TextSelection for each view + make GetTextSelection() const. Created 4 years, 5 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
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 b9bcafc640e9a105f1cd93d2b6e7129760df01cb..7717ba6fcdc7520a03048f93c1b9d7be832d2c0e 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 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())
+ 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() {
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_base.h ('k') | content/browser/renderer_host/text_input_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698