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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_win.cc

Issue 149620: Use WebWidget from the WebKit API. This change also makes... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "app/l10n_util_win.h" 9 #include "app/l10n_util_win.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 24 matching lines...) Expand all
35 #include "webkit/glue/plugins/plugin_constants_win.h" 35 #include "webkit/glue/plugins/plugin_constants_win.h"
36 #include "webkit/glue/plugins/webplugin_delegate_impl.h" 36 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
37 #include "webkit/glue/webcursor.h" 37 #include "webkit/glue/webcursor.h"
38 38
39 using base::TimeDelta; 39 using base::TimeDelta;
40 using base::TimeTicks; 40 using base::TimeTicks;
41 41
42 using WebKit::WebInputEvent; 42 using WebKit::WebInputEvent;
43 using WebKit::WebInputEventFactory; 43 using WebKit::WebInputEventFactory;
44 using WebKit::WebMouseEvent; 44 using WebKit::WebMouseEvent;
45 using WebKit::WebTextDirection;
45 46
46 namespace { 47 namespace {
47 48
48 // Tooltips will wrap after this width. Yes, wrap. Imagine that! 49 // Tooltips will wrap after this width. Yes, wrap. Imagine that!
49 const int kTooltipMaxWidthPixels = 300; 50 const int kTooltipMaxWidthPixels = 300;
50 51
51 // Maximum number of characters we allow in a tooltip. 52 // Maximum number of characters we allow in a tooltip.
52 const int kMaxTooltipLength = 1024; 53 const int kMaxTooltipLength = 1024;
53 54
54 // A callback function for EnumThreadWindows to enumerate and dismiss 55 // A callback function for EnumThreadWindows to enumerate and dismiss
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return false; 106 return false;
106 } 107 }
107 108
108 // Returns the text direction according to the keyboard status. 109 // Returns the text direction according to the keyboard status.
109 // This function retrieves the status of all keys and returns the following 110 // This function retrieves the status of all keys and returns the following
110 // values: 111 // values:
111 // * WEB_TEXT_DIRECTION_RTL 112 // * WEB_TEXT_DIRECTION_RTL
112 // If only a control key and a right-shift key are down. 113 // If only a control key and a right-shift key are down.
113 // * WEB_TEXT_DIRECTION_LTR 114 // * WEB_TEXT_DIRECTION_LTR
114 // If only a control key and a left-shift key are down. 115 // If only a control key and a left-shift key are down.
116
115 static bool GetNewTextDirection(WebTextDirection* direction) { 117 static bool GetNewTextDirection(WebTextDirection* direction) {
116 uint8_t keystate[256]; 118 uint8_t keystate[256];
117 if (!GetKeyboardState(&keystate[0])) 119 if (!GetKeyboardState(&keystate[0]))
118 return false; 120 return false;
119 121
120 // To check if a user is pressing only a control key and a right-shift key 122 // To check if a user is pressing only a control key and a right-shift key
121 // (or a left-shift key), we use the steps below: 123 // (or a left-shift key), we use the steps below:
122 // 1. Check if a user is pressing a control key and a right-shift key (or 124 // 1. Check if a user is pressing a control key and a right-shift key (or
123 // a left-shift key). 125 // a left-shift key).
124 // 2. If the condition 1 is true, we should check if there are any other 126 // 2. If the condition 1 is true, we should check if there are any other
125 // keys pressed at the same time. 127 // keys pressed at the same time.
126 // To ignore the keys checked in 1, we set their status to 0 before 128 // To ignore the keys checked in 1, we set their status to 0 before
127 // checking the key status. 129 // checking the key status.
128 const int kKeyDownMask = 0x80; 130 const int kKeyDownMask = 0x80;
129 if ((keystate[VK_CONTROL] & kKeyDownMask) == 0) 131 if ((keystate[VK_CONTROL] & kKeyDownMask) == 0)
130 return false; 132 return false;
131 133
132 if (keystate[VK_RSHIFT] & kKeyDownMask) { 134 if (keystate[VK_RSHIFT] & kKeyDownMask) {
133 keystate[VK_RSHIFT] = 0; 135 keystate[VK_RSHIFT] = 0;
134 *direction = WEB_TEXT_DIRECTION_RTL; 136 *direction = WebKit::WebTextDirectionRightToLeft;
135 } else if (keystate[VK_LSHIFT] & kKeyDownMask) { 137 } else if (keystate[VK_LSHIFT] & kKeyDownMask) {
136 keystate[VK_LSHIFT] = 0; 138 keystate[VK_LSHIFT] = 0;
137 *direction = WEB_TEXT_DIRECTION_LTR; 139 *direction = WebKit::WebTextDirectionLeftToRight;
138 } else { 140 } else {
139 return false; 141 return false;
140 } 142 }
141 143
142 // Scan the key status to find pressed keys. We should adandon changing the 144 // Scan the key status to find pressed keys. We should adandon changing the
143 // text direction when there are other pressed keys. 145 // text direction when there are other pressed keys.
144 // This code is executed only when a user is pressing a control key and a 146 // This code is executed only when a user is pressing a control key and a
145 // right-shift key (or a left-shift key), i.e. we should ignore the status of 147 // right-shift key (or a left-shift key), i.e. we should ignore the status of
146 // the keys: VK_SHIFT, VK_CONTROL, VK_RCONTROL, and VK_LCONTROL. 148 // the keys: VK_SHIFT, VK_CONTROL, VK_RCONTROL, and VK_LCONTROL.
147 // So, we reset their status to 0 and ignore them. 149 // So, we reset their status to 0 and ignore them.
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 LRESULT RenderWidgetHostViewWin::OnImeComposition( 936 LRESULT RenderWidgetHostViewWin::OnImeComposition(
935 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { 937 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) {
936 // At first, update the position of the IME window. 938 // At first, update the position of the IME window.
937 ime_input_.UpdateImeWindow(m_hWnd); 939 ime_input_.UpdateImeWindow(m_hWnd);
938 940
939 // Retrieve the result string and its attributes of the ongoing composition 941 // Retrieve the result string and its attributes of the ongoing composition
940 // and send it to a renderer process. 942 // and send it to a renderer process.
941 ImeComposition composition; 943 ImeComposition composition;
942 if (ime_input_.GetResult(m_hWnd, lparam, &composition)) { 944 if (ime_input_.GetResult(m_hWnd, lparam, &composition)) {
943 Send(new ViewMsg_ImeSetComposition(render_widget_host_->routing_id(), 945 Send(new ViewMsg_ImeSetComposition(render_widget_host_->routing_id(),
944 1, 946 WebKit::WebCompositionCommandConfirm,
945 composition.cursor_position, 947 composition.cursor_position,
946 composition.target_start, 948 composition.target_start,
947 composition.target_end, 949 composition.target_end,
948 composition.ime_string)); 950 composition.ime_string));
949 ime_input_.ResetComposition(m_hWnd); 951 ime_input_.ResetComposition(m_hWnd);
950 // Fall though and try reading the composition string. 952 // Fall though and try reading the composition string.
951 // Japanese IMEs send a message containing both GCS_RESULTSTR and 953 // Japanese IMEs send a message containing both GCS_RESULTSTR and
952 // GCS_COMPSTR, which means an ongoing composition has been finished 954 // GCS_COMPSTR, which means an ongoing composition has been finished
953 // by the start of another composition. 955 // by the start of another composition.
954 } 956 }
955 // Retrieve the composition string and its attributes of the ongoing 957 // Retrieve the composition string and its attributes of the ongoing
956 // composition and send it to a renderer process. 958 // composition and send it to a renderer process.
957 if (ime_input_.GetComposition(m_hWnd, lparam, &composition)) { 959 if (ime_input_.GetComposition(m_hWnd, lparam, &composition)) {
958 Send(new ViewMsg_ImeSetComposition(render_widget_host_->routing_id(), 960 Send(new ViewMsg_ImeSetComposition(render_widget_host_->routing_id(),
959 0, 961 WebKit::WebCompositionCommandSet,
960 composition.cursor_position, 962 composition.cursor_position,
961 composition.target_start, 963 composition.target_start,
962 composition.target_end, 964 composition.target_end,
963 composition.ime_string)); 965 composition.ime_string));
964 } 966 }
965 // We have to prevent WTL from calling ::DefWindowProc() because we do not 967 // We have to prevent WTL from calling ::DefWindowProc() because we do not
966 // want for the IMM (Input Method Manager) to send WM_IME_CHAR messages. 968 // want for the IMM (Input Method Manager) to send WM_IME_CHAR messages.
967 handled = TRUE; 969 handled = TRUE;
968 return 0; 970 return 0;
969 } 971 }
970 972
971 LRESULT RenderWidgetHostViewWin::OnImeEndComposition( 973 LRESULT RenderWidgetHostViewWin::OnImeEndComposition(
972 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { 974 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) {
973 if (ime_input_.is_composing()) { 975 if (ime_input_.is_composing()) {
974 // A composition has been ended while there is an ongoing composition, 976 // A composition has been ended while there is an ongoing composition,
975 // i.e. the ongoing composition has been canceled. 977 // i.e. the ongoing composition has been canceled.
976 // We need to reset the composition status both of the ImeInput object and 978 // We need to reset the composition status both of the ImeInput object and
977 // of the renderer process. 979 // of the renderer process.
978 std::wstring empty_string; 980 std::wstring empty_string;
979 Send(new ViewMsg_ImeSetComposition(render_widget_host_->routing_id(), 981 Send(new ViewMsg_ImeSetComposition(render_widget_host_->routing_id(),
980 -1, -1, -1, -1, empty_string)); 982 WebKit::WebCompositionCommandDiscard,
983 -1, -1, -1, empty_string));
981 ime_input_.ResetComposition(m_hWnd); 984 ime_input_.ResetComposition(m_hWnd);
982 } 985 }
983 ime_input_.DestroyImeWindow(m_hWnd); 986 ime_input_.DestroyImeWindow(m_hWnd);
984 // Let WTL call ::DefWindowProc() and release its resources. 987 // Let WTL call ::DefWindowProc() and release its resources.
985 handled = FALSE; 988 handled = FALSE;
986 return 0; 989 return 0;
987 } 990 }
988 991
989 LRESULT RenderWidgetHostViewWin::OnMouseEvent(UINT message, WPARAM wparam, 992 LRESULT RenderWidgetHostViewWin::OnMouseEvent(UINT message, WPARAM wparam,
990 LPARAM lparam, BOOL& handled) { 993 LPARAM lparam, BOOL& handled) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 // WM_LBUTTONDOWN. 1321 // WM_LBUTTONDOWN.
1319 SetFocus(); 1322 SetFocus();
1320 } 1323 }
1321 } 1324 }
1322 1325
1323 void RenderWidgetHostViewWin::ShutdownHost() { 1326 void RenderWidgetHostViewWin::ShutdownHost() {
1324 shutdown_factory_.RevokeAll(); 1327 shutdown_factory_.RevokeAll();
1325 render_widget_host_->Shutdown(); 1328 render_widget_host_->Shutdown();
1326 // Do not touch any members at this point, |this| has been deleted. 1329 // Do not touch any members at this point, |this| has been deleted.
1327 } 1330 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_gtk.cc ('k') | chrome/common/render_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698