| 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_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <peninputpanel_i.c> | 9 #include <peninputpanel_i.c> |
| 10 #include <stack> | 10 #include <stack> |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 capture_enter_key_(false), | 469 capture_enter_key_(false), |
| 470 is_hidden_(false), | 470 is_hidden_(false), |
| 471 about_to_validate_and_paint_(false), | 471 about_to_validate_and_paint_(false), |
| 472 close_on_deactivate_(false), | 472 close_on_deactivate_(false), |
| 473 being_destroyed_(false), | 473 being_destroyed_(false), |
| 474 tooltip_hwnd_(NULL), | 474 tooltip_hwnd_(NULL), |
| 475 tooltip_showing_(false), | 475 tooltip_showing_(false), |
| 476 weak_factory_(this), | 476 weak_factory_(this), |
| 477 is_loading_(false), | 477 is_loading_(false), |
| 478 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 478 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 479 can_compose_inline_(true), |
| 479 is_fullscreen_(false), | 480 is_fullscreen_(false), |
| 480 ignore_mouse_movement_(true), | 481 ignore_mouse_movement_(true), |
| 481 composition_range_(ui::Range::InvalidRange()), | 482 composition_range_(ui::Range::InvalidRange()), |
| 482 ALLOW_THIS_IN_INITIALIZER_LIST( | 483 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 483 touch_state_(new WebTouchState(this))), | 484 touch_state_(new WebTouchState(this))), |
| 484 pointer_down_context_(false), | 485 pointer_down_context_(false), |
| 485 focus_on_editable_field_(false), | 486 focus_on_editable_field_(false), |
| 486 received_focus_change_after_pointer_down_(false), | 487 received_focus_change_after_pointer_down_(false), |
| 487 touch_events_enabled_(false), | 488 touch_events_enabled_(false), |
| 488 ALLOW_THIS_IN_INITIALIZER_LIST( | 489 ALLOW_THIS_IN_INITIALIZER_LIST( |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 } | 756 } |
| 756 } | 757 } |
| 757 | 758 |
| 758 void RenderWidgetHostViewWin::SetIsLoading(bool is_loading) { | 759 void RenderWidgetHostViewWin::SetIsLoading(bool is_loading) { |
| 759 is_loading_ = is_loading; | 760 is_loading_ = is_loading; |
| 760 UpdateCursorIfOverSelf(); | 761 UpdateCursorIfOverSelf(); |
| 761 } | 762 } |
| 762 | 763 |
| 763 void RenderWidgetHostViewWin::TextInputStateChanged( | 764 void RenderWidgetHostViewWin::TextInputStateChanged( |
| 764 const ViewHostMsg_TextInputState_Params& params) { | 765 const ViewHostMsg_TextInputState_Params& params) { |
| 765 // TODO(kinaba): currently, can_compose_inline is ignored and always treated | 766 if (text_input_type_ != params.type || |
| 766 // as true. We need to support "can_compose_inline=false" for PPAPI plugins | 767 can_compose_inline_ != params.can_compose_inline) { |
| 767 // that may want to avoid drawing composition-text by themselves and pass | |
| 768 // the responsibility to the browser. | |
| 769 if (text_input_type_ != params.type) { | |
| 770 text_input_type_ = params.type; | 768 text_input_type_ = params.type; |
| 769 can_compose_inline_ = params.can_compose_inline; |
| 771 UpdateIMEState(); | 770 UpdateIMEState(); |
| 772 } | 771 } |
| 773 } | 772 } |
| 774 | 773 |
| 775 void RenderWidgetHostViewWin::SelectionBoundsChanged( | 774 void RenderWidgetHostViewWin::SelectionBoundsChanged( |
| 776 const gfx::Rect& start_rect, | 775 const gfx::Rect& start_rect, |
| 777 WebKit::WebTextDirection start_direction, | 776 WebKit::WebTextDirection start_direction, |
| 778 const gfx::Rect& end_rect, | 777 const gfx::Rect& end_rect, |
| 779 WebKit::WebTextDirection end_direction) { | 778 WebKit::WebTextDirection end_direction) { |
| 780 bool is_enabled = (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE && | 779 bool is_enabled = (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE && |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 | 1664 |
| 1666 LRESULT RenderWidgetHostViewWin::OnImeStartComposition( | 1665 LRESULT RenderWidgetHostViewWin::OnImeStartComposition( |
| 1667 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 1666 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 1668 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeStartComposition"); | 1667 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeStartComposition"); |
| 1669 if (!render_widget_host_) | 1668 if (!render_widget_host_) |
| 1670 return 0; | 1669 return 0; |
| 1671 | 1670 |
| 1672 // Reset the composition status and create IME windows. | 1671 // Reset the composition status and create IME windows. |
| 1673 ime_input_.CreateImeWindow(m_hWnd); | 1672 ime_input_.CreateImeWindow(m_hWnd); |
| 1674 ime_input_.ResetComposition(m_hWnd); | 1673 ime_input_.ResetComposition(m_hWnd); |
| 1675 // We have to prevent WTL from calling ::DefWindowProc() because the function | 1674 // When the focus is on an element that does not draw composition by itself |
| 1675 // (i.e., PPAPI plugin not handling IME), let IME to draw the text. Otherwise |
| 1676 // we have to prevent WTL from calling ::DefWindowProc() because the function |
| 1676 // calls ::ImmSetCompositionWindow() and ::ImmSetCandidateWindow() to | 1677 // calls ::ImmSetCompositionWindow() and ::ImmSetCandidateWindow() to |
| 1677 // over-write the position of IME windows. | 1678 // over-write the position of IME windows. |
| 1678 handled = TRUE; | 1679 handled = (can_compose_inline_ ? TRUE : FALSE); |
| 1679 return 0; | 1680 return 0; |
| 1680 } | 1681 } |
| 1681 | 1682 |
| 1682 LRESULT RenderWidgetHostViewWin::OnImeComposition( | 1683 LRESULT RenderWidgetHostViewWin::OnImeComposition( |
| 1683 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 1684 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 1684 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeComposition"); | 1685 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeComposition"); |
| 1685 if (!render_widget_host_) | 1686 if (!render_widget_host_) |
| 1686 return 0; | 1687 return 0; |
| 1687 | 1688 |
| 1688 // At first, update the position of the IME window. | 1689 // At first, update the position of the IME window. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1717 const std::vector<WebKit::WebCompositionUnderline>& underlines = | 1718 const std::vector<WebKit::WebCompositionUnderline>& underlines = |
| 1718 reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( | 1719 reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( |
| 1719 composition.underlines); | 1720 composition.underlines); |
| 1720 render_widget_host_->ImeSetComposition( | 1721 render_widget_host_->ImeSetComposition( |
| 1721 composition.text, underlines, | 1722 composition.text, underlines, |
| 1722 composition.selection.start(), composition.selection.end()); | 1723 composition.selection.start(), composition.selection.end()); |
| 1723 } | 1724 } |
| 1724 // We have to prevent WTL from calling ::DefWindowProc() because we do not | 1725 // We have to prevent WTL from calling ::DefWindowProc() because we do not |
| 1725 // want for the IMM (Input Method Manager) to send WM_IME_CHAR messages. | 1726 // want for the IMM (Input Method Manager) to send WM_IME_CHAR messages. |
| 1726 handled = TRUE; | 1727 handled = TRUE; |
| 1728 if (!can_compose_inline_) { |
| 1729 // When the focus is on an element that does not draw composition by itself |
| 1730 // (i.e., PPAPI plugin not handling IME), let IME to draw the text, which |
| 1731 // is the default behavior of DefWindowProc. Note, however, even in this |
| 1732 // case we don't want GCS_RESULTSTR to be converted to WM_IME_CHAR messages. |
| 1733 // Thus we explicitly drop the flag. |
| 1734 return ::DefWindowProc(m_hWnd, message, wparam, lparam & ~GCS_RESULTSTR); |
| 1735 } |
| 1727 return 0; | 1736 return 0; |
| 1728 } | 1737 } |
| 1729 | 1738 |
| 1730 LRESULT RenderWidgetHostViewWin::OnImeEndComposition( | 1739 LRESULT RenderWidgetHostViewWin::OnImeEndComposition( |
| 1731 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 1740 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 1732 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeEndComposition"); | 1741 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnImeEndComposition"); |
| 1733 if (!render_widget_host_) | 1742 if (!render_widget_host_) |
| 1734 return 0; | 1743 return 0; |
| 1735 | 1744 |
| 1736 if (ime_input_.is_composing()) { | 1745 if (ime_input_.is_composing()) { |
| (...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3066 } | 3075 } |
| 3067 | 3076 |
| 3068 void RenderWidgetHostViewWin::UpdateIMEState() { | 3077 void RenderWidgetHostViewWin::UpdateIMEState() { |
| 3069 if (base::win::IsTsfAwareRequired()) { | 3078 if (base::win::IsTsfAwareRequired()) { |
| 3070 ui::TsfBridge::GetInstance()->OnTextInputTypeChanged(this); | 3079 ui::TsfBridge::GetInstance()->OnTextInputTypeChanged(this); |
| 3071 return; | 3080 return; |
| 3072 } | 3081 } |
| 3073 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE && | 3082 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE && |
| 3074 text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD) { | 3083 text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD) { |
| 3075 ime_input_.EnableIME(m_hWnd); | 3084 ime_input_.EnableIME(m_hWnd); |
| 3085 ime_input_.SetUseCompositionWindow(!can_compose_inline_); |
| 3076 } else { | 3086 } else { |
| 3077 ime_input_.DisableIME(m_hWnd); | 3087 ime_input_.DisableIME(m_hWnd); |
| 3078 } | 3088 } |
| 3079 } | 3089 } |
| 3080 | 3090 |
| 3081 //////////////////////////////////////////////////////////////////////////////// | 3091 //////////////////////////////////////////////////////////////////////////////// |
| 3082 // RenderWidgetHostView, public: | 3092 // RenderWidgetHostView, public: |
| 3083 | 3093 |
| 3084 // static | 3094 // static |
| 3085 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 3095 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3102 // receive a focus change in the context of a pointer down message, it means | 3112 // receive a focus change in the context of a pointer down message, it means |
| 3103 // that the pointer down message occurred on the edit field and we should | 3113 // that the pointer down message occurred on the edit field and we should |
| 3104 // display the on screen keyboard | 3114 // display the on screen keyboard |
| 3105 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) | 3115 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) |
| 3106 DisplayOnScreenKeyboardIfNeeded(); | 3116 DisplayOnScreenKeyboardIfNeeded(); |
| 3107 received_focus_change_after_pointer_down_ = false; | 3117 received_focus_change_after_pointer_down_ = false; |
| 3108 pointer_down_context_ = false; | 3118 pointer_down_context_ = false; |
| 3109 } | 3119 } |
| 3110 | 3120 |
| 3111 } // namespace content | 3121 } // namespace content |
| OLD | NEW |