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

Unified Diff: content/browser/renderer_host/text_input_manager.h

Issue 2903833002: Reland: Update TextSelection for non-user initiated events
Patch Set: Add test for JS cursor movement Created 3 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/text_input_manager.h
diff --git a/content/browser/renderer_host/text_input_manager.h b/content/browser/renderer_host/text_input_manager.h
index b4cbcaec304d476ef5303f8c8a456639310e0919..55cc46caf8856d680e8086e916cacc0c506f34eb 100644
--- a/content/browser/renderer_host/text_input_manager.h
+++ b/content/browser/renderer_host/text_input_manager.h
@@ -105,20 +105,22 @@ class CONTENT_EXPORT TextInputManager {
void SetSelection(const base::string16& text,
size_t offset,
- const gfx::Range& range);
+ const gfx::Range& range,
+ bool user_initiated);
const base::string16& selected_text() const { return selected_text_; }
size_t offset() const { return offset_; }
const gfx::Range& range() const { return range_; }
const base::string16& text() const { return text_; }
+ bool user_initiated() const { return user_initiated_; }
private:
// The offset of the text stored in |text| relative to the start of the web
// page.
- size_t offset_;
+ size_t offset_ = 0;
// The range of the selection in the page (highlighted text).
- gfx::Range range_;
+ gfx::Range range_ = gfx::Range::InvalidRange();
// The highlighted text which is the portion of |text_| marked by |offset_|
// and |range_|. It will be an empty string if either |text_| or |range_|
@@ -129,6 +131,9 @@ class CONTENT_EXPORT TextInputManager {
// Part of the text on the page which includes the highlighted text plus
// possibly several characters before and after it.
base::string16 text_;
+
+ // True if text selection is triggered by user input.
+ bool user_initiated_ = false;
};
TextInputManager();
@@ -194,7 +199,8 @@ class CONTENT_EXPORT TextInputManager {
void SelectionChanged(RenderWidgetHostViewBase* view,
const base::string16& text,
size_t offset,
- const gfx::Range& range);
+ const gfx::Range& range,
+ bool user_initiated);
// Registers the given |view| for tracking its TextInputState. This is called
// by any view which has updates in its TextInputState (whether tab's RWHV or

Powered by Google App Engine
This is Rietveld 408576698