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

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

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/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 7f50d089887d2555c85fd5e32562c2e2eb96d9a9..b09ae5069420f5c96af8b022c118a5a5e52fc008 100644
--- a/content/browser/renderer_host/text_input_manager.h
+++ b/content/browser/renderer_host/text_input_manager.h
@@ -9,17 +9,15 @@
#include <utility>
#include "base/observer_list.h"
+#include "base/strings/string16.h"
#include "content/common/content_export.h"
#include "content/common/text_input_state.h"
#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/range/range.h"
#include "ui/gfx/selection_bound.h"
struct ViewHostMsg_SelectionBounds_Params;
-namespace gfx {
-class Range;
-}
-
namespace content {
class RenderWidgetHostImpl;
@@ -58,6 +56,27 @@ class CONTENT_EXPORT TextInputManager {
virtual void OnImeCompositionRangeChanged(
TextInputManager* text_input_manager,
RenderWidgetHostViewBase* updated_view) {}
+ // Called when the text selection for the |updated_view_| has changed.
+ virtual void OnTextSelectionChanged(
+ TextInputManager* text_input_manager,
+ RenderWidgetHostViewBase* updated_view) {}
+ };
+
+ // This struct is used to store text selection related information for views.
+ struct TextSelection {
+ TextSelection();
+ TextSelection(const TextSelection& other);
+ ~TextSelection();
+
+ // The offset of the text stored in |text| relative to the start of the web
+ // page.
+ size_t offset;
+
+ // The current selection range relative to the start of the web page.
+ gfx::Range range;
+
+ // The text inside and around the current selection range.
+ base::string16 text;
};
TextInputManager();
@@ -84,6 +103,12 @@ class CONTENT_EXPORT TextInputManager {
// Returns a vector of rects representing the character bounds.
const std::vector<gfx::Rect>* GetCompositionCharacterBounds() const;
+ // The following method returns the text selection state for the given |view|.
+ // If |view| == nullptr, it will assume |active_view_| and return its state.
+ // In the case of |active_view_| == nullptr, the method will return nullptr.
+ const TextSelection* GetTextSelection(
+ RenderWidgetHostViewBase* view = nullptr) const;
+
// ---------------------------------------------------------------------------
// The following methods are called by RWHVs on the tab to update their IME-
// related state.
@@ -108,6 +133,12 @@ class CONTENT_EXPORT TextInputManager {
const gfx::Range& range,
const std::vector<gfx::Rect>& character_bounds);
+ // Updates the new text selection information for the |view|.
+ void SelectionChanged(RenderWidgetHostViewBase* view,
+ const base::string16& text,
+ size_t offset,
+ const gfx::Range& range);
+
// 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
// that of a child frame). The |view| must unregister itself before being
@@ -177,6 +208,7 @@ class CONTENT_EXPORT TextInputManager {
ViewMap<TextInputState> text_input_state_map_;
ViewMap<SelectionRegion> selection_region_map_;
ViewMap<CompositionRangeInfo> composition_range_info_map_;
+ ViewMap<TextSelection> text_selection_map_;
base::ObserverList<Observer> observer_list_;
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_base.cc ('k') | content/browser/renderer_host/text_input_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698