| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/gdi_util.h" | 8 #include "app/gfx/gdi_util.h" |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/l10n_util_win.h" | 10 #include "app/l10n_util_win.h" |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 case TTN_SHOW: | 933 case TTN_SHOW: |
| 934 tooltip_showing_ = true; | 934 tooltip_showing_ = true; |
| 935 SetMsgHandled(TRUE); | 935 SetMsgHandled(TRUE); |
| 936 break; | 936 break; |
| 937 } | 937 } |
| 938 return 0; | 938 return 0; |
| 939 } | 939 } |
| 940 | 940 |
| 941 LRESULT RenderWidgetHostViewWin::OnImeSetContext( | 941 LRESULT RenderWidgetHostViewWin::OnImeSetContext( |
| 942 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 942 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 943 if (!render_widget_host_) |
| 944 return 0; |
| 945 |
| 943 // We need status messages about the focused input control from a | 946 // We need status messages about the focused input control from a |
| 944 // renderer process when: | 947 // renderer process when: |
| 945 // * the current input context has IMEs, and; | 948 // * the current input context has IMEs, and; |
| 946 // * an application is activated. | 949 // * an application is activated. |
| 947 // This seems to tell we should also check if the current input context has | 950 // This seems to tell we should also check if the current input context has |
| 948 // IMEs before sending a request, however, this WM_IME_SETCONTEXT is | 951 // IMEs before sending a request, however, this WM_IME_SETCONTEXT is |
| 949 // fortunately sent to an application only while the input context has IMEs. | 952 // fortunately sent to an application only while the input context has IMEs. |
| 950 // Therefore, we just start/stop status messages according to the activation | 953 // Therefore, we just start/stop status messages according to the activation |
| 951 // status of this application without checks. | 954 // status of this application without checks. |
| 952 bool activated = (wparam == TRUE); | 955 bool activated = (wparam == TRUE); |
| 953 if (Send(new ViewMsg_ImeSetInputMode( | 956 if (Send(new ViewMsg_ImeSetInputMode( |
| 954 render_widget_host_->routing_id(), activated))) { | 957 render_widget_host_->routing_id(), activated))) { |
| 955 ime_notification_ = activated; | 958 ime_notification_ = activated; |
| 956 } | 959 } |
| 957 | 960 |
| 958 if (ime_notification_) | 961 if (ime_notification_) |
| 959 ime_input_.CreateImeWindow(m_hWnd); | 962 ime_input_.CreateImeWindow(m_hWnd); |
| 960 | 963 |
| 961 ime_input_.CleanupComposition(m_hWnd); | 964 ime_input_.CleanupComposition(m_hWnd); |
| 962 ime_input_.SetImeWindowStyle(m_hWnd, message, wparam, lparam, &handled); | 965 ime_input_.SetImeWindowStyle(m_hWnd, message, wparam, lparam, &handled); |
| 963 return 0; | 966 return 0; |
| 964 } | 967 } |
| 965 | 968 |
| 966 LRESULT RenderWidgetHostViewWin::OnImeStartComposition( | 969 LRESULT RenderWidgetHostViewWin::OnImeStartComposition( |
| 967 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 970 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 971 if (!render_widget_host_) |
| 972 return 0; |
| 973 |
| 968 // Reset the composition status and create IME windows. | 974 // Reset the composition status and create IME windows. |
| 969 ime_input_.CreateImeWindow(m_hWnd); | 975 ime_input_.CreateImeWindow(m_hWnd); |
| 970 ime_input_.ResetComposition(m_hWnd); | 976 ime_input_.ResetComposition(m_hWnd); |
| 971 // We have to prevent WTL from calling ::DefWindowProc() because the function | 977 // We have to prevent WTL from calling ::DefWindowProc() because the function |
| 972 // calls ::ImmSetCompositionWindow() and ::ImmSetCandidateWindow() to | 978 // calls ::ImmSetCompositionWindow() and ::ImmSetCandidateWindow() to |
| 973 // over-write the position of IME windows. | 979 // over-write the position of IME windows. |
| 974 handled = TRUE; | 980 handled = TRUE; |
| 975 return 0; | 981 return 0; |
| 976 } | 982 } |
| 977 | 983 |
| 978 LRESULT RenderWidgetHostViewWin::OnImeComposition( | 984 LRESULT RenderWidgetHostViewWin::OnImeComposition( |
| 979 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 985 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 986 if (!render_widget_host_) |
| 987 return 0; |
| 988 |
| 980 // At first, update the position of the IME window. | 989 // At first, update the position of the IME window. |
| 981 ime_input_.UpdateImeWindow(m_hWnd); | 990 ime_input_.UpdateImeWindow(m_hWnd); |
| 982 | 991 |
| 983 // Retrieve the result string and its attributes of the ongoing composition | 992 // Retrieve the result string and its attributes of the ongoing composition |
| 984 // and send it to a renderer process. | 993 // and send it to a renderer process. |
| 985 ImeComposition composition; | 994 ImeComposition composition; |
| 986 if (ime_input_.GetResult(m_hWnd, lparam, &composition)) { | 995 if (ime_input_.GetResult(m_hWnd, lparam, &composition)) { |
| 987 Send(new ViewMsg_ImeSetComposition(render_widget_host_->routing_id(), | 996 Send(new ViewMsg_ImeSetComposition(render_widget_host_->routing_id(), |
| 988 WebKit::WebCompositionCommandConfirm, | 997 WebKit::WebCompositionCommandConfirm, |
| 989 composition.cursor_position, | 998 composition.cursor_position, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1007 composition.ime_string)); | 1016 composition.ime_string)); |
| 1008 } | 1017 } |
| 1009 // We have to prevent WTL from calling ::DefWindowProc() because we do not | 1018 // We have to prevent WTL from calling ::DefWindowProc() because we do not |
| 1010 // want for the IMM (Input Method Manager) to send WM_IME_CHAR messages. | 1019 // want for the IMM (Input Method Manager) to send WM_IME_CHAR messages. |
| 1011 handled = TRUE; | 1020 handled = TRUE; |
| 1012 return 0; | 1021 return 0; |
| 1013 } | 1022 } |
| 1014 | 1023 |
| 1015 LRESULT RenderWidgetHostViewWin::OnImeEndComposition( | 1024 LRESULT RenderWidgetHostViewWin::OnImeEndComposition( |
| 1016 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { | 1025 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { |
| 1026 if (!render_widget_host_) |
| 1027 return 0; |
| 1028 |
| 1017 if (ime_input_.is_composing()) { | 1029 if (ime_input_.is_composing()) { |
| 1018 // A composition has been ended while there is an ongoing composition, | 1030 // A composition has been ended while there is an ongoing composition, |
| 1019 // i.e. the ongoing composition has been canceled. | 1031 // i.e. the ongoing composition has been canceled. |
| 1020 // We need to reset the composition status both of the ImeInput object and | 1032 // We need to reset the composition status both of the ImeInput object and |
| 1021 // of the renderer process. | 1033 // of the renderer process. |
| 1022 std::wstring empty_string; | 1034 std::wstring empty_string; |
| 1023 Send(new ViewMsg_ImeSetComposition(render_widget_host_->routing_id(), | 1035 Send(new ViewMsg_ImeSetComposition(render_widget_host_->routing_id(), |
| 1024 WebKit::WebCompositionCommandDiscard, | 1036 WebKit::WebCompositionCommandDiscard, |
| 1025 -1, -1, -1, empty_string)); | 1037 -1, -1, -1, empty_string)); |
| 1026 ime_input_.ResetComposition(m_hWnd); | 1038 ime_input_.ResetComposition(m_hWnd); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1388 SetFocus(); | 1400 SetFocus(); |
| 1389 } | 1401 } |
| 1390 } | 1402 } |
| 1391 | 1403 |
| 1392 void RenderWidgetHostViewWin::ShutdownHost() { | 1404 void RenderWidgetHostViewWin::ShutdownHost() { |
| 1393 shutdown_factory_.RevokeAll(); | 1405 shutdown_factory_.RevokeAll(); |
| 1394 if (render_widget_host_) | 1406 if (render_widget_host_) |
| 1395 render_widget_host_->Shutdown(); | 1407 render_widget_host_->Shutdown(); |
| 1396 // Do not touch any members at this point, |this| has been deleted. | 1408 // Do not touch any members at this point, |this| has been deleted. |
| 1397 } | 1409 } |
| OLD | NEW |