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

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: Added an interactive ui test 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 41724ead586ebe5c9461dbe00f581442d29d6601..ca74803a4f460c3f040054c2cf2b5d5b5761fabc 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,15 @@ void RenderWidgetHostViewBase::SelectionBoundsChanged(
void RenderWidgetHostViewBase::SelectionChanged(const base::string16& text,
size_t offset,
const gfx::Range& range) {
+#if defined(USE_AURA)
kenrb 2016/07/12 19:15:25 Shouldn't the SelectionChanged() override in Rende
EhsanK 2016/07/12 19:33:48 Yes, definitely. Sorry it was missing in this patc
+ 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 +144,16 @@ void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) {
}
base::string16 RenderWidgetHostViewBase::GetSelectedText() const {
+#if defined(USE_AURA)
+ return const_cast<RenderWidgetHostViewBase*>(this)
+ ->GetSelectedTextFromTextInputManager();
+#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() {
@@ -292,6 +305,20 @@ void RenderWidgetHostViewBase::FlushInput() {
impl->FlushInput();
}
+base::string16 RenderWidgetHostViewBase::GetSelectedTextFromTextInputManager() {
+ 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());
+}
+
void RenderWidgetHostViewBase::OnTextSurroundingSelectionResponse(
const base::string16& content,
size_t start_offset,

Powered by Google App Engine
This is Rietveld 408576698