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

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

Issue 1948343002: [reland] Browser Side Text Input State Tracking for OOPIF (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added the missing test file Created 4 years, 7 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"
11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" 11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h"
12 #include "content/browser/renderer_host/render_process_host_impl.h" 12 #include "content/browser/renderer_host/render_process_host_impl.h"
13 #include "content/browser/renderer_host/render_widget_host_delegate.h" 13 #include "content/browser/renderer_host/render_widget_host_delegate.h"
14 #include "content/browser/renderer_host/render_widget_host_impl.h" 14 #include "content/browser/renderer_host/render_widget_host_impl.h"
15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" 15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h"
16 #include "content/browser/renderer_host/text_input_manager.h"
16 #include "content/common/content_switches_internal.h" 17 #include "content/common/content_switches_internal.h"
17 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 18 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
18 #include "ui/display/display.h" 19 #include "ui/display/display.h"
19 #include "ui/display/screen.h" 20 #include "ui/display/screen.h"
20 #include "ui/gfx/geometry/point_conversions.h" 21 #include "ui/gfx/geometry/point_conversions.h"
21 #include "ui/gfx/geometry/size_conversions.h" 22 #include "ui/gfx/geometry/size_conversions.h"
22 #include "ui/gfx/geometry/size_f.h" 23 #include "ui/gfx/geometry/size_f.h"
23 24
24 namespace content { 25 namespace content {
25 26
26 namespace { 27 namespace {
27 28
28 // How many microseconds apart input events should be flushed. 29 // How many microseconds apart input events should be flushed.
29 const int kFlushInputRateInUs = 16666; 30 const int kFlushInputRateInUs = 16666;
30 31
31 } 32 }
32 33
33 RenderWidgetHostViewBase::RenderWidgetHostViewBase() 34 RenderWidgetHostViewBase::RenderWidgetHostViewBase()
34 : popup_type_(blink::WebPopupTypeNone), 35 : popup_type_(blink::WebPopupTypeNone),
35 background_color_(SK_ColorWHITE), 36 background_color_(SK_ColorWHITE),
36 mouse_locked_(false), 37 mouse_locked_(false),
37 showing_context_menu_(false), 38 showing_context_menu_(false),
38 selection_text_offset_(0), 39 selection_text_offset_(0),
39 selection_range_(gfx::Range::InvalidRange()), 40 selection_range_(gfx::Range::InvalidRange()),
40 current_device_scale_factor_(0), 41 current_device_scale_factor_(0),
41 current_display_rotation_(display::Display::ROTATE_0), 42 current_display_rotation_(display::Display::ROTATE_0),
42 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), 43 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()),
44 text_input_manager_(nullptr),
43 renderer_frame_number_(0), 45 renderer_frame_number_(0),
44 weak_factory_(this) {} 46 weak_factory_(this) {}
45 47
46 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { 48 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() {
47 DCHECK(!mouse_locked_); 49 DCHECK(!mouse_locked_);
48 // We call this here to guarantee that observers are notified before we go 50 // We call this here to guarantee that observers are notified before we go
49 // away. However, some subclasses may wish to call this earlier in their 51 // away. However, some subclasses may wish to call this earlier in their
50 // shutdown process, e.g. to force removal from 52 // shutdown process, e.g. to force removal from
51 // RenderWidgetHostInputEventRouter's surface map before relinquishing a 53 // RenderWidgetHostInputEventRouter's surface map before relinquishing a
52 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling 54 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling
53 // NotifyObserversAboutShutdown() twice, as the observers are required to 55 // NotifyObserversAboutShutdown() twice, as the observers are required to
54 // de-register on the first call, and so the second call does nothing. 56 // de-register on the first call, and so the second call does nothing.
55 NotifyObserversAboutShutdown(); 57 NotifyObserversAboutShutdown();
58 // If we have a live reference to |text_input_manager_|, we should unregister
59 // so that the |text_input_manager_| will free its state.
60 if (text_input_manager_)
61 text_input_manager_->Unregister(this);
56 } 62 }
57 63
58 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() { 64 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() {
59 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the 65 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the
60 // following notification to remove this view from its surface owners map. 66 // following notification to remove this view from its surface owners map.
61 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver, 67 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver,
62 observers_, 68 observers_,
63 OnRenderWidgetHostViewBaseDestroyed(this)); 69 OnRenderWidgetHostViewBaseDestroyed(this));
64 // All observers are required to disconnect after they are notified. 70 // All observers are required to disconnect after they are notified.
65 DCHECK(!observers_.might_have_observers()); 71 DCHECK(!observers_.might_have_observers());
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 current_display_rotation_ == display.rotation()) { 227 current_display_rotation_ == display.rotation()) {
222 return false; 228 return false;
223 } 229 }
224 230
225 current_display_area_ = display.work_area(); 231 current_display_area_ = display.work_area();
226 current_device_scale_factor_ = display.device_scale_factor(); 232 current_device_scale_factor_ = display.device_scale_factor();
227 current_display_rotation_ = display.rotation(); 233 current_display_rotation_ = display.rotation();
228 return true; 234 return true;
229 } 235 }
230 236
237 void RenderWidgetHostViewBase::DidUnregisterFromTextInputManager(
EhsanK 2016/05/24 20:42:47 This method is replacing the observer method OnDes
238 TextInputManager* text_input_manager) {
239 DCHECK(text_input_manager && text_input_manager_ == text_input_manager);
240
241 text_input_manager_ = nullptr;
242 }
243
231 base::WeakPtr<RenderWidgetHostViewBase> RenderWidgetHostViewBase::GetWeakPtr() { 244 base::WeakPtr<RenderWidgetHostViewBase> RenderWidgetHostViewBase::GetWeakPtr() {
232 return weak_factory_.GetWeakPtr(); 245 return weak_factory_.GetWeakPtr();
233 } 246 }
234 247
235 std::unique_ptr<SyntheticGestureTarget> 248 std::unique_ptr<SyntheticGestureTarget>
236 RenderWidgetHostViewBase::CreateSyntheticGestureTarget() { 249 RenderWidgetHostViewBase::CreateSyntheticGestureTarget() {
237 RenderWidgetHostImpl* host = 250 RenderWidgetHostImpl* host =
238 RenderWidgetHostImpl::From(GetRenderWidgetHost()); 251 RenderWidgetHostImpl::From(GetRenderWidgetHost());
239 return std::unique_ptr<SyntheticGestureTarget>( 252 return std::unique_ptr<SyntheticGestureTarget>(
240 new SyntheticGestureTargetBase(host)); 253 new SyntheticGestureTargetBase(host));
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 gfx::ToRoundedPoint(point))); 388 gfx::ToRoundedPoint(point)));
376 } 389 }
377 390
378 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( 391 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace(
379 const gfx::Point& point, 392 const gfx::Point& point,
380 cc::SurfaceId original_surface, 393 cc::SurfaceId original_surface,
381 gfx::Point* transformed_point) { 394 gfx::Point* transformed_point) {
382 *transformed_point = point; 395 *transformed_point = point;
383 } 396 }
384 397
398 void RenderWidgetHostViewBase::TextInputStateChanged(
399 const TextInputState& text_input_state) {
400 // TODO(ekaramad): Use TextInputManager code paths when IME is implemented on
401 // other platforms.
402 #if defined(USE_AURA)
403 if (GetTextInputManager())
404 GetTextInputManager()->UpdateTextInputState(this, text_input_state);
405 #endif
406 }
407
408 TextInputManager* RenderWidgetHostViewBase::GetTextInputManager() {
409 if (text_input_manager_)
410 return text_input_manager_;
411
412 RenderWidgetHostImpl* host =
413 RenderWidgetHostImpl::From(GetRenderWidgetHost());
414 if (!host || !host->delegate())
415 return nullptr;
416
417 // This RWHV needs to be registered with the TextInputManager so that the
418 // TextInputManager starts tracking its state, and observing its lifetime.
419 text_input_manager_ = host->delegate()->GetTextInputManager();
420 if (text_input_manager_)
421 text_input_manager_->Register(this);
422
423 return text_input_manager_;
424 }
425
385 void RenderWidgetHostViewBase::AddObserver( 426 void RenderWidgetHostViewBase::AddObserver(
386 RenderWidgetHostViewBaseObserver* observer) { 427 RenderWidgetHostViewBaseObserver* observer) {
387 observers_.AddObserver(observer); 428 observers_.AddObserver(observer);
388 } 429 }
389 430
390 void RenderWidgetHostViewBase::RemoveObserver( 431 void RenderWidgetHostViewBase::RemoveObserver(
391 RenderWidgetHostViewBaseObserver* observer) { 432 RenderWidgetHostViewBaseObserver* observer) {
392 observers_.RemoveObserver(observer); 433 observers_.RemoveObserver(observer);
393 } 434 }
394 435
395 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { 436 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const {
396 return false; 437 return false;
397 } 438 }
398 439
399 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { 440 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const {
400 return cc::SurfaceId(); 441 return cc::SurfaceId();
401 } 442 }
402 443
403 } // namespace content 444 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698