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

Side by Side Diff: webkit/tools/test_shell/event_sending_controller.cc

Issue 5631002: wstrings: convert CppVariant and CppBoundClass to not use wstring (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This file contains the definition for EventSendingController. 5 // This file contains the definition for EventSendingController.
6 // 6 //
7 // Some notes about drag and drop handling: 7 // Some notes about drag and drop handling:
8 // Windows drag and drop goes through a system call to DoDragDrop. At that 8 // Windows drag and drop goes through a system call to DoDragDrop. At that
9 // point, program control is given to Windows which then periodically makes 9 // point, program control is given to Windows which then periodically makes
10 // callbacks into the webview. This won't work for layout tests, so instead, 10 // callbacks into the webview. This won't work for layout tests, so instead,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 e->modifiers = 0; 142 e->modifiers = 0;
143 e->x = pos.x(); 143 e->x = pos.x();
144 e->y = pos.y(); 144 e->y = pos.y();
145 e->globalX = pos.x(); 145 e->globalX = pos.x();
146 e->globalY = pos.y(); 146 e->globalY = pos.y();
147 e->timeStampSeconds = GetCurrentEventTimeSec(); 147 e->timeStampSeconds = GetCurrentEventTimeSec();
148 e->clickCount = click_count; 148 e->clickCount = click_count;
149 } 149 }
150 150
151 // Returns true if the specified key is the system key. 151 // Returns true if the specified key is the system key.
152 bool ApplyKeyModifier(const std::wstring& arg, WebInputEvent* event) { 152 bool ApplyKeyModifier(const std::string& key, WebInputEvent* event) {
153 bool system_key = false; 153 bool system_key = false;
154 const wchar_t* arg_string = arg.c_str(); 154 if (key == "ctrlKey"
155 if (!wcscmp(arg_string, L"ctrlKey")
156 #if !defined(OS_MACOSX) 155 #if !defined(OS_MACOSX)
157 || !wcscmp(arg_string, L"addSelectionKey") 156 || key == "addSelectionKey"
158 #endif 157 #endif
159 ) { 158 ) {
160 event->modifiers |= WebInputEvent::ControlKey; 159 event->modifiers |= WebInputEvent::ControlKey;
161 } else if (!wcscmp(arg_string, L"shiftKey") 160 } else if (key == "shiftKey"
viettrungluu 2010/12/03 02:00:16 Nit: reformat with standard style?
162 || !wcscmp(arg_string, L"rangeSelectionKey")) { 161 || key == "rangeSelectionKey") {
163 event->modifiers |= WebInputEvent::ShiftKey; 162 event->modifiers |= WebInputEvent::ShiftKey;
164 } else if (!wcscmp(arg_string, L"altKey")) { 163 } else if (key == "altKey") {
165 event->modifiers |= WebInputEvent::AltKey; 164 event->modifiers |= WebInputEvent::AltKey;
166 #if !defined(OS_MACOSX) 165 #if !defined(OS_MACOSX)
167 // On Windows all keys with Alt modifier will be marked as system key. 166 // On Windows all keys with Alt modifier will be marked as system key.
168 // We keep the same behavior on Linux and everywhere non-Mac, see: 167 // We keep the same behavior on Linux and everywhere non-Mac, see:
169 // third_party/WebKit/WebKit/chromium/src/gtk/WebInputEventFactory.cpp 168 // third_party/WebKit/WebKit/chromium/src/gtk/WebInputEventFactory.cpp
170 // If we want to change this behavior on Linux, this piece of code must be 169 // If we want to change this behavior on Linux, this piece of code must be
171 // kept in sync with the related code in above file. 170 // kept in sync with the related code in above file.
172 system_key = true; 171 system_key = true;
173 #endif 172 #endif
174 #if defined(OS_MACOSX) 173 #if defined(OS_MACOSX)
175 } else if (!wcscmp(arg_string, L"metaKey") 174 } else if (key == "metaKey"
viettrungluu 2010/12/03 02:00:16 "
176 || !wcscmp(arg_string, L"addSelectionKey")) { 175 || key == "addSelectionKey") {
177 event->modifiers |= WebInputEvent::MetaKey; 176 event->modifiers |= WebInputEvent::MetaKey;
178 // On Mac only command key presses are marked as system key. 177 // On Mac only command key presses are marked as system key.
179 // See the related code in: 178 // See the related code in:
180 // third_party/WebKit/WebKit/chromium/src/mac/WebInputEventFactory.cpp 179 // third_party/WebKit/WebKit/chromium/src/mac/WebInputEventFactory.cpp
181 // It must be kept in sync with the related code in above file. 180 // It must be kept in sync with the related code in above file.
182 system_key = true; 181 system_key = true;
183 #else 182 #else
184 } else if (!wcscmp(arg_string, L"metaKey")) { 183 } else if (key == "metaKey") {
185 event->modifiers |= WebInputEvent::MetaKey; 184 event->modifiers |= WebInputEvent::MetaKey;
186 #endif 185 #endif
187 } 186 }
188 return system_key; 187 return system_key;
189 } 188 }
190 189
191 bool ApplyKeyModifiers(const CppVariant* arg, WebInputEvent* event) { 190 bool ApplyKeyModifiers(const CppVariant* arg, WebInputEvent* event) {
192 bool system_key = false; 191 bool system_key = false;
193 if (arg->isObject()) { 192 if (arg->isObject()) {
194 std::vector<std::wstring> args = arg->ToStringVector(); 193 std::vector<std::string> args = arg->ToStringVector();
195 for (std::vector<std::wstring>::const_iterator i = args.begin(); 194 for (std::vector<std::string>::const_iterator i = args.begin();
196 i != args.end(); ++i) { 195 i != args.end(); ++i) {
197 system_key |= ApplyKeyModifier(*i, event); 196 system_key |= ApplyKeyModifier(*i, event);
198 } 197 }
199 } else if (arg->isString()) { 198 } else if (arg->isString()) {
200 system_key = ApplyKeyModifier(UTF8ToWide(arg->ToString()), event); 199 system_key = ApplyKeyModifier(arg->ToString(), event);
201 } 200 }
202 return system_key; 201 return system_key;
203 } 202 }
204 203
205 // Get the edit command corresponding to a keyboard event. 204 // Get the edit command corresponding to a keyboard event.
206 // Returns true if the specified event corresponds to an edit command, the name 205 // Returns true if the specified event corresponds to an edit command, the name
207 // of the edit command will be stored in |*name|. 206 // of the edit command will be stored in |*name|.
208 bool GetEditCommand(const WebKeyboardEvent& event, std::string* name) { 207 bool GetEditCommand(const WebKeyboardEvent& event, std::string* name) {
209 #if defined(OS_MACOSX) 208 #if defined(OS_MACOSX)
210 // We only cares about Left,Right,Up,Down keys with Command or Command+Shift 209 // We only cares about Left,Right,Up,Down keys with Command or Command+Shift
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 method_factory_.NewRunnableMethod(&EventSendingController::mouseDown, 855 method_factory_.NewRunnableMethod(&EventSendingController::mouseDown,
857 args, static_cast<CppVariant*>(NULL))); 856 args, static_cast<CppVariant*>(NULL)));
858 MessageLoop::current()->PostTask(FROM_HERE, 857 MessageLoop::current()->PostTask(FROM_HERE,
859 method_factory_.NewRunnableMethod(&EventSendingController::mouseUp, 858 method_factory_.NewRunnableMethod(&EventSendingController::mouseUp,
860 args, static_cast<CppVariant*>(NULL))); 859 args, static_cast<CppVariant*>(NULL)));
861 } 860 }
862 861
863 void EventSendingController::beginDragWithFiles( 862 void EventSendingController::beginDragWithFiles(
864 const CppArgumentList& args, CppVariant* result) { 863 const CppArgumentList& args, CppVariant* result) {
865 current_drag_data.initialize(); 864 current_drag_data.initialize();
866 std::vector<std::wstring> files = args[0].ToStringVector(); 865 std::vector<std::string> files = args[0].ToStringVector();
867 for (size_t i = 0; i < files.size(); ++i) { 866 for (size_t i = 0; i < files.size(); ++i) {
868 FilePath file_path = FilePath::FromWStringHack(files[i]); 867 std::wstring file = UTF8ToWide(files[i]);
868 FilePath file_path = FilePath::FromWStringHack(file);
869 file_util::AbsolutePath(&file_path); 869 file_util::AbsolutePath(&file_path);
870 current_drag_data.appendToFilenames( 870 current_drag_data.appendToFilenames(
871 webkit_glue::FilePathStringToWebString(file_path.value())); 871 webkit_glue::FilePathStringToWebString(file_path.value()));
872 } 872 }
873 current_drag_effects_allowed = WebKit::WebDragOperationCopy; 873 current_drag_effects_allowed = WebKit::WebDragOperationCopy;
874 874
875 // Provide a drag source. 875 // Provide a drag source.
876 WebPoint client_point(last_mouse_pos_.x(), last_mouse_pos_.y()); 876 WebPoint client_point(last_mouse_pos_.x(), last_mouse_pos_.y());
877 WebPoint screen_point(last_mouse_pos_.x(), last_mouse_pos_.y()); 877 WebPoint screen_point(last_mouse_pos_.x(), last_mouse_pos_.y());
878 webview()->dragTargetDragEnter( 878 webview()->dragTargetDragEnter(
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 1072
1073 void EventSendingController::fireKeyboardEventsToElement( 1073 void EventSendingController::fireKeyboardEventsToElement(
1074 const CppArgumentList& args, CppVariant* result) { 1074 const CppArgumentList& args, CppVariant* result) {
1075 result->SetNull(); 1075 result->SetNull();
1076 } 1076 }
1077 1077
1078 void EventSendingController::clearKillRing( 1078 void EventSendingController::clearKillRing(
1079 const CppArgumentList& args, CppVariant* result) { 1079 const CppArgumentList& args, CppVariant* result) {
1080 result->SetNull(); 1080 result->SetNull();
1081 } 1081 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698