Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 25 #include "base/command_line.h" | 32 #include "base/command_line.h" |
| 26 #include "base/message_loop/message_loop.h" | 33 #include "base/message_loop/message_loop.h" |
| 27 #include "base/win/wrapped_window_proc.h" | 34 #include "base/win/wrapped_window_proc.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 : popup_type_(blink::WebPopupTypeNone), | 379 : popup_type_(blink::WebPopupTypeNone), |
| 373 background_color_(SK_ColorWHITE), | 380 background_color_(SK_ColorWHITE), |
| 374 mouse_locked_(false), | 381 mouse_locked_(false), |
| 375 showing_context_menu_(false), | 382 showing_context_menu_(false), |
| 376 selection_text_offset_(0), | 383 selection_text_offset_(0), |
| 377 selection_range_(gfx::Range::InvalidRange()), | 384 selection_range_(gfx::Range::InvalidRange()), |
| 378 current_device_scale_factor_(0), | 385 current_device_scale_factor_(0), |
| 379 current_display_rotation_(gfx::Display::ROTATE_0), | 386 current_display_rotation_(gfx::Display::ROTATE_0), |
| 380 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), | 387 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), |
| 381 renderer_frame_number_(0), | 388 renderer_frame_number_(0), |
| 389 text_input_state_(new TextInputState()), | |
| 382 weak_factory_(this) {} | 390 weak_factory_(this) {} |
| 383 | 391 |
| 384 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { | 392 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { |
| 385 DCHECK(!mouse_locked_); | 393 DCHECK(!mouse_locked_); |
| 386 // We call this here to guarantee that observers are notified before we go | 394 // We call this here to guarantee that observers are notified before we go |
| 387 // away. However, some subclasses may wish to call this earlier in their | 395 // away. However, some subclasses may wish to call this earlier in their |
| 388 // shutdown process, e.g. to force removal from | 396 // shutdown process, e.g. to force removal from |
| 389 // RenderWidgetHostInputEventRouter's surface map before relinquishing a | 397 // RenderWidgetHostInputEventRouter's surface map before relinquishing a |
| 390 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling | 398 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling |
| 391 // NotifyObserversAboutShutdown() twice, as the observers are required to | 399 // NotifyObserversAboutShutdown() twice, as the observers are required to |
| 392 // de-register on the first call, and so the second call does nothing. | 400 // de-register on the first call, and so the second call does nothing. |
| 393 NotifyObserversAboutShutdown(); | 401 NotifyObserversAboutShutdown(); |
| 394 } | 402 } |
| 395 | 403 |
| 396 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() { | 404 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() { |
| 397 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the | 405 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the |
| 398 // following notification to remove this view from its surface owners map. | 406 // following notification to remove this view from its surface owners map. |
| 399 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver, | 407 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver, |
| 400 observers_, | 408 observers_, |
| 401 OnRenderWidgetHostViewBaseDestroyed(this)); | 409 OnRenderWidgetHostViewBaseDestroyed(this)); |
| 402 // All observers are required to disconnect after they are notified. | 410 // All observers are required to disconnect after they are notified. |
| 403 DCHECK(!observers_.might_have_observers()); | 411 DCHECK(!observers_.might_have_observers()); |
| 404 } | 412 } |
| 405 | 413 |
| 414 void RenderWidgetHostViewBase::NotifyHostDelegateAboutShutdown() { | |
| 415 RenderWidgetHostImpl* host = | |
| 416 RenderWidgetHostImpl::From(GetRenderWidgetHost()); | |
| 417 | |
| 418 if (!host || !host->delegate()) | |
| 419 return; | |
| 420 | |
| 421 bool has_active_text = text_input_state()->type != ui::TEXT_INPUT_TYPE_NONE; | |
| 422 text_input_state_.reset(new TextInputState); | |
|
Charlie Reis
2016/03/16 16:55:13
Same minor nit: new TextInputState()
EhsanK
2016/03/30 20:46:03
Thanks! Done.
| |
| 423 | |
| 424 host->delegate()->UpdateTextInputState(this, has_active_text); | |
| 425 } | |
| 426 | |
| 406 bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){ | 427 bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){ |
| 407 return false; | 428 return false; |
| 408 } | 429 } |
| 409 | 430 |
| 410 void RenderWidgetHostViewBase::SetBackgroundColor(SkColor color) { | 431 void RenderWidgetHostViewBase::SetBackgroundColor(SkColor color) { |
| 411 background_color_ = color; | 432 background_color_ = color; |
| 412 } | 433 } |
| 413 | 434 |
| 414 void RenderWidgetHostViewBase::SetBackgroundColorToDefault() { | 435 void RenderWidgetHostViewBase::SetBackgroundColorToDefault() { |
| 415 SetBackgroundColor(SK_ColorWHITE); | 436 SetBackgroundColor(SK_ColorWHITE); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 gfx::ToRoundedPoint(point))); | 734 gfx::ToRoundedPoint(point))); |
| 714 } | 735 } |
| 715 | 736 |
| 716 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( | 737 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( |
| 717 const gfx::Point& point, | 738 const gfx::Point& point, |
| 718 cc::SurfaceId original_surface, | 739 cc::SurfaceId original_surface, |
| 719 gfx::Point* transformed_point) { | 740 gfx::Point* transformed_point) { |
| 720 *transformed_point = point; | 741 *transformed_point = point; |
| 721 } | 742 } |
| 722 | 743 |
| 744 void RenderWidgetHostViewBase::TextInputStateChanged( | |
| 745 const TextInputState& params) { | |
| 746 bool text_input_state_changed = true; | |
| 747 #if !defined(OS_ANDROID) | |
| 748 if (params.type == text_input_state_->type && | |
| 749 params.can_compose_inline == text_input_state_->can_compose_inline | |
| 750 #if !defined(OS_MACOSX) | |
| 751 && params.mode == text_input_state_->mode && | |
| 752 params.flags == text_input_state_->flags | |
| 753 #endif | |
| 754 ) | |
| 755 text_input_state_changed = false; | |
| 756 #else | |
| 757 if (params.is_non_ime_change) { | |
| 758 // Sends an acknowledgement to the renderer of a processed IME event. | |
| 759 GetRenderWidgetHost()->Send( | |
| 760 new InputMsg_ImeEventAck(GetRenderWidgetHost()->GetRoutingID())); | |
| 761 } | |
| 762 #endif | |
| 763 | |
| 764 if (text_input_state_changed) { | |
| 765 *text_input_state_ = params; | |
| 766 RenderWidgetHostImpl* host = | |
| 767 RenderWidgetHostImpl::From(GetRenderWidgetHost()); | |
| 768 if (host && host->delegate()) | |
| 769 host->delegate()->UpdateTextInputState(this, text_input_state_changed); | |
| 770 } | |
| 771 } | |
| 772 | |
| 723 void RenderWidgetHostViewBase::AddObserver( | 773 void RenderWidgetHostViewBase::AddObserver( |
| 724 RenderWidgetHostViewBaseObserver* observer) { | 774 RenderWidgetHostViewBaseObserver* observer) { |
| 725 observers_.AddObserver(observer); | 775 observers_.AddObserver(observer); |
| 726 } | 776 } |
| 727 | 777 |
| 728 void RenderWidgetHostViewBase::RemoveObserver( | 778 void RenderWidgetHostViewBase::RemoveObserver( |
| 729 RenderWidgetHostViewBaseObserver* observer) { | 779 RenderWidgetHostViewBaseObserver* observer) { |
| 730 observers_.RemoveObserver(observer); | 780 observers_.RemoveObserver(observer); |
| 731 } | 781 } |
| 732 | 782 |
| 733 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { | 783 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { |
| 734 return cc::SurfaceId(); | 784 return cc::SurfaceId(); |
| 735 } | 785 } |
| 736 | 786 |
| 737 } // namespace content | 787 } // namespace content |
| OLD | NEW |