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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_base.cc

Issue 2659433002: Track Text Selection information in TextInputManager (OOPIF for Android) (Closed)
Patch Set: Clean ups Created 3 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/browser/renderer_host/render_widget_host_view_base.h" 5 #include "content/browser/renderer_host/render_widget_host_view_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/browser/accessibility/browser_accessibility_manager.h" 9 #include "content/browser/accessibility/browser_accessibility_manager.h"
10 #include "content/browser/gpu/gpu_data_manager_impl.h" 10 #include "content/browser/gpu/gpu_data_manager_impl.h"
(...skipping 19 matching lines...) Expand all
30 const int kFlushInputRateInUs = 16666; 30 const int kFlushInputRateInUs = 16666;
31 31
32 } 32 }
33 33
34 RenderWidgetHostViewBase::RenderWidgetHostViewBase() 34 RenderWidgetHostViewBase::RenderWidgetHostViewBase()
35 : is_fullscreen_(false), 35 : is_fullscreen_(false),
36 popup_type_(blink::WebPopupTypeNone), 36 popup_type_(blink::WebPopupTypeNone),
37 background_color_(SK_ColorWHITE), 37 background_color_(SK_ColorWHITE),
38 mouse_locked_(false), 38 mouse_locked_(false),
39 showing_context_menu_(false), 39 showing_context_menu_(false),
40 #if !defined(USE_AURA)
41 selection_text_offset_(0),
42 selection_range_(gfx::Range::InvalidRange()),
43 #endif
44 current_device_scale_factor_(0), 40 current_device_scale_factor_(0),
45 current_display_rotation_(display::Display::ROTATE_0), 41 current_display_rotation_(display::Display::ROTATE_0),
46 text_input_manager_(nullptr), 42 text_input_manager_(nullptr),
47 renderer_frame_number_(0), 43 renderer_frame_number_(0),
48 weak_factory_(this) { 44 weak_factory_(this) {
49 } 45 }
50 46
51 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { 47 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() {
52 DCHECK(!mouse_locked_); 48 DCHECK(!mouse_locked_);
53 // We call this here to guarantee that observers are notified before we go 49 // We call this here to guarantee that observers are notified before we go
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 #endif 127 #endif
132 } 128 }
133 129
134 float RenderWidgetHostViewBase::GetBottomControlsHeight() const { 130 float RenderWidgetHostViewBase::GetBottomControlsHeight() const {
135 return 0.f; 131 return 0.f;
136 } 132 }
137 133
138 void RenderWidgetHostViewBase::SelectionChanged(const base::string16& text, 134 void RenderWidgetHostViewBase::SelectionChanged(const base::string16& text,
139 size_t offset, 135 size_t offset,
140 const gfx::Range& range) { 136 const gfx::Range& range) {
141 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms.
142 // Also, remove the following local variables when that happens
143 // (https://crbug.com/578168 and https://crbug.com/602427).
144 #if !defined(OS_ANDROID)
145 if (GetTextInputManager()) 137 if (GetTextInputManager())
146 GetTextInputManager()->SelectionChanged(this, text, offset, range); 138 GetTextInputManager()->SelectionChanged(this, text, offset, range);
147 #else
148 selection_text_ = text;
149 selection_text_offset_ = offset;
150 selection_range_.set_start(range.start());
151 selection_range_.set_end(range.end());
152 #endif
153 } 139 }
154 140
155 gfx::Size RenderWidgetHostViewBase::GetRequestedRendererSize() const { 141 gfx::Size RenderWidgetHostViewBase::GetRequestedRendererSize() const {
156 return GetViewBounds().size(); 142 return GetViewBounds().size();
157 } 143 }
158 144
159 ui::TextInputClient* RenderWidgetHostViewBase::GetTextInputClient() { 145 ui::TextInputClient* RenderWidgetHostViewBase::GetTextInputClient() {
160 NOTREACHED(); 146 NOTREACHED();
161 return NULL; 147 return NULL;
162 } 148 }
(...skipping 10 matching lines...) Expand all
173 bool RenderWidgetHostViewBase::IsShowingContextMenu() const { 159 bool RenderWidgetHostViewBase::IsShowingContextMenu() const {
174 return showing_context_menu_; 160 return showing_context_menu_;
175 } 161 }
176 162
177 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { 163 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) {
178 DCHECK_NE(showing_context_menu_, showing); 164 DCHECK_NE(showing_context_menu_, showing);
179 showing_context_menu_ = showing; 165 showing_context_menu_ = showing;
180 } 166 }
181 167
182 base::string16 RenderWidgetHostViewBase::GetSelectedText() { 168 base::string16 RenderWidgetHostViewBase::GetSelectedText() {
183 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms.
184 // Also, remove the following local variables when that happens
185 // (https://crbug.com/578168 and https://crbug.com/602427).
186 #if !defined(OS_ANDROID)
187 if (!GetTextInputManager()) 169 if (!GetTextInputManager())
188 return base::string16(); 170 return base::string16();
189 171
190 const TextInputManager::TextSelection* selection = 172 const TextInputManager::TextSelection* selection =
191 GetTextInputManager()->GetTextSelection(this); 173 GetTextInputManager()->GetTextSelection(this);
192 174
193 if (!selection || !selection->range.IsValid()) 175 if (!selection || !selection->range.IsValid())
194 return base::string16(); 176 return base::string16();
195 177
196 return selection->text.substr(selection->range.GetMin() - selection->offset, 178 return selection->text.substr(selection->range.GetMin() - selection->offset,
197 selection->range.length()); 179 selection->range.length());
198 #else
199 if (!selection_range_.IsValid())
200 return base::string16();
201 return selection_text_.substr(
202 selection_range_.GetMin() - selection_text_offset_,
203 selection_range_.length());
204 #endif
205 } 180 }
206 181
207 bool RenderWidgetHostViewBase::IsMouseLocked() { 182 bool RenderWidgetHostViewBase::IsMouseLocked() {
208 return mouse_locked_; 183 return mouse_locked_;
209 } 184 }
210 185
211 InputEventAckState RenderWidgetHostViewBase::FilterInputEvent( 186 InputEventAckState RenderWidgetHostViewBase::FilterInputEvent(
212 const blink::WebInputEvent& input_event) { 187 const blink::WebInputEvent& input_event) {
213 // By default, input events are simply forwarded to the renderer. 188 // By default, input events are simply forwarded to the renderer.
214 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 189 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 501
527 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { 502 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const {
528 return false; 503 return false;
529 } 504 }
530 505
531 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { 506 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const {
532 return cc::SurfaceId(); 507 return cc::SurfaceId();
533 } 508 }
534 509
535 } // namespace content 510 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698