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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 bool is_guest_view_hack) | 454 bool is_guest_view_hack) |
455 : host_(RenderWidgetHostImpl::From(host)), | 455 : host_(RenderWidgetHostImpl::From(host)), |
456 window_(nullptr), | 456 window_(nullptr), |
457 delegated_frame_host_(new DelegatedFrameHost(this)), | 457 delegated_frame_host_(new DelegatedFrameHost(this)), |
458 in_shutdown_(false), | 458 in_shutdown_(false), |
459 in_bounds_changed_(false), | 459 in_bounds_changed_(false), |
460 is_fullscreen_(false), | 460 is_fullscreen_(false), |
461 popup_parent_host_view_(NULL), | 461 popup_parent_host_view_(NULL), |
462 popup_child_host_view_(NULL), | 462 popup_child_host_view_(NULL), |
463 is_loading_(false), | 463 is_loading_(false), |
464 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | |
465 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | |
466 text_input_flags_(0), | |
467 can_compose_inline_(true), | |
468 has_composition_text_(false), | 464 has_composition_text_(false), |
469 accept_return_character_(false), | 465 accept_return_character_(false), |
470 last_swapped_software_frame_scale_factor_(1.f), | 466 last_swapped_software_frame_scale_factor_(1.f), |
471 paint_canvas_(NULL), | 467 paint_canvas_(NULL), |
472 synthetic_move_sent_(false), | 468 synthetic_move_sent_(false), |
473 cursor_visibility_state_in_renderer_(UNKNOWN), | 469 cursor_visibility_state_in_renderer_(UNKNOWN), |
474 #if defined(OS_WIN) | 470 #if defined(OS_WIN) |
475 legacy_render_widget_host_HWND_(NULL), | 471 legacy_render_widget_host_HWND_(NULL), |
476 legacy_window_destroyed_(false), | 472 legacy_window_destroyed_(false), |
477 showing_context_menu_(false), | 473 showing_context_menu_(false), |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 if (host) | 768 if (host) |
773 ::SetFocus(host->GetAcceleratedWidget()); | 769 ::SetFocus(host->GetAcceleratedWidget()); |
774 } | 770 } |
775 #endif | 771 #endif |
776 if (host_ && set_focus_on_mouse_down_or_key_event_) { | 772 if (host_ && set_focus_on_mouse_down_or_key_event_) { |
777 set_focus_on_mouse_down_or_key_event_ = false; | 773 set_focus_on_mouse_down_or_key_event_ = false; |
778 host_->Focus(); | 774 host_->Focus(); |
779 } | 775 } |
780 } | 776 } |
781 | 777 |
782 RenderFrameHostImpl* RenderWidgetHostViewAura::GetFocusedFrame() { | |
783 RenderViewHost* rvh = RenderViewHost::From(host_); | |
784 if (!rvh) | |
785 return nullptr; | |
786 FrameTreeNode* focused_frame = | |
787 rvh->GetDelegate()->GetFrameTree()->GetFocusedFrame(); | |
788 if (!focused_frame) | |
789 return nullptr; | |
790 | |
791 return focused_frame->current_frame_host(); | |
792 } | |
793 | |
794 bool RenderWidgetHostViewAura::CanRendererHandleEvent( | 778 bool RenderWidgetHostViewAura::CanRendererHandleEvent( |
795 const ui::MouseEvent* event, | 779 const ui::MouseEvent* event, |
796 bool mouse_locked, | 780 bool mouse_locked, |
797 bool selection_popup) { | 781 bool selection_popup) { |
798 #if defined(OS_WIN) | 782 #if defined(OS_WIN) |
799 bool showing_context_menu = showing_context_menu_; | 783 bool showing_context_menu = showing_context_menu_; |
800 showing_context_menu_ = false; | 784 showing_context_menu_ = false; |
801 #endif | 785 #endif |
802 | 786 |
803 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) | 787 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); | 981 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); |
998 current_cursor_.SetDisplayInfo(display); | 982 current_cursor_.SetDisplayInfo(display); |
999 UpdateCursorIfOverSelf(); | 983 UpdateCursorIfOverSelf(); |
1000 } | 984 } |
1001 | 985 |
1002 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { | 986 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { |
1003 is_loading_ = is_loading; | 987 is_loading_ = is_loading; |
1004 UpdateCursorIfOverSelf(); | 988 UpdateCursorIfOverSelf(); |
1005 } | 989 } |
1006 | 990 |
1007 void RenderWidgetHostViewAura::TextInputStateChanged( | 991 void RenderWidgetHostViewAura::NotifyTextInputStateChanged() { |
1008 const ViewHostMsg_TextInputState_Params& params) { | 992 RenderWidgetHostViewBase::NotifyTextInputStateChanged(); |
1009 if (text_input_type_ != params.type || | 993 |
1010 text_input_mode_ != params.mode || | 994 if (!GetInputMethod()) |
1011 can_compose_inline_ != params.can_compose_inline || | 995 return; |
1012 text_input_flags_ != params.flags) { | 996 |
1013 text_input_type_ = params.type; | 997 GetInputMethod()->OnTextInputTypeChanged(this); |
1014 text_input_mode_ = params.mode; | 998 |
1015 can_compose_inline_ = params.can_compose_inline; | 999 const TextInputState* state = current_text_input_state(); |
1016 text_input_flags_ = params.flags; | 1000 if (state->show_ime_if_needed && state->type != ui::TEXT_INPUT_TYPE_NONE) |
1017 if (GetInputMethod()) | 1001 GetInputMethod()->ShowImeIfNeeded(); |
1018 GetInputMethod()->OnTextInputTypeChanged(this); | |
1019 } | |
1020 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { | |
1021 if (GetInputMethod()) | |
1022 GetInputMethod()->ShowImeIfNeeded(); | |
1023 } | |
1024 } | 1002 } |
1025 | 1003 |
1026 void RenderWidgetHostViewAura::ImeCancelComposition() { | 1004 void RenderWidgetHostViewAura::ImeCancelComposition() { |
1027 if (GetInputMethod()) | 1005 if (GetInputMethod()) |
1028 GetInputMethod()->CancelComposition(this); | 1006 GetInputMethod()->CancelComposition(this); |
1029 has_composition_text_ = false; | 1007 has_composition_text_ = false; |
1030 } | 1008 } |
1031 | 1009 |
1032 void RenderWidgetHostViewAura::ImeCompositionRangeChanged( | 1010 void RenderWidgetHostViewAura::ImeCompositionRangeChanged( |
1033 const gfx::Range& range, | 1011 const gfx::Range& range, |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 has_composition_text_ = false; | 1614 has_composition_text_ = false; |
1637 } | 1615 } |
1638 | 1616 |
1639 void RenderWidgetHostViewAura::ClearCompositionText() { | 1617 void RenderWidgetHostViewAura::ClearCompositionText() { |
1640 if (host_ && has_composition_text_) | 1618 if (host_ && has_composition_text_) |
1641 host_->ImeCancelComposition(); | 1619 host_->ImeCancelComposition(); |
1642 has_composition_text_ = false; | 1620 has_composition_text_ = false; |
1643 } | 1621 } |
1644 | 1622 |
1645 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { | 1623 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { |
1646 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); | 1624 DCHECK(current_text_input_state()->type != ui::TEXT_INPUT_TYPE_NONE); |
1647 if (host_) | 1625 if (host_) |
1648 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); | 1626 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); |
1649 has_composition_text_ = false; | 1627 has_composition_text_ = false; |
1650 } | 1628 } |
1651 | 1629 |
1652 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { | 1630 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { |
1653 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { | 1631 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { |
1654 popup_child_host_view_->InsertChar(event); | 1632 popup_child_host_view_->InsertChar(event); |
1655 return; | 1633 return; |
1656 } | 1634 } |
1657 | 1635 |
1658 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 | 1636 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 |
1659 if (host_ && | 1637 if (host_ && |
1660 (accept_return_character_ || event.GetCharacter() != ui::VKEY_RETURN)) { | 1638 (accept_return_character_ || event.GetCharacter() != ui::VKEY_RETURN)) { |
1661 // Send a blink::WebInputEvent::Char event to |host_|. | 1639 // Send a blink::WebInputEvent::Char event to |host_|. |
1662 ForwardKeyboardEvent(NativeWebKeyboardEvent(event, event.GetCharacter())); | 1640 ForwardKeyboardEvent(NativeWebKeyboardEvent(event, event.GetCharacter())); |
1663 } | 1641 } |
1664 } | 1642 } |
1665 | 1643 |
1666 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { | 1644 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { |
1667 return text_input_type_; | 1645 return current_text_input_state()->type; |
1668 } | 1646 } |
1669 | 1647 |
1670 ui::TextInputMode RenderWidgetHostViewAura::GetTextInputMode() const { | 1648 ui::TextInputMode RenderWidgetHostViewAura::GetTextInputMode() const { |
1671 return text_input_mode_; | 1649 return current_text_input_state()->mode; |
1672 } | 1650 } |
1673 | 1651 |
1674 int RenderWidgetHostViewAura::GetTextInputFlags() const { | 1652 int RenderWidgetHostViewAura::GetTextInputFlags() const { |
1675 return text_input_flags_; | 1653 return current_text_input_state()->flags; |
1676 } | 1654 } |
1677 | 1655 |
1678 bool RenderWidgetHostViewAura::CanComposeInline() const { | 1656 bool RenderWidgetHostViewAura::CanComposeInline() const { |
1679 return can_compose_inline_; | 1657 return current_text_input_state()->can_compose_inline; |
1680 } | 1658 } |
1681 | 1659 |
1682 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen( | 1660 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen( |
1683 const gfx::Rect& rect) const { | 1661 const gfx::Rect& rect) const { |
1684 gfx::Point origin = rect.origin(); | 1662 gfx::Point origin = rect.origin(); |
1685 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); | 1663 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); |
1686 | 1664 |
1687 aura::Window* root_window = window_->GetRootWindow(); | 1665 aura::Window* root_window = window_->GetRootWindow(); |
1688 if (!root_window) | 1666 if (!root_window) |
1689 return rect; | 1667 return rect; |
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3069 | 3047 |
3070 //////////////////////////////////////////////////////////////////////////////// | 3048 //////////////////////////////////////////////////////////////////////////////// |
3071 // RenderWidgetHostViewBase, public: | 3049 // RenderWidgetHostViewBase, public: |
3072 | 3050 |
3073 // static | 3051 // static |
3074 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 3052 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
3075 GetScreenInfoForWindow(results, NULL); | 3053 GetScreenInfoForWindow(results, NULL); |
3076 } | 3054 } |
3077 | 3055 |
3078 } // namespace content | 3056 } // namespace content |
OLD | NEW |