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

Side by Side Diff: content/browser/renderer_host/text_input_manager.h

Issue 2213503002: Tracking SelectionBounds for all RenderWidgets on the Browser Side (Mac) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a crash Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__
6 #define CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ 6 #define CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__
7 7
8 #include <unordered_map> 8 #include <unordered_map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // The following methods can be used to obtain information about IME-related 90 // The following methods can be used to obtain information about IME-related
91 // state for the active RenderWidgetHost. If the active widget is nullptr, the 91 // state for the active RenderWidgetHost. If the active widget is nullptr, the
92 // methods below will return nullptr as well. 92 // methods below will return nullptr as well.
93 // Users of these methods should not hold on to the pointers as they become 93 // Users of these methods should not hold on to the pointers as they become
94 // dangling if the TextInputManager or |active_view_| are destroyed. 94 // dangling if the TextInputManager or |active_view_| are destroyed.
95 95
96 // Returns the currently stored TextInputState. An state of nullptr can be 96 // Returns the currently stored TextInputState. An state of nullptr can be
97 // interpreted as a ui::TextInputType of ui::TEXT_INPUT_TYPE_NONE. 97 // interpreted as a ui::TextInputType of ui::TEXT_INPUT_TYPE_NONE.
98 const TextInputState* GetTextInputState() const; 98 const TextInputState* GetTextInputState() const;
99 99
100 // Returns the rect between selection bounds.
101 gfx::Rect GetSelectionBoundsRect() const;
102
103 // Returns a vector of rects representing the character bounds. 100 // Returns a vector of rects representing the character bounds.
104 const std::vector<gfx::Rect>* GetCompositionCharacterBounds() const; 101 const std::vector<gfx::Rect>* GetCompositionCharacterBounds() const;
105 102
106 // The following method returns the text selection state for the given |view|. 103 // The following method returns the text selection state for the given |view|.
107 // If |view| == nullptr, it will assume |active_view_| and return its state. 104 // If |view| == nullptr, it will assume |active_view_| and return its state.
108 // In the case of |active_view_| == nullptr, the method will return nullptr. 105 // In the case of |active_view_| == nullptr, the method will return nullptr.
109 const TextSelection* GetTextSelection( 106 const TextSelection* GetTextSelection(
110 RenderWidgetHostViewBase* view = nullptr) const; 107 RenderWidgetHostViewBase* view = nullptr) const;
111 108
109 #if defined(USE_AURA)
110 // Returns the rect between selection bounds.
111 gfx::Rect GetSelectionBoundsRect() const;
112 #elif defined(OS_MACOSX)
Charlie Reis 2016/08/04 18:44:51 Hmm, this seems unfortunate to need different sele
EhsanK 2016/08/04 23:53:02 There is more in the .cc file for each specific me
kenrb 2016/08/08 22:03:04 What if we just store (more or less) the raw conte
113 // Returns the first caret bound for the view corresponding to |widget|.
114 const gfx::Rect* GetCaretRect(RenderWidgetHostImpl* widget) const;
115
116 // Returns the first selection bound for the view corresponding to |widget|.
117 const gfx::Rect* GetFirstSelectionRect(RenderWidgetHostImpl* widget) const;
118 #endif
119
112 // --------------------------------------------------------------------------- 120 // ---------------------------------------------------------------------------
113 // The following methods are called by RWHVs on the tab to update their IME- 121 // The following methods are called by RWHVs on the tab to update their IME-
114 // related state. 122 // related state.
115 123
116 // Updates the TextInputState for |view|. 124 // Updates the TextInputState for |view|.
117 void UpdateTextInputState(RenderWidgetHostViewBase* view, 125 void UpdateTextInputState(RenderWidgetHostViewBase* view,
118 const TextInputState& state); 126 const TextInputState& state);
119 127
120 // The current IME composition has been cancelled on the renderer side for 128 // The current IME composition has been cancelled on the renderer side for
121 // the widget corresponding to |view|. 129 // the widget corresponding to |view|.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // TextInputManager. 169 // TextInputManager.
162 void AddObserver(Observer* observer); 170 void AddObserver(Observer* observer);
163 void RemoveObserver(Observer* observer); 171 void RemoveObserver(Observer* observer);
164 172
165 RenderWidgetHostViewBase* active_view_for_testing() { return active_view_; } 173 RenderWidgetHostViewBase* active_view_for_testing() { return active_view_; }
166 size_t GetRegisteredViewsCountForTesting(); 174 size_t GetRegisteredViewsCountForTesting();
167 ui::TextInputType GetTextInputTypeForViewForTesting( 175 ui::TextInputType GetTextInputTypeForViewForTesting(
168 RenderWidgetHostViewBase* view); 176 RenderWidgetHostViewBase* view);
169 177
170 private: 178 private:
179 #if !defined(OS_ANDROID)
171 // Text selection bounds. 180 // Text selection bounds.
172 struct SelectionRegion { 181 struct SelectionRegion {
173 SelectionRegion(); 182 SelectionRegion();
174 SelectionRegion(const SelectionRegion& other); 183 SelectionRegion(const SelectionRegion& other);
175 184 #if defined(USE_AURA)
176 // The begining of the selection region. 185 // The begining of the selection region.
177 gfx::SelectionBound anchor; 186 gfx::SelectionBound anchor;
178 // The end of the selection region (caret position). 187 // The end of the selection region (caret position).
179 gfx::SelectionBound focus; 188 gfx::SelectionBound focus;
189 #else // OS_MACOSX
Charlie Reis 2016/08/04 18:44:51 Same here, and more so. This will be difficult to
EhsanK 2016/08/04 23:53:02 Let me think about this. Meanwhile, all suggestion
190 // The current caret bounds.
191 gfx::Rect caret_rect;
192 // The current first selection bounds.
193 gfx::Rect first_selection_rect;
194 #endif // USE_AURA
180 }; 195 };
196 #endif
181 197
182 // Ccomposition range information. 198 // Ccomposition range information.
183 struct CompositionRangeInfo { 199 struct CompositionRangeInfo {
184 CompositionRangeInfo(); 200 CompositionRangeInfo();
185 CompositionRangeInfo(const CompositionRangeInfo& other); 201 CompositionRangeInfo(const CompositionRangeInfo& other);
186 ~CompositionRangeInfo(); 202 ~CompositionRangeInfo();
187 203
188 std::vector<gfx::Rect> character_bounds; 204 std::vector<gfx::Rect> character_bounds;
189 }; 205 };
190 206
(...skipping 19 matching lines...) Expand all
210 ViewMap<CompositionRangeInfo> composition_range_info_map_; 226 ViewMap<CompositionRangeInfo> composition_range_info_map_;
211 ViewMap<TextSelection> text_selection_map_; 227 ViewMap<TextSelection> text_selection_map_;
212 228
213 base::ObserverList<Observer> observer_list_; 229 base::ObserverList<Observer> observer_list_;
214 230
215 DISALLOW_COPY_AND_ASSIGN(TextInputManager); 231 DISALLOW_COPY_AND_ASSIGN(TextInputManager);
216 }; 232 };
217 } 233 }
218 234
219 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ 235 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698