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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.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_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 7940896835bfe89771a903f186ec65da81513879..cc28907d6297fb798c6fac1384a37c20a3003b8e 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -1544,8 +1544,16 @@ bool RenderWidgetHostViewAura::HasCompositionText() const {
}
bool RenderWidgetHostViewAura::GetTextRange(gfx::Range* range) const {
- range->set_start(selection_text_offset_);
- range->set_end(selection_text_offset_ + selection_text_.length());
+ if (!text_input_manager_)
+ return false;
+
+ const TextInputManager::TextSelection* selection =
+ text_input_manager_->GetTextSelection();
+ if (!selection)
+ return false;
+
+ range->set_start(selection->offset);
+ range->set_end(selection->offset + selection->text.length());
return true;
}
@@ -1557,8 +1565,16 @@ bool RenderWidgetHostViewAura::GetCompositionTextRange(
}
bool RenderWidgetHostViewAura::GetSelectionRange(gfx::Range* range) const {
- range->set_start(selection_range_.start());
- range->set_end(selection_range_.end());
+ if (!text_input_manager_)
+ return false;
+
+ const TextInputManager::TextSelection* selection =
+ text_input_manager_->GetTextSelection();
+ if (!selection)
+ return false;
+
+ range->set_start(selection->range.start());
+ range->set_end(selection->range.end());
return true;
}
@@ -1577,8 +1593,16 @@ bool RenderWidgetHostViewAura::DeleteRange(const gfx::Range& range) {
bool RenderWidgetHostViewAura::GetTextFromRange(
const gfx::Range& range,
base::string16* text) const {
- gfx::Range selection_text_range(selection_text_offset_,
- selection_text_offset_ + selection_text_.length());
+ if (!text_input_manager_)
+ return false;
+
+ const TextInputManager::TextSelection* selection =
+ text_input_manager_->GetTextSelection();
+ if (!selection)
+ return false;
+
+ gfx::Range selection_text_range(selection->offset,
+ selection->offset + selection->text.length());
if (!selection_text_range.Contains(range)) {
text->clear();
@@ -1586,11 +1610,10 @@ bool RenderWidgetHostViewAura::GetTextFromRange(
}
if (selection_text_range.EqualsIgnoringDirection(range)) {
// Avoid calling substr whose performance is low.
- *text = selection_text_;
+ *text = selection->text;
} else {
- *text = selection_text_.substr(
- range.GetMin() - selection_text_offset_,
- range.length());
+ *text = selection->text.substr(range.GetMin() - selection->offset,
+ range.length());
}
return true;
}

Powered by Google App Engine
This is Rietveld 408576698