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

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: Rebase (Code changed during CQ Dry-run) Created 4 years, 6 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(
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 gfx::ToRoundedPoint(point))); 394 gfx::ToRoundedPoint(point)));
382 } 395 }
383 396
384 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( 397 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace(
385 const gfx::Point& point, 398 const gfx::Point& point,
386 cc::SurfaceId original_surface, 399 cc::SurfaceId original_surface,
387 gfx::Point* transformed_point) { 400 gfx::Point* transformed_point) {
388 *transformed_point = point; 401 *transformed_point = point;
389 } 402 }
390 403
404 void RenderWidgetHostViewBase::TextInputStateChanged(
405 const TextInputState& text_input_state) {
406 // TODO(ekaramad): Use TextInputManager code paths when IME is implemented on
407 // other platforms.
408 #if defined(USE_AURA)
409 if (GetTextInputManager())
410 GetTextInputManager()->UpdateTextInputState(this, text_input_state);
411 #endif
412 }
413
414 TextInputManager* RenderWidgetHostViewBase::GetTextInputManager() {
415 if (text_input_manager_)
416 return text_input_manager_;
417
418 RenderWidgetHostImpl* host =
419 RenderWidgetHostImpl::From(GetRenderWidgetHost());
420 if (!host || !host->delegate())
421 return nullptr;
422
423 // This RWHV needs to be registered with the TextInputManager so that the
424 // TextInputManager starts tracking its state, and observing its lifetime.
425 text_input_manager_ = host->delegate()->GetTextInputManager();
426 if (text_input_manager_)
427 text_input_manager_->Register(this);
428
429 return text_input_manager_;
430 }
431
391 void RenderWidgetHostViewBase::AddObserver( 432 void RenderWidgetHostViewBase::AddObserver(
392 RenderWidgetHostViewBaseObserver* observer) { 433 RenderWidgetHostViewBaseObserver* observer) {
393 observers_.AddObserver(observer); 434 observers_.AddObserver(observer);
394 } 435 }
395 436
396 void RenderWidgetHostViewBase::RemoveObserver( 437 void RenderWidgetHostViewBase::RemoveObserver(
397 RenderWidgetHostViewBaseObserver* observer) { 438 RenderWidgetHostViewBaseObserver* observer) {
398 observers_.RemoveObserver(observer); 439 observers_.RemoveObserver(observer);
399 } 440 }
400 441
401 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { 442 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const {
402 return false; 443 return false;
403 } 444 }
404 445
405 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { 446 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const {
406 return cc::SurfaceId(); 447 return cc::SurfaceId();
407 } 448 }
408 449
409 } // namespace content 450 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_base.h ('k') | content/browser/renderer_host/text_input_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698