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

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

Issue 1663013005: [DO NOT REVIEW] Always calling Notify for android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Trying to Fix MAC Created 4 years, 8 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_view_host_delegate.h"
14 #include "content/browser/renderer_host/render_view_host_impl.h"
13 #include "content/browser/renderer_host/render_widget_host_delegate.h" 15 #include "content/browser/renderer_host/render_widget_host_delegate.h"
14 #include "content/browser/renderer_host/render_widget_host_impl.h" 16 #include "content/browser/renderer_host/render_widget_host_impl.h"
15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" 17 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h"
16 #include "content/common/content_switches_internal.h" 18 #include "content/common/content_switches_internal.h"
19 #include "content/common/input_messages.h"
20 #include "content/common/site_isolation_policy.h"
21 #include "content/common/text_input_state.h"
22 #include "content/common/view_messages.h"
17 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 23 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
24 #include "content/public/common/browser_plugin_guest_mode.h"
18 #include "ui/gfx/display.h" 25 #include "ui/gfx/display.h"
19 #include "ui/gfx/geometry/point_conversions.h" 26 #include "ui/gfx/geometry/point_conversions.h"
20 #include "ui/gfx/geometry/size_conversions.h" 27 #include "ui/gfx/geometry/size_conversions.h"
21 #include "ui/gfx/geometry/size_f.h" 28 #include "ui/gfx/geometry/size_f.h"
22 #include "ui/gfx/screen.h" 29 #include "ui/gfx/screen.h"
23 30
24 namespace content { 31 namespace content {
25 32
26 namespace { 33 namespace {
27 34
28 // How many microseconds apart input events should be flushed. 35 // How many microseconds apart input events should be flushed.
29 const int kFlushInputRateInUs = 16666; 36 const int kFlushInputRateInUs = 16666;
30 37
31 } 38 }
32 39
33 RenderWidgetHostViewBase::RenderWidgetHostViewBase() 40 RenderWidgetHostViewBase::RenderWidgetHostViewBase()
34 : popup_type_(blink::WebPopupTypeNone), 41 : popup_type_(blink::WebPopupTypeNone),
35 background_color_(SK_ColorWHITE), 42 background_color_(SK_ColorWHITE),
36 mouse_locked_(false), 43 mouse_locked_(false),
37 showing_context_menu_(false), 44 showing_context_menu_(false),
38 selection_text_offset_(0), 45 selection_text_offset_(0),
39 selection_range_(gfx::Range::InvalidRange()), 46 selection_range_(gfx::Range::InvalidRange()),
40 current_device_scale_factor_(0), 47 current_device_scale_factor_(0),
41 current_display_rotation_(gfx::Display::ROTATE_0), 48 current_display_rotation_(gfx::Display::ROTATE_0),
42 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), 49 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()),
43 renderer_frame_number_(0), 50 renderer_frame_number_(0),
51 text_input_state_(new TextInputState()),
44 weak_factory_(this) {} 52 weak_factory_(this) {}
45 53
46 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { 54 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() {
47 DCHECK(!mouse_locked_); 55 DCHECK(!mouse_locked_);
48 // We call this here to guarantee that observers are notified before we go 56 // 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 57 // away. However, some subclasses may wish to call this earlier in their
50 // shutdown process, e.g. to force removal from 58 // shutdown process, e.g. to force removal from
51 // RenderWidgetHostInputEventRouter's surface map before relinquishing a 59 // RenderWidgetHostInputEventRouter's surface map before relinquishing a
52 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling 60 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling
53 // NotifyObserversAboutShutdown() twice, as the observers are required to 61 // NotifyObserversAboutShutdown() twice, as the observers are required to
54 // de-register on the first call, and so the second call does nothing. 62 // de-register on the first call, and so the second call does nothing.
55 NotifyObserversAboutShutdown(); 63 NotifyObserversAboutShutdown();
56 } 64 }
57 65
58 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() { 66 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() {
59 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the 67 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the
60 // following notification to remove this view from its surface owners map. 68 // following notification to remove this view from its surface owners map.
61 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver, 69 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver,
62 observers_, 70 observers_,
63 OnRenderWidgetHostViewBaseDestroyed(this)); 71 OnRenderWidgetHostViewBaseDestroyed(this));
64 // All observers are required to disconnect after they are notified. 72 // All observers are required to disconnect after they are notified.
65 DCHECK(!observers_.might_have_observers()); 73 DCHECK(!observers_.might_have_observers());
66 } 74 }
67 75
76 void RenderWidgetHostViewBase::NotifyHostDelegateAboutShutdown() {
77 RenderWidgetHostImpl* host =
78 RenderWidgetHostImpl::From(GetRenderWidgetHost());
79
80 if (!host || !host->delegate())
81 return;
82
83 bool has_active_text = text_input_state()->type != ui::TEXT_INPUT_TYPE_NONE;
84 text_input_state_.reset(new TextInputState());
85
86 host->delegate()->UpdateTextInputState(this, has_active_text);
87 }
88
68 bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){ 89 bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){
69 return false; 90 return false;
70 } 91 }
71 92
72 void RenderWidgetHostViewBase::SetBackgroundColor(SkColor color) { 93 void RenderWidgetHostViewBase::SetBackgroundColor(SkColor color) {
73 background_color_ = color; 94 background_color_ = color;
74 } 95 }
75 96
76 void RenderWidgetHostViewBase::SetBackgroundColorToDefault() { 97 void RenderWidgetHostViewBase::SetBackgroundColorToDefault() {
77 SetBackgroundColor(SK_ColorWHITE); 98 SetBackgroundColor(SK_ColorWHITE);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 gfx::ToRoundedPoint(point))); 396 gfx::ToRoundedPoint(point)));
376 } 397 }
377 398
378 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( 399 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace(
379 const gfx::Point& point, 400 const gfx::Point& point,
380 cc::SurfaceId original_surface, 401 cc::SurfaceId original_surface,
381 gfx::Point* transformed_point) { 402 gfx::Point* transformed_point) {
382 *transformed_point = point; 403 *transformed_point = point;
383 } 404 }
384 405
406 void RenderWidgetHostViewBase::TextInputStateChanged(
407 const TextInputState& params) {
408 bool text_input_state_changed = true;
409 #if !defined(OS_ANDROID)
410 if (params.type == text_input_state_->type &&
411 params.can_compose_inline == text_input_state_->can_compose_inline
412 #if !defined(OS_MACOSX)
413 && params.mode == text_input_state_->mode &&
414 params.flags == text_input_state_->flags
415 #endif
416 )
417 text_input_state_changed = false;
418 #else
419 if (params.is_non_ime_change) {
420 // Sends an acknowledgement to the renderer of a processed IME event.
421 GetRenderWidgetHost()->Send(
422 new InputMsg_ImeEventAck(GetRenderWidgetHost()->GetRoutingID()));
423 }
424 #endif
425
426 if (text_input_state_changed) {
427 *text_input_state_ = params;
428 RenderWidgetHostImpl* host =
429 RenderWidgetHostImpl::From(GetRenderWidgetHost());
430 if (host && host->delegate())
431 host->delegate()->UpdateTextInputState(this, text_input_state_changed);
432 }
433 }
434
385 void RenderWidgetHostViewBase::AddObserver( 435 void RenderWidgetHostViewBase::AddObserver(
386 RenderWidgetHostViewBaseObserver* observer) { 436 RenderWidgetHostViewBaseObserver* observer) {
387 observers_.AddObserver(observer); 437 observers_.AddObserver(observer);
388 } 438 }
389 439
390 void RenderWidgetHostViewBase::RemoveObserver( 440 void RenderWidgetHostViewBase::RemoveObserver(
391 RenderWidgetHostViewBaseObserver* observer) { 441 RenderWidgetHostViewBaseObserver* observer) {
392 observers_.RemoveObserver(observer); 442 observers_.RemoveObserver(observer);
393 } 443 }
394 444
395 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { 445 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const {
396 return false; 446 return false;
397 } 447 }
398 448
399 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { 449 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const {
400 return cc::SurfaceId(); 450 return cc::SurfaceId();
401 } 451 }
402 452
403 } // namespace content 453 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698