| OLD | NEW |
| 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 | 5 |
| 6 /* | 6 /* |
| 7 EventSendingController class: | 7 EventSendingController class: |
| 8 Bound to a JavaScript window.eventSender object using | 8 Bound to a JavaScript window.eventSender object using |
| 9 CppBoundClass::BindToJavascript(), this allows layout tests that are run in | 9 CppBoundClass::BindToJavascript(), this allows layout tests that are run in |
| 10 the test_shell to fire DOM events. | 10 the test_shell to fire DOM events. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/task.h" | 21 #include "base/task.h" |
| 22 #include "webkit/api/public/WebDragOperation.h" | 22 #include "webkit/api/public/WebDragOperation.h" |
| 23 #include "webkit/api/public/WebInputEvent.h" | 23 #include "webkit/api/public/WebInputEvent.h" |
| 24 #include "webkit/glue/cpp_bound_class.h" | 24 #include "webkit/glue/cpp_bound_class.h" |
| 25 | 25 |
| 26 class TestShell; | 26 class TestShell; |
| 27 class WebView; | 27 class WebView; |
| 28 | 28 |
| 29 namespace WebKit { | 29 namespace WebKit { |
| 30 class WebDragData; | 30 class WebDragData; |
| 31 class WebMouseEvent; | |
| 32 struct WebPoint; | 31 struct WebPoint; |
| 33 } | 32 } |
| 34 | 33 |
| 35 class EventSendingController : public CppBoundClass { | 34 class EventSendingController : public CppBoundClass { |
| 36 public: | 35 public: |
| 37 // Builds the property and method lists needed to bind this class to a JS | 36 // Builds the property and method lists needed to bind this class to a JS |
| 38 // object. | 37 // object. |
| 39 EventSendingController(TestShell* shell); | 38 EventSendingController(TestShell* shell); |
| 40 | 39 |
| 41 // Resets some static variable state. | 40 // Resets some static variable state. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // Returns the test shell's webview. | 83 // Returns the test shell's webview. |
| 85 static WebView* webview(); | 84 static WebView* webview(); |
| 86 | 85 |
| 87 // Returns true if dragMode is true. | 86 // Returns true if dragMode is true. |
| 88 bool drag_mode() { return dragMode.isBool() && dragMode.ToBoolean(); } | 87 bool drag_mode() { return dragMode.isBool() && dragMode.ToBoolean(); } |
| 89 | 88 |
| 90 // Sometimes we queue up mouse move and mouse up events for drag drop | 89 // Sometimes we queue up mouse move and mouse up events for drag drop |
| 91 // handling purposes. These methods dispatch the event. | 90 // handling purposes. These methods dispatch the event. |
| 92 static void DoMouseMove(const WebKit::WebMouseEvent& e); | 91 static void DoMouseMove(const WebKit::WebMouseEvent& e); |
| 93 static void DoMouseUp(const WebKit::WebMouseEvent& e); | 92 static void DoMouseUp(const WebKit::WebMouseEvent& e); |
| 93 static void DoLeapForward(int milliseconds); |
| 94 static void ReplaySavedEvents(); | 94 static void ReplaySavedEvents(); |
| 95 | 95 |
| 96 // Helper to return the button type given a button code | 96 // Helper to return the button type given a button code |
| 97 static WebKit::WebMouseEvent::Button GetButtonTypeFromButtonNumber( | 97 static WebKit::WebMouseEvent::Button GetButtonTypeFromButtonNumber( |
| 98 int button_code); | 98 int button_code); |
| 99 | 99 |
| 100 // Helper to extract the button number from the optional argument in | 100 // Helper to extract the button number from the optional argument in |
| 101 // mouseDown and mouseUp | 101 // mouseDown and mouseUp |
| 102 static int GetButtonNumberFromSingleArg(const CppArgumentList& args); | 102 static int GetButtonNumberFromSingleArg(const CppArgumentList& args); |
| 103 | 103 |
| 104 // Returns true if the key_code passed in needs a shift key modifier to | 104 // Returns true if the key_code passed in needs a shift key modifier to |
| 105 // be passed into the generated event. | 105 // be passed into the generated event. |
| 106 bool NeedsShiftModifier(int key_code); | 106 bool NeedsShiftModifier(int key_code); |
| 107 | 107 |
| 108 void UpdateClickCountForButton(int button_number); |
| 109 |
| 108 ScopedRunnableMethodFactory<EventSendingController> method_factory_; | 110 ScopedRunnableMethodFactory<EventSendingController> method_factory_; |
| 109 | 111 |
| 110 // Non-owning pointer. The LayoutTestController is owned by the host. | 112 // Non-owning pointer. The LayoutTestController is owned by the host. |
| 111 static TestShell* shell_; | 113 static TestShell* shell_; |
| 112 | 114 |
| 113 // Location of last mouseMoveTo event. | 115 // Location of last mouseMoveTo event. |
| 114 static gfx::Point last_mouse_pos_; | 116 static gfx::Point last_mouse_pos_; |
| 115 | 117 |
| 116 // Currently pressed mouse button (Left/Right/Middle or None) | 118 // Currently pressed mouse button (Left/Right/Middle or None) |
| 117 static WebKit::WebMouseEvent::Button pressed_button_; | 119 static WebKit::WebMouseEvent::Button pressed_button_; |
| 118 | 120 |
| 119 // The last button number passed to mouseDown and mouseUp. | 121 // The last button number passed to mouseDown and mouseUp. |
| 120 // Used to determine whether the click count continues to | 122 // Used to determine whether the click count continues to |
| 121 // increment or not. | 123 // increment or not. |
| 122 static int last_button_number_; | 124 static int last_button_number_; |
| 123 }; | 125 }; |
| 124 | 126 |
| 125 #endif // WEBKIT_TOOLS_TEST_SHELL_EVENT_SENDING_CONTROLLER_H_ | 127 #endif // WEBKIT_TOOLS_TEST_SHELL_EVENT_SENDING_CONTROLLER_H_ |
| OLD | NEW |