diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 23:30:22 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 23:30:22 +0000 |
commit | 62cb33cae4bad68a085b50832c8a7f1e1c2e917c (patch) | |
tree | 4eddbf29c7ae1c41fd1300ae4ce95b817404bbaf /webkit/glue | |
parent | 57346c5659ada3c2a06095afac6e53bedf41ab94 (diff) | |
download | chromium_src-62cb33cae4bad68a085b50832c8a7f1e1c2e917c.zip chromium_src-62cb33cae4bad68a085b50832c8a7f1e1c2e917c.tar.gz chromium_src-62cb33cae4bad68a085b50832c8a7f1e1c2e917c.tar.bz2 |
Use Webkit::WebInputEvent and remove webkit/glue/webinputevent.
This change adds a temporary dependency on src/KeyIdentifier.{h,cpp} which I am going to remove after this CL. I didn't want to grow this CL any larger.
R=dglazkov
Review URL: http://codereview.chromium.org/53099
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12728 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/SConscript | 3 | ||||
-rw-r--r-- | webkit/glue/chrome_client_impl.cc | 9 | ||||
-rw-r--r-- | webkit/glue/context_menu_unittest.cc | 15 | ||||
-rw-r--r-- | webkit/glue/event_conversion.cc | 85 | ||||
-rw-r--r-- | webkit/glue/event_conversion.h | 10 | ||||
-rw-r--r-- | webkit/glue/glue.vcproj | 16 | ||||
-rw-r--r-- | webkit/glue/webinputevent.h | 206 | ||||
-rw-r--r-- | webkit/glue/webinputevent_util.cc | 120 | ||||
-rw-r--r-- | webkit/glue/webinputevent_util.h | 18 | ||||
-rw-r--r-- | webkit/glue/webinputevent_win.cc | 345 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 91 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 39 | ||||
-rw-r--r-- | webkit/glue/webwidget.h | 5 | ||||
-rw-r--r-- | webkit/glue/webwidget_impl.cc | 25 | ||||
-rw-r--r-- | webkit/glue/webwidget_impl.h | 35 |
15 files changed, 172 insertions, 850 deletions
diff --git a/webkit/glue/SConscript b/webkit/glue/SConscript index 5e364ae..73aef79 100644 --- a/webkit/glue/SConscript +++ b/webkit/glue/SConscript @@ -135,7 +135,6 @@ if env.Bit('windows'): 'plugins/plugin_list_win.cc', 'plugins/plugin_stream_win.cc', 'webcursor_win.cc', - 'webinputevent_win.cc', 'webkit_glue_win.cc', ]) elif env.Bit('linux'): @@ -144,8 +143,6 @@ elif env.Bit('linux'): 'plugins/plugin_list_linux.cc', 'plugins/webplugin_delegate_impl_gtk.cc', 'webcursor_gtk.cc', - 'webinputevent_linux.cc', - 'webinputevent_util.cc', 'webkit_glue_gtk.cc', ]) elif env.Bit('mac'): diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index 6b574d5..60cfe9b 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -30,16 +30,19 @@ MSVC_POP_WARNING(); #include "base/logging.h" #include "base/gfx/rect.h" #include "googleurl/src/gurl.h" +#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webframe_impl.h" -#include "webkit/glue/webinputevent.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/weburlrequest_impl.h" #include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview_impl.h" #include "webkit/glue/webwidget_impl.h" +using WebKit::WebInputEvent; +using WebKit::WebMouseEvent; + // Callback class that's given to the WebViewDelegate during a file choose // operation. class WebFileChooserCallbackImpl : public WebFileChooserCallback { @@ -191,11 +194,11 @@ static inline bool CurrentEventShouldCauseBackgroundTab( if (!input_event) return false; - if (input_event->type != WebInputEvent::MOUSE_UP) + if (input_event->type != WebInputEvent::MouseUp) return false; const WebMouseEvent* mouse_event = static_cast<const WebMouseEvent*>(input_event); - return (mouse_event->button == WebMouseEvent::BUTTON_MIDDLE); + return (mouse_event->button == WebMouseEvent::ButtonMiddle); } void ChromeClientImpl::show() { diff --git a/webkit/glue/context_menu_unittest.cc b/webkit/glue/context_menu_unittest.cc index d54d1f3..b7ff8ed 100644 --- a/webkit/glue/context_menu_unittest.cc +++ b/webkit/glue/context_menu_unittest.cc @@ -14,6 +14,8 @@ #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_shell_test.h" +using WebKit::WebInputEvent; +using WebKit::WebMouseEvent; // Right clicking inside on an iframe should produce a context menu class ContextMenuCapturing : public TestShellTest { @@ -45,21 +47,18 @@ TEST_F(ContextMenuCapturing, ContextMenuCapturing) { // Create a right click in the center of the iframe. (I'm hoping this will // make this a bit more robust in case of some other formatting or other bug.) WebMouseEvent mouse_event; - mouse_event.type = WebInputEvent::MOUSE_DOWN; - mouse_event.modifiers = 0; - mouse_event.button = WebMouseEvent::BUTTON_RIGHT; + mouse_event.type = WebInputEvent::MouseDown; + mouse_event.button = WebMouseEvent::ButtonRight; mouse_event.x = 250; mouse_event.y = 250; - mouse_event.global_x = 250; - mouse_event.global_y = 250; - mouse_event.timestamp_sec = 0; - mouse_event.layout_test_click_count = 0; + mouse_event.globalX = 250; + mouse_event.globalY = 250; WebView* webview = test_shell_->webView(); webview->HandleInputEvent(&mouse_event); // Now simulate the corresponding up event which should display the menu - mouse_event.type = WebInputEvent::MOUSE_UP; + mouse_event.type = WebInputEvent::MouseUp; webview->HandleInputEvent(&mouse_event); EXPECT_EQ(1U, test_delegate->captured_context_menu_events().size()); diff --git a/webkit/glue/event_conversion.cc b/webkit/glue/event_conversion.cc index 826c02f..ae2ed73 100644 --- a/webkit/glue/event_conversion.cc +++ b/webkit/glue/event_conversion.cc @@ -15,13 +15,18 @@ #undef LOG #include "base/gfx/point.h" #include "base/logging.h" +#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "webkit/glue/glue_util.h" -#include "webkit/glue/webinputevent.h" #include "webkit/glue/webkit_glue.h" using namespace WebCore; +using WebKit::WebInputEvent; +using WebKit::WebKeyboardEvent; +using WebKit::WebMouseEvent; +using WebKit::WebMouseWheelEvent; + // MakePlatformMouseEvent ----------------------------------------------------- int MakePlatformMouseEvent::last_click_count_ = 0; @@ -32,14 +37,14 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget, // TODO(mpcomplete): widget is always toplevel, unless it's a popup. We // may be able to get rid of this once we abstract popups into a WebKit API. m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y)); - m_globalPosition = IntPoint(e.global_x, e.global_y); + m_globalPosition = IntPoint(e.globalX, e.globalY); m_button = static_cast<MouseButton>(e.button); - m_shiftKey = (e.modifiers & WebInputEvent::SHIFT_KEY) != 0; - m_ctrlKey = (e.modifiers & WebInputEvent::CTRL_KEY) != 0; - m_altKey = (e.modifiers & WebInputEvent::ALT_KEY) != 0; - m_metaKey = (e.modifiers & WebInputEvent::META_KEY) != 0; + m_shiftKey = (e.modifiers & WebInputEvent::ShiftKey) != 0; + m_ctrlKey = (e.modifiers & WebInputEvent::ControlKey) != 0; + m_altKey = (e.modifiers & WebInputEvent::AltKey) != 0; + m_metaKey = (e.modifiers & WebInputEvent::MetaKey) != 0; m_modifierFlags = e.modifiers; - m_timestamp = e.timestamp_sec; + m_timestamp = e.timeStampSeconds; // This differs slightly from the WebKit code in WebKit/win/WebView.cpp where // their original code looks buggy. @@ -59,8 +64,8 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget, #endif switch (e.type) { - case WebInputEvent::MOUSE_MOVE: - case WebInputEvent::MOUSE_LEAVE: // synthesize a move event + case WebInputEvent::MouseMove: + case WebInputEvent::MouseLeave: // synthesize a move event if (cancel_previous_click) { last_click_count_ = 0; last_click_position = IntPoint(); @@ -72,18 +77,18 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget, // TODO(port): make these platform agnostic when we restructure this code. #if defined(OS_LINUX) || defined(OS_MACOSX) - case WebInputEvent::MOUSE_DOUBLE_CLICK: + case WebInputEvent::MouseDoubleClick: ++m_clickCount; // fall through - case WebInputEvent::MOUSE_DOWN: + case WebInputEvent::MouseDown: ++m_clickCount; last_click_time_ = current_time; last_click_button = m_button; m_eventType = MouseEventPressed; break; #else - case WebInputEvent::MOUSE_DOWN: - case WebInputEvent::MOUSE_DOUBLE_CLICK: + case WebInputEvent::MouseDown: + case WebInputEvent::MouseDoubleClick: if (!cancel_previous_click && (m_button == last_click_button)) { ++last_click_count_; } else { @@ -97,7 +102,7 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget, break; #endif - case WebInputEvent::MOUSE_UP: + case WebInputEvent::MouseUp: m_clickCount = last_click_count_; m_eventType = MouseEventReleased; break; @@ -107,7 +112,7 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget, } if (WebKit::layoutTestMode()) { - m_clickCount = e.layout_test_click_count; + m_clickCount = e.layoutTestClickCount; } } @@ -116,18 +121,18 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget, MakePlatformWheelEvent::MakePlatformWheelEvent(Widget* widget, const WebMouseWheelEvent& e) { m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y)); - m_globalPosition = IntPoint(e.global_x, e.global_y); - m_deltaX = e.delta_x; - m_deltaY = e.delta_y; - m_wheelTicksX = e.wheel_ticks_x; - m_wheelTicksY = e.wheel_ticks_y; + m_globalPosition = IntPoint(e.globalX, e.globalY); + m_deltaX = e.deltaX; + m_deltaY = e.deltaY; + m_wheelTicksX = e.wheelTicksX; + m_wheelTicksY = e.wheelTicksY; m_isAccepted = false; - m_granularity = e.scroll_by_page ? + m_granularity = e.scrollByPage ? ScrollByPageWheelEvent : ScrollByPixelWheelEvent; - m_shiftKey = (e.modifiers & WebInputEvent::SHIFT_KEY) != 0; - m_ctrlKey = (e.modifiers & WebInputEvent::CTRL_KEY) != 0; - m_altKey = (e.modifiers & WebInputEvent::ALT_KEY) != 0; - m_metaKey = (e.modifiers & WebInputEvent::META_KEY) != 0; + m_shiftKey = (e.modifiers & WebInputEvent::ShiftKey) != 0; + m_ctrlKey = (e.modifiers & WebInputEvent::ControlKey) != 0; + m_altKey = (e.modifiers & WebInputEvent::AltKey) != 0; + m_metaKey = (e.modifiers & WebInputEvent::MetaKey) != 0; } // MakePlatformKeyboardEvent -------------------------------------------------- @@ -135,13 +140,13 @@ MakePlatformWheelEvent::MakePlatformWheelEvent(Widget* widget, static inline const PlatformKeyboardEvent::Type ToPlatformKeyboardEventType( WebInputEvent::Type type) { switch (type) { - case WebInputEvent::KEY_UP: + case WebInputEvent::KeyUp: return PlatformKeyboardEvent::KeyUp; - case WebInputEvent::KEY_DOWN: + case WebInputEvent::KeyDown: return PlatformKeyboardEvent::KeyDown; - case WebInputEvent::RAW_KEY_DOWN: + case WebInputEvent::RawKeyDown: return PlatformKeyboardEvent::RawKeyDown; - case WebInputEvent::CHAR: + case WebInputEvent::Char: return PlatformKeyboardEvent::Char; default: ASSERT_NOT_REACHED(); @@ -153,17 +158,17 @@ MakePlatformKeyboardEvent::MakePlatformKeyboardEvent( const WebKeyboardEvent& e) { m_type = ToPlatformKeyboardEventType(e.type); m_text = WebCore::String(e.text); - m_unmodifiedText = WebCore::String(e.unmodified_text); - m_keyIdentifier = WebCore::String(e.key_identifier); - m_autoRepeat = (e.modifiers & WebInputEvent::IS_AUTO_REPEAT) != 0; - m_windowsVirtualKeyCode = e.windows_key_code; - m_nativeVirtualKeyCode = e.native_key_code; - m_isKeypad = (e.modifiers & WebInputEvent::IS_KEYPAD) != 0; - m_shiftKey = (e.modifiers & WebInputEvent::SHIFT_KEY) != 0; - m_ctrlKey = (e.modifiers & WebInputEvent::CTRL_KEY) != 0; - m_altKey = (e.modifiers & WebInputEvent::ALT_KEY) != 0; - m_metaKey = (e.modifiers & WebInputEvent::META_KEY) != 0; - m_isSystemKey = e.system_key; + m_unmodifiedText = WebCore::String(e.unmodifiedText); + m_keyIdentifier = WebCore::String(e.keyIdentifier); + m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat) != 0; + m_windowsVirtualKeyCode = e.windowsKeyCode; + m_nativeVirtualKeyCode = e.nativeKeyCode; + m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad) != 0; + m_shiftKey = (e.modifiers & WebInputEvent::ShiftKey) != 0; + m_ctrlKey = (e.modifiers & WebInputEvent::ControlKey) != 0; + m_altKey = (e.modifiers & WebInputEvent::AltKey) != 0; + m_metaKey = (e.modifiers & WebInputEvent::MetaKey) != 0; + m_isSystemKey = e.isSystemKey; } void MakePlatformKeyboardEvent::SetKeyType(Type type) { diff --git a/webkit/glue/event_conversion.h b/webkit/glue/event_conversion.h index 05cb4cd..3f49938 100644 --- a/webkit/glue/event_conversion.h +++ b/webkit/glue/event_conversion.h @@ -18,16 +18,19 @@ namespace WebCore { class Widget; } +namespace WebKit { class WebMouseEvent; class WebMouseWheelEvent; class WebKeyboardEvent; +} // These classes are used to convert from WebInputEvent subclasses to // corresponding WebCore events. class MakePlatformMouseEvent : public WebCore::PlatformMouseEvent { public: - MakePlatformMouseEvent(WebCore::Widget* widget, const WebMouseEvent& e); + MakePlatformMouseEvent( + WebCore::Widget* widget, const WebKit::WebMouseEvent& e); static void ResetLastClick() { last_click_time_ = last_click_count_ = 0; @@ -40,12 +43,13 @@ class MakePlatformMouseEvent : public WebCore::PlatformMouseEvent { class MakePlatformWheelEvent : public WebCore::PlatformWheelEvent { public: - MakePlatformWheelEvent(WebCore::Widget* widget, const WebMouseWheelEvent& e); + MakePlatformWheelEvent( + WebCore::Widget* widget, const WebKit::WebMouseWheelEvent& e); }; class MakePlatformKeyboardEvent : public WebCore::PlatformKeyboardEvent { public: - MakePlatformKeyboardEvent(const WebKeyboardEvent& e); + MakePlatformKeyboardEvent(const WebKit::WebKeyboardEvent& e); void SetKeyType(Type type); bool IsCharacterKey() const; }; diff --git a/webkit/glue/glue.vcproj b/webkit/glue/glue.vcproj index 8e166c4..5583de0 100644 --- a/webkit/glue/glue.vcproj +++ b/webkit/glue/glue.vcproj @@ -219,14 +219,6 @@ > </File> <File - RelativePath=".\webinputevent.h" - > - </File> - <File - RelativePath=".\webinputevent_win.cc" - > - </File> - <File RelativePath=".\webmediaplayer.h" > </File> @@ -667,14 +659,6 @@ > </File> <File - RelativePath=".\webinputevent_util.cc" - > - </File> - <File - RelativePath=".\webinputevent_util.h" - > - </File> - <File RelativePath=".\webkit_glue.cc" > </File> diff --git a/webkit/glue/webinputevent.h b/webkit/glue/webinputevent.h deleted file mode 100644 index 351da4b..0000000 --- a/webkit/glue/webinputevent.h +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_GLUE_WEBINPUTEVENT_H_ -#define WEBKIT_GLUE_WEBINPUTEVENT_H_ - -#include "base/basictypes.h" -#include "base/string16.h" - -#if defined(OS_WIN) -#include <windows.h> -#elif defined(OS_MACOSX) -#ifdef __OBJC__ -@class NSEvent; -@class NSView; -#else -class NSEvent; -class NSView; -#endif // __OBJC__ -#elif defined(OS_LINUX) -#include <glib.h> -typedef struct _GdkEventButton GdkEventButton; -typedef struct _GdkEventMotion GdkEventMotion; -typedef struct _GdkEventScroll GdkEventScroll; -typedef struct _GdkEventKey GdkEventKey; -#endif - -// The classes defined in this file are intended to be used with WebView's -// HandleInputEvent method. These event types are cross-platform; however, -// there are platform-specific constructors that accept native UI events. -// -// The fields of these event classes roughly correspond to the fields required -// by WebCore's platform event classes. -// -// WARNING! These classes must remain PODs (plain old data). They will be -// "serialized" by shipping their raw bytes across the wire, so they must not -// contain any non-bit-copyable member variables! - -// WebInputEvent -------------------------------------------------------------- - -class WebInputEvent { - public: - WebInputEvent() : modifiers(0) { } - - // There are two schemes used for keyboard input. On Windows (and, - // interestingly enough, on Mac Carbon) there are two events for a keypress. - // One is a raw keydown, which provides the keycode only. If the app doesn't - // handle that, then the system runs key translation to create an event - // containing the generated character and pumps that event. In such a scheme, - // those two events are translated to RAW_KEY_DOWN and CHAR events - // respectively. In Cocoa and Gtk, key events contain both the keycode and any - // translation into actual text. In such a case, WebCore will eventually need - // to split the events (see disambiguateKeyDownEvent and its callers) but we - // don't worry about that here. We just use a different type (KEY_DOWN) to - // indicate this. - enum Type { - // WebMouseEvent - MOUSE_DOWN, - MOUSE_UP, - MOUSE_MOVE, - MOUSE_LEAVE, - MOUSE_DOUBLE_CLICK, - - // WebMouseWheelEvent - MOUSE_WHEEL, - - // WebKeyboardEvent - RAW_KEY_DOWN, - KEY_DOWN, - KEY_UP, - CHAR - }; - - enum Modifiers { - // modifiers for all events: - SHIFT_KEY = 1 << 0, - CTRL_KEY = 1 << 1, - ALT_KEY = 1 << 2, - META_KEY = 1 << 3, - - // modifiers for keyboard events: - IS_KEYPAD = 1 << 4, - IS_AUTO_REPEAT = 1 << 5 - }; - - Type type; - int modifiers; - - // Returns true if the WebInputEvent |type| is a keyboard event. - static bool IsKeyboardEventType(int type) { - return type == RAW_KEY_DOWN || - type == KEY_DOWN || - type == KEY_UP || - type == CHAR; - } -}; - -// WebMouseEvent -------------------------------------------------------------- - -class WebMouseEvent : public WebInputEvent { - public: - // These values defined for WebCore::MouseButton - enum Button { - BUTTON_NONE = -1, - BUTTON_LEFT, - BUTTON_MIDDLE, - BUTTON_RIGHT - }; - - Button button; - int x; - int y; - int global_x; - int global_y; - double timestamp_sec; // Seconds since epoch. - int layout_test_click_count; // Only used during layout tests. - - WebMouseEvent() {} -#if defined(OS_WIN) - WebMouseEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); -#elif defined(OS_MACOSX) - WebMouseEvent(NSEvent *event, NSView* view); -#elif defined(OS_LINUX) - explicit WebMouseEvent(const GdkEventButton* event); - explicit WebMouseEvent(const GdkEventMotion* event); -#endif -}; - -// WebMouseWheelEvent --------------------------------------------------------- - -class WebMouseWheelEvent : public WebMouseEvent { - public: - float delta_x; - float delta_y; - float wheel_ticks_x; - float wheel_ticks_y; - bool scroll_by_page; - - WebMouseWheelEvent() {} -#if defined(OS_WIN) - WebMouseWheelEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); -#elif defined(OS_MACOSX) - WebMouseWheelEvent(NSEvent *event, NSView* view); -#elif defined(OS_LINUX) - explicit WebMouseWheelEvent(const GdkEventScroll* event); -#endif -}; - -// WebKeyboardEvent ----------------------------------------------------------- - -// Caps on string lengths so we can make them static arrays and keep them PODs. -const size_t kTextLengthCap = 4; -// http://www.w3.org/TR/DOM-Level-3-Events/keyset.html lists the identifiers. -// The longest is 18 characters, so we'll round up to the next multiple of 4. -const size_t kIdentifierLengthCap = 20; - -class WebKeyboardEvent : public WebInputEvent { - public: - // |windows_key_code| is the Windows key code associated with this key event. - // Sometimes it's direct from the event (i.e. on Windows), sometimes it's via - // a mapping function. If you want a list, see - // webkit/port/platform/chromium/KeyboardCodes* . - int windows_key_code; - - // The actual key code genenerated by the platform. The DOM spec runs on - // Windows-equivalent codes (thus |windows_key_code| above) but it doesn't - // hurt to have this one around. - int native_key_code; - - // |text| is the text generated by this keystroke. |unmodified_text| is - // |text|, but unmodified by an concurrently-held modifiers (except shift). - // This is useful for working out shortcut keys. Linux and Windows guarantee - // one character per event. The Mac does not, but in reality that's all it - // ever gives. We're generous, and cap it a bit longer. - char16 text[kTextLengthCap]; - char16 unmodified_text[kTextLengthCap]; - - // This is a string identifying the key pressed. - char key_identifier[kIdentifierLengthCap]; - - // This identifies whether this event was tagged by the system as being a - // "system key" event (see - // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for details). - // Other platforms don't have this concept, but it's just easier to leave it - // always false than ifdef. - bool system_key; - - WebKeyboardEvent() : windows_key_code(0), - native_key_code(0), - system_key(false) { - memset(&text, 0, sizeof(text)); - memset(&unmodified_text, 0, sizeof(unmodified_text)); - memset(&key_identifier, 0, sizeof(key_identifier)); - } - -#if defined(OS_WIN) - WebKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); -#elif defined(OS_MACOSX) - explicit WebKeyboardEvent(NSEvent *event); -#elif defined(OS_LINUX) - explicit WebKeyboardEvent(const GdkEventKey* event); -#endif -}; - -#endif // WEBKIT_GLUE_WEBINPUTEVENT_H_ diff --git a/webkit/glue/webinputevent_util.cc b/webkit/glue/webinputevent_util.cc deleted file mode 100644 index 9f47429..0000000 --- a/webkit/glue/webinputevent_util.cc +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "webkit/glue/webinputevent_util.h" - -#include "KeyboardCodes.h" - -#include "base/string_util.h" - -using namespace WebCore; - -namespace webkit_glue { - -std::string GetKeyIdentifierForWindowsKeyCode(unsigned short key_code) { - switch (key_code) { - case VKEY_MENU: - return "Alt"; - case VKEY_CONTROL: - return "Control"; - case VKEY_SHIFT: - return "Shift"; - case VKEY_CAPITAL: - return "CapsLock"; - case VKEY_LWIN: - case VKEY_RWIN: - return "Win"; - case VKEY_CLEAR: - return "Clear"; - case VKEY_DOWN: - return "Down"; - // "End" - case VKEY_END: - return "End"; - // "Enter" - case VKEY_RETURN: - return "Enter"; - case VKEY_EXECUTE: - return "Execute"; - case VKEY_F1: - return "F1"; - case VKEY_F2: - return "F2"; - case VKEY_F3: - return "F3"; - case VKEY_F4: - return "F4"; - case VKEY_F5: - return "F5"; - case VKEY_F6: - return "F6"; - case VKEY_F7: - return "F7"; - case VKEY_F8: - return "F8"; - case VKEY_F9: - return "F9"; - case VKEY_F10: - return "F11"; - case VKEY_F12: - return "F12"; - case VKEY_F13: - return "F13"; - case VKEY_F14: - return "F14"; - case VKEY_F15: - return "F15"; - case VKEY_F16: - return "F16"; - case VKEY_F17: - return "F17"; - case VKEY_F18: - return "F18"; - case VKEY_F19: - return "F19"; - case VKEY_F20: - return "F20"; - case VKEY_F21: - return "F21"; - case VKEY_F22: - return "F22"; - case VKEY_F23: - return "F23"; - case VKEY_F24: - return "F24"; - case VKEY_HELP: - return "Help"; - case VKEY_HOME: - return "Home"; - case VKEY_INSERT: - return "Insert"; - case VKEY_LEFT: - return "Left"; - case VKEY_NEXT: - return "PageDown"; - case VKEY_PRIOR: - return "PageUp"; - case VKEY_PAUSE: - return "Pause"; - case VKEY_SNAPSHOT: - return "PrintScreen"; - case VKEY_RIGHT: - return "Right"; - case VKEY_SCROLL: - return "Scroll"; - case VKEY_SELECT: - return "Select"; - case VKEY_UP: - return "Up"; - // Standard says that DEL becomes U+007F. - case VKEY_DELETE: - return "U+007F"; - default: - return StringPrintf("U+%04X", toupper(key_code)); - } -} - -} // namespace webkit_glue diff --git a/webkit/glue/webinputevent_util.h b/webkit/glue/webinputevent_util.h deleted file mode 100644 index 6452c77..0000000 --- a/webkit/glue/webinputevent_util.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_GLUE_WEBINPUTEVENT_UTIL_H_ -#define WEBKIT_GLUE_WEBINPUTEVENT_UTIL_H_ - -#include <string> - -// The shared Linux and Windows keyboard event code lives here. - -namespace webkit_glue { - -std::string GetKeyIdentifierForWindowsKeyCode(unsigned short key_code); - -} // namespace webkit_glue - -#endif // WEBKIT_GLUE_WEBINPUTEVENT_UTIL_H_ diff --git a/webkit/glue/webinputevent_win.cc b/webkit/glue/webinputevent_win.cc deleted file mode 100644 index 9dd4d85..0000000 --- a/webkit/glue/webinputevent_win.cc +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "webkit/glue/webinputevent.h" - -#include "base/logging.h" -#include "base/string_util.h" -#include "webkit/glue/webinputevent_util.h" - -static const unsigned long kDefaultScrollLinesPerWheelDelta = 3; -static const unsigned long kDefaultScrollCharsPerWheelDelta = 1; - -// WebMouseEvent -------------------------------------------------------------- - -static LPARAM GetRelativeCursorPos(HWND hwnd) { - POINT pos = {-1, -1}; - GetCursorPos(&pos); - ScreenToClient(hwnd, &pos); - return MAKELPARAM(pos.x, pos.y); -} - -WebMouseEvent::WebMouseEvent(HWND hwnd, UINT message, WPARAM wparam, - LPARAM lparam) { - switch (message) { - case WM_MOUSEMOVE: - type = MOUSE_MOVE; - if (wparam & MK_LBUTTON) - button = BUTTON_LEFT; - else if (wparam & MK_MBUTTON) - button = BUTTON_MIDDLE; - else if (wparam & MK_RBUTTON) - button = BUTTON_MIDDLE; - else - button = BUTTON_NONE; - break; - case WM_MOUSELEAVE: - type = MOUSE_LEAVE; - button = BUTTON_NONE; - // set the current mouse position (relative to the client area of the - // current window) since none is specified for this event - lparam = GetRelativeCursorPos(hwnd); - break; - case WM_LBUTTONDOWN: - type = MOUSE_DOWN; - button = BUTTON_LEFT; - break; - case WM_MBUTTONDOWN: - type = MOUSE_DOWN; - button = BUTTON_MIDDLE; - break; - case WM_RBUTTONDOWN: - type = MOUSE_DOWN; - button = BUTTON_RIGHT; - break; - case WM_LBUTTONUP: - type = MOUSE_UP; - button = BUTTON_LEFT; - break; - case WM_MBUTTONUP: - type = MOUSE_UP; - button = BUTTON_MIDDLE; - break; - case WM_RBUTTONUP: - type = MOUSE_UP; - button = BUTTON_RIGHT; - break; - case WM_LBUTTONDBLCLK: - type = MOUSE_DOUBLE_CLICK; - button = BUTTON_LEFT; - break; - case WM_MBUTTONDBLCLK: - type = MOUSE_DOUBLE_CLICK; - button = BUTTON_MIDDLE; - break; - case WM_RBUTTONDBLCLK: - type = MOUSE_DOUBLE_CLICK; - button = BUTTON_RIGHT; - break; - default: - NOTREACHED() << "unexpected native message"; - } - - // set position fields: - - x = static_cast<short>(LOWORD(lparam)); - y = static_cast<short>(HIWORD(lparam)); - - POINT global_point = { x, y }; - ClientToScreen(hwnd, &global_point); - - global_x = global_point.x; - global_y = global_point.y; - - // set modifiers: - - if (wparam & MK_CONTROL) - modifiers |= CTRL_KEY; - if (wparam & MK_SHIFT) - modifiers |= SHIFT_KEY; - if (GetKeyState(VK_MENU) & 0x8000) - modifiers |= (ALT_KEY | META_KEY); // TODO(darin): set META properly - - // TODO(pkasting): http://b/1117926 Instead of using GetTickCount() here, we - // should use GetMessageTime() on the original Windows message in the browser - // process, and pass that in the WebMouseEvent. - timestamp_sec = GetTickCount() / 1000.0; - - layout_test_click_count = 0; -} - -// WebMouseWheelEvent --------------------------------------------------------- - -WebMouseWheelEvent::WebMouseWheelEvent(HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam) - : scroll_by_page(false) { - type = MOUSE_WHEEL; - button = BUTTON_NONE; - - // Get key state, coordinates, and wheel delta from event. - typedef SHORT (WINAPI *GetKeyStateFunction)(int key); - GetKeyStateFunction get_key_state; - UINT key_state; - float wheel_delta; - bool horizontal_scroll = false; - if ((message == WM_VSCROLL) || (message == WM_HSCROLL)) { - // Synthesize mousewheel event from a scroll event. This is needed to - // simulate middle mouse scrolling in some laptops. Use GetAsyncKeyState - // for key state since we are synthesizing the input event. - get_key_state = GetAsyncKeyState; - key_state = 0; - if (get_key_state(VK_SHIFT)) - key_state |= MK_SHIFT; - if (get_key_state(VK_CONTROL)) - key_state |= MK_CONTROL; - - POINT cursor_position = {0}; - GetCursorPos(&cursor_position); - global_x = cursor_position.x; - global_y = cursor_position.y; - - switch (LOWORD(wparam)) { - case SB_LINEUP: // == SB_LINELEFT - wheel_delta = WHEEL_DELTA; - break; - case SB_LINEDOWN: // == SB_LINERIGHT - wheel_delta = -WHEEL_DELTA; - break; - case SB_PAGEUP: - wheel_delta = 1; - scroll_by_page = true; - break; - case SB_PAGEDOWN: - wheel_delta = -1; - scroll_by_page = true; - break; - default: // We don't supoprt SB_THUMBPOSITION or SB_THUMBTRACK here. - wheel_delta = 0; - break; - } - - if (message == WM_HSCROLL) - horizontal_scroll = true; - } else { - // Non-synthesized event; we can just read data off the event. - get_key_state = GetKeyState; - key_state = GET_KEYSTATE_WPARAM(wparam); - - global_x = static_cast<short>(LOWORD(lparam)); - global_y = static_cast<short>(HIWORD(lparam)); - - wheel_delta = static_cast<float>(GET_WHEEL_DELTA_WPARAM(wparam)); - if (message == WM_MOUSEHWHEEL) { - horizontal_scroll = true; - wheel_delta = -wheel_delta; // Windows is <- -/+ ->, WebKit <- +/- ->. - } - } - if (key_state & MK_SHIFT) - horizontal_scroll = true; - - // Set modifiers based on key state. - if (key_state & MK_SHIFT) - modifiers |= SHIFT_KEY; - if (key_state & MK_CONTROL) - modifiers |= CTRL_KEY; - if (get_key_state(VK_MENU) & 0x8000) - modifiers |= (ALT_KEY | META_KEY); - - // Set coordinates by translating event coordinates from screen to client. - POINT client_point = { global_x, global_y }; - MapWindowPoints(NULL, hwnd, &client_point, 1); - x = client_point.x; - y = client_point.y; - - // Convert wheel delta amount to a number of pixels to scroll. - // - // How many pixels should we scroll per line? Gecko uses the height of the - // current line, which means scroll distance changes as you go through the - // page or go to different pages. IE 7 is ~50 px/line, although the value - // seems to vary slightly by page and zoom level. Since IE 7 has a smoothing - // algorithm on scrolling, it can get away with slightly larger scroll values - // without feeling jerky. Here we use 100 px per three lines (the default - // scroll amount is three lines per wheel tick). - static const float kScrollbarPixelsPerLine = 100.0f / 3.0f; - wheel_delta /= WHEEL_DELTA; - float scroll_delta = wheel_delta; - if (horizontal_scroll) { - unsigned long scroll_chars = kDefaultScrollCharsPerWheelDelta; - SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scroll_chars, 0); - // TODO(pkasting): Should probably have a different multiplier - // kScrollbarPixelsPerChar here. - scroll_delta *= static_cast<float>(scroll_chars) * kScrollbarPixelsPerLine; - } else { - unsigned long scroll_lines = kDefaultScrollLinesPerWheelDelta; - SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scroll_lines, 0); - if (scroll_lines == WHEEL_PAGESCROLL) - scroll_by_page = true; - if (!scroll_by_page) { - scroll_delta *= - static_cast<float>(scroll_lines) * kScrollbarPixelsPerLine; - } - } - - // Set scroll amount based on above calculations. WebKit expects positive - // delta_y to mean "scroll up" and positive delta_x to mean "scroll left". - if (horizontal_scroll) { - delta_x = scroll_delta; - delta_y = 0; - wheel_ticks_x = wheel_delta; - wheel_ticks_y = 0; - } else { - delta_x = 0; - delta_y = scroll_delta; - wheel_ticks_x = 0; - wheel_ticks_y = wheel_delta; - } -} - -// WebKeyboardEvent ----------------------------------------------------------- - -bool IsKeyPad(WPARAM wparam, LPARAM lparam) { - bool keypad = false; - switch (wparam) { - case VK_RETURN: - keypad = (lparam >> 16) & KF_EXTENDED; - break; - case VK_INSERT: - case VK_DELETE: - case VK_HOME: - case VK_END: - case VK_PRIOR: - case VK_NEXT: - case VK_UP: - case VK_DOWN: - case VK_LEFT: - case VK_RIGHT: - keypad = !((lparam >> 16) & KF_EXTENDED); - break; - case VK_NUMLOCK: - case VK_NUMPAD0: - case VK_NUMPAD1: - case VK_NUMPAD2: - case VK_NUMPAD3: - case VK_NUMPAD4: - case VK_NUMPAD5: - case VK_NUMPAD6: - case VK_NUMPAD7: - case VK_NUMPAD8: - case VK_NUMPAD9: - case VK_DIVIDE: - case VK_MULTIPLY: - case VK_SUBTRACT: - case VK_ADD: - case VK_DECIMAL: - case VK_CLEAR: - keypad = true; - break; - default: - keypad = false; - } - - return keypad; -} - -WebKeyboardEvent::WebKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, - LPARAM lparam) { - system_key = false; - - windows_key_code = native_key_code = static_cast<int>(wparam); - - switch (message) { - case WM_SYSKEYDOWN: - system_key = true; - case WM_KEYDOWN: - type = RAW_KEY_DOWN; - break; - case WM_SYSKEYUP: - system_key = true; - case WM_KEYUP: - type = KEY_UP; - break; - case WM_IME_CHAR: - type = CHAR; - break; - case WM_SYSCHAR: - system_key = true; - type = CHAR; - case WM_CHAR: - type = CHAR; - break; - default: - NOTREACHED() << "unexpected native message: " << message; - } - - memset(&text, 0, sizeof(text)); - memset(&unmodified_text, 0, sizeof(unmodified_text)); - memset(&key_identifier, 0, sizeof(key_identifier)); - - if (type == CHAR || type == RAW_KEY_DOWN) { - text[0] = windows_key_code; - unmodified_text[0] = windows_key_code; - } - if (type != CHAR) { - std::string key_identifier_str = - webkit_glue::GetKeyIdentifierForWindowsKeyCode(windows_key_code); - base::strlcpy(key_identifier, key_identifier_str.c_str(), - kIdentifierLengthCap); - } - - if (GetKeyState(VK_SHIFT) & 0x8000) - modifiers |= SHIFT_KEY; - if (GetKeyState(VK_CONTROL) & 0x8000) - modifiers |= CTRL_KEY; - if (GetKeyState(VK_MENU) & 0x8000) - modifiers |= (ALT_KEY | META_KEY); - - if (LOWORD(lparam) > 1) - modifiers |= IS_AUTO_REPEAT; - if (IsKeyPad(wparam, lparam)) - modifiers |= IS_KEYPAD; -} diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index c09a174..4d6b8a09 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -84,6 +84,7 @@ MSVC_POP_WARNING(); #include "base/logging.h" #include "base/message_loop.h" #include "base/string_util.h" +#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "webkit/glue/chrome_client_impl.h" #include "webkit/glue/clipboard_conversion.h" #include "webkit/glue/context_menu_client_impl.h" @@ -99,7 +100,6 @@ MSVC_POP_WARNING(); #include "webkit/glue/webdevtoolsagent_impl.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/webhistoryitem_impl.h" -#include "webkit/glue/webinputevent.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webdevtoolsagent.h" @@ -114,6 +114,11 @@ MSVC_POP_WARNING(); using namespace WebCore; +using WebKit::WebInputEvent; +using WebKit::WebKeyboardEvent; +using WebKit::WebMouseEvent; +using WebKit::WebMouseWheelEvent; + // Change the text zoom level by kTextSizeMultiplierRatio each time the user // zooms text in or out (ie., change by 20%). The min and max values limit // text zoom to half and 3x the original text size. These three values match @@ -429,7 +434,7 @@ void WebViewImpl::MouseDown(const WebMouseEvent& event) { // If a text field that has focus is clicked again, we should display the // autocomplete popup. RefPtr<Node> clicked_node; - if (event.button == WebMouseEvent::BUTTON_LEFT) { + if (event.button == WebMouseEvent::ButtonLeft) { RefPtr<Node> focused_node = GetFocusedNode(); if (focused_node.get() && webkit_glue::NodeToHTMLInputElement(focused_node.get())) { @@ -501,7 +506,7 @@ void WebViewImpl::MouseUp(const WebMouseEvent& event) { #if defined(OS_WIN) || defined(OS_LINUX) // Dispatch the contextmenu event regardless of if the click was swallowed. - if (event.button == WebMouseEvent::BUTTON_RIGHT) + if (event.button == WebMouseEvent::ButtonRight) MouseContextMenu(event); #endif } @@ -512,9 +517,9 @@ void WebViewImpl::MouseWheel(const WebMouseWheelEvent& event) { } bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { - DCHECK((event.type == WebInputEvent::RAW_KEY_DOWN) || - (event.type == WebInputEvent::KEY_DOWN) || - (event.type == WebInputEvent::KEY_UP)); + DCHECK((event.type == WebInputEvent::RawKeyDown) || + (event.type == WebInputEvent::KeyDown) || + (event.type == WebInputEvent::KeyUp)); // Please refer to the comments explaining the suppress_next_keypress_event_ // member. @@ -538,9 +543,9 @@ bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { #if defined(OS_WIN) // TODO(pinkerton): figure out these keycodes on non-windows - if (((event.modifiers == 0) && (event.windows_key_code == VK_APPS)) || - ((event.modifiers == WebInputEvent::SHIFT_KEY) && - (event.windows_key_code == VK_F10))) { + if (((event.modifiers == 0) && (event.windowsKeyCode == VK_APPS)) || + ((event.modifiers == WebInputEvent::ShiftKey) && + (event.windowsKeyCode == VK_F10))) { SendContextMenuEvent(event); return true; } @@ -548,7 +553,7 @@ bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { MakePlatformKeyboardEvent evt(event); - if (WebInputEvent::RAW_KEY_DOWN == event.type) { + if (WebInputEvent::RawKeyDown == event.type) { if (handler->keyEvent(evt) && !evt.isSystemKey()) { suppress_next_keypress_event_ = true; return true; @@ -565,14 +570,14 @@ bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { bool WebViewImpl::AutocompleteHandleKeyEvent(const WebKeyboardEvent& event) { if (!autocomplete_popup_showing_ || // Home and End should be left to the text field to process. - event.windows_key_code == base::VKEY_HOME || - event.windows_key_code == base::VKEY_END) { + event.windowsKeyCode == base::VKEY_HOME || + event.windowsKeyCode == base::VKEY_END) { return false; } // Pressing delete triggers the removal of the selected suggestion from the // DB. - if (event.windows_key_code == base::VKEY_DELETE && + if (event.windowsKeyCode == base::VKEY_DELETE && autocomplete_popup_->selectedIndex() != -1) { Node* node = GetFocusedNode(); if (!node || (node->nodeType() != WebCore::Node::ELEMENT_NODE)) { @@ -599,14 +604,14 @@ bool WebViewImpl::AutocompleteHandleKeyEvent(const WebKeyboardEvent& event) { return false; } - if (!autocomplete_popup_->isInterestedInEventForKey(event.windows_key_code)) + if (!autocomplete_popup_->isInterestedInEventForKey(event.windowsKeyCode)) return false; if (autocomplete_popup_->handleKeyEvent(MakePlatformKeyboardEvent(event))) { #if defined(OS_WIN) - // We need to ignore the next CHAR event after this otherwise pressing + // We need to ignore the next Char event after this otherwise pressing // enter when selecting an item in the menu will go to the page. - if (WebInputEvent::RAW_KEY_DOWN == event.type) + if (WebInputEvent::RawKeyDown == event.type) suppress_next_keypress_event_ = true; #endif return true; @@ -616,7 +621,7 @@ bool WebViewImpl::AutocompleteHandleKeyEvent(const WebKeyboardEvent& event) { } bool WebViewImpl::CharEvent(const WebKeyboardEvent& event) { - DCHECK(event.type == WebInputEvent::CHAR); + DCHECK(event.type == WebInputEvent::Char); // Please refer to the comments explaining the suppress_next_keypress_event_ // member. @@ -716,10 +721,10 @@ bool WebViewImpl::SendContextMenuEvent(const WebKeyboardEvent& event) { Frame* focused_frame = page()->focusController()->focusedOrMainFrame(); focused_frame->view()->setCursor(pointerCursor()); WebMouseEvent mouse_event; - mouse_event.button = WebMouseEvent::BUTTON_RIGHT; + mouse_event.button = WebMouseEvent::ButtonRight; mouse_event.x = coords.x(); mouse_event.y = coords.y(); - mouse_event.type = WebInputEvent::MOUSE_UP; + mouse_event.type = WebInputEvent::MouseUp; MakePlatformMouseEvent platform_event(view, mouse_event); @@ -737,9 +742,9 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { return false; switch (event.type) { - case WebInputEvent::CHAR: { - if (event.windows_key_code == VKEY_SPACE) { - int key_code = ((event.modifiers & WebInputEvent::SHIFT_KEY) ? + case WebInputEvent::Char: { + if (event.windowsKeyCode == VKEY_SPACE) { + int key_code = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PRIOR : VKEY_NEXT); return ScrollViewWithKeyboard(key_code); } @@ -747,12 +752,12 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { } #if defined(OS_WIN) - case WebInputEvent::RAW_KEY_DOWN: { + case WebInputEvent::RawKeyDown: { #else - case WebInputEvent::KEY_DOWN: { + case WebInputEvent::KeyDown: { #endif - if (event.modifiers == WebInputEvent::CTRL_KEY) { - switch (event.windows_key_code) { + if (event.modifiers == WebInputEvent::ControlKey) { + switch (event.windowsKeyCode) { case 'A': GetFocusedFrame()->SelectAll(); return true; @@ -771,8 +776,8 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { return false; } } - if (!event.system_key) { - return ScrollViewWithKeyboard(event.windows_key_code); + if (!event.isSystemKey) { + return ScrollViewWithKeyboard(event.windowsKeyCode); } break; } @@ -991,34 +996,34 @@ bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) { // processing methods. For now we'll assume it has processed them (as we are // only interested in whether keyboard events are processed). switch (input_event->type) { - case WebInputEvent::MOUSE_MOVE: + case WebInputEvent::MouseMove: MouseMove(*static_cast<const WebMouseEvent*>(input_event)); break; - case WebInputEvent::MOUSE_LEAVE: + case WebInputEvent::MouseLeave: MouseLeave(*static_cast<const WebMouseEvent*>(input_event)); break; - case WebInputEvent::MOUSE_WHEEL: + case WebInputEvent::MouseWheel: MouseWheel(*static_cast<const WebMouseWheelEvent*>(input_event)); break; - case WebInputEvent::MOUSE_DOWN: - case WebInputEvent::MOUSE_DOUBLE_CLICK: + case WebInputEvent::MouseDown: + case WebInputEvent::MouseDoubleClick: MouseDown(*static_cast<const WebMouseEvent*>(input_event)); break; - case WebInputEvent::MOUSE_UP: + case WebInputEvent::MouseUp: MouseUp(*static_cast<const WebMouseEvent*>(input_event)); break; - case WebInputEvent::RAW_KEY_DOWN: - case WebInputEvent::KEY_DOWN: - case WebInputEvent::KEY_UP: + case WebInputEvent::RawKeyDown: + case WebInputEvent::KeyDown: + case WebInputEvent::KeyUp: handled = KeyEvent(*static_cast<const WebKeyboardEvent*>(input_event)); break; - case WebInputEvent::CHAR: + case WebInputEvent::Char: handled = CharEvent(*static_cast<const WebKeyboardEvent*>(input_event)); break; default: @@ -1302,14 +1307,14 @@ void WebViewImpl::SetInitialFocus(bool reverse) { // Since we don't have a keyboard event, we'll create one. WebKeyboardEvent keyboard_event; - keyboard_event.type = WebInputEvent::RAW_KEY_DOWN; + keyboard_event.type = WebInputEvent::RawKeyDown; if (reverse) - keyboard_event.modifiers = WebInputEvent::SHIFT_KEY; + keyboard_event.modifiers = WebInputEvent::ShiftKey; // VK_TAB which is only defined on Windows. - keyboard_event.windows_key_code = 0x09; + keyboard_event.windowsKeyCode = 0x09; MakePlatformKeyboardEvent platform_event(keyboard_event); - RefPtr<KeyboardEvent> webkit_event = KeyboardEvent::create(platform_event, - NULL); + RefPtr<KeyboardEvent> webkit_event = + KeyboardEvent::create(platform_event, NULL); page()->focusController()->setInitialFocus( reverse ? WebCore::FocusDirectionBackward : WebCore::FocusDirectionForward, diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index 4ac01fb..539e125 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -35,14 +35,17 @@ class Range; class Widget; } +namespace WebKit { +class WebKeyboardEvent; +class WebMouseEvent; +class WebMouseWheelEvent; +} + class AutocompletePopupMenuClient; class ImageResourceFetcher; class SearchableFormData; struct WebDropData; class WebHistoryItemImpl; -class WebKeyboardEvent; -class WebMouseEvent; -class WebMouseWheelEvent; class WebDevToolsAgent; class WebDevToolsAgentImpl; class WebViewDelegate; @@ -65,7 +68,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { virtual gfx::Size GetSize() { return size(); } virtual void Layout(); virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& rect); - virtual bool HandleInputEvent(const WebInputEvent* input_event); + virtual bool HandleInputEvent(const WebKit::WebInputEvent* input_event); virtual void MouseCaptureLost(); virtual void SetFocus(bool enable); virtual void StoreFocusForFrame(WebFrame* frame); @@ -148,15 +151,15 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { void ObserveNewNavigation(); // Event related methods: - void MouseMove(const WebMouseEvent& mouse_event); - void MouseLeave(const WebMouseEvent& mouse_event); - void MouseDown(const WebMouseEvent& mouse_event); - void MouseUp(const WebMouseEvent& mouse_event); - void MouseContextMenu(const WebMouseEvent& mouse_event); - void MouseDoubleClick(const WebMouseEvent& mouse_event); - void MouseWheel(const WebMouseWheelEvent& wheel_event); - bool KeyEvent(const WebKeyboardEvent& key_event); - bool CharEvent(const WebKeyboardEvent& key_event); + void MouseMove(const WebKit::WebMouseEvent& mouse_event); + void MouseLeave(const WebKit::WebMouseEvent& mouse_event); + void MouseDown(const WebKit::WebMouseEvent& mouse_event); + void MouseUp(const WebKit::WebMouseEvent& mouse_event); + void MouseContextMenu(const WebKit::WebMouseEvent& mouse_event); + void MouseDoubleClick(const WebKit::WebMouseEvent& mouse_event); + void MouseWheel(const WebKit::WebMouseWheelEvent& wheel_event); + bool KeyEvent(const WebKit::WebKeyboardEvent& key_event); + bool CharEvent(const WebKit::WebKeyboardEvent& key_event); // Handles context menu events orignated via the the keyboard. These // include the VK_APPS virtual key and the Shift+F10 combine. @@ -165,7 +168,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { // webkit\webkit\win\WebView.cpp. The only significant change in this // function is the code to convert from a Keyboard event to the Right // Mouse button down event. - bool SendContextMenuEvent(const WebKeyboardEvent& event); + bool SendContextMenuEvent(const WebKit::WebKeyboardEvent& event); // Releases references used to restore focus. void ReleaseFocusReferences(); @@ -257,10 +260,10 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { private: // Returns true if the event was actually processed. - bool KeyEventDefault(const WebKeyboardEvent& event); + bool KeyEventDefault(const WebKit::WebKeyboardEvent& event); // Returns true if the autocomple has consumed the event. - bool AutocompleteHandleKeyEvent(const WebKeyboardEvent& event); + bool AutocompleteHandleKeyEvent(const WebKit::WebKeyboardEvent& event); // Repaints the autofill popup. Should be called when the suggestions have // changed. Note that this should only be called when the autofill popup is @@ -338,11 +341,11 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { // WebKit to pass enough information up into ChromeClient::show() so we can // decide if the window.open event was caused by a middle-mouse click public: - static const WebInputEvent* current_input_event() { + static const WebKit::WebInputEvent* current_input_event() { return g_current_input_event; } private: - static const WebInputEvent* g_current_input_event; + static const WebKit::WebInputEvent* g_current_input_event; DISALLOW_COPY_AND_ASSIGN(WebViewImpl); }; diff --git a/webkit/glue/webwidget.h b/webkit/glue/webwidget.h index b1b011d..ed38375 100644 --- a/webkit/glue/webwidget.h +++ b/webkit/glue/webwidget.h @@ -13,7 +13,10 @@ class Rect; class Size; } +namespace WebKit { class WebInputEvent; +} + class WebWidgetDelegate; class WebWidget { @@ -48,7 +51,7 @@ class WebWidget { // Called to inform the WebWidget of an input event. // Returns true if the event has been processed, false otherwise. - virtual bool HandleInputEvent(const WebInputEvent* input_event) = 0; + virtual bool HandleInputEvent(const WebKit::WebInputEvent* input_event) = 0; // Called to inform the WebWidget that mouse capture was lost. virtual void MouseCaptureLost() = 0; diff --git a/webkit/glue/webwidget_impl.cc b/webkit/glue/webwidget_impl.cc index 52e5ed0..1ea7c1c 100644 --- a/webkit/glue/webwidget_impl.cc +++ b/webkit/glue/webwidget_impl.cc @@ -22,14 +22,19 @@ MSVC_POP_WARNING(); #include "base/gfx/rect.h" #include "base/logging.h" #include "skia/ext/platform_canvas.h" +#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "webkit/glue/event_conversion.h" #include "webkit/glue/glue_util.h" -#include "webkit/glue/webinputevent.h" #include "webkit/glue/webwidget_delegate.h" #include "webkit/glue/webwidget_impl.h" using namespace WebCore; +using WebKit::WebInputEvent; +using WebKit::WebKeyboardEvent; +using WebKit::WebMouseEvent; +using WebKit::WebMouseWheelEvent; + // WebWidget ---------------------------------------------------------------- /*static*/ @@ -165,30 +170,30 @@ bool WebWidgetImpl::HandleInputEvent(const WebInputEvent* input_event) { // methods. For now we'll assume it has processed them (as we are only // interested in whether keyboard events are processed). switch (input_event->type) { - case WebInputEvent::MOUSE_MOVE: + case WebInputEvent::MouseMove: MouseMove(*static_cast<const WebMouseEvent*>(input_event)); return true; - case WebInputEvent::MOUSE_LEAVE: + case WebInputEvent::MouseLeave: MouseLeave(*static_cast<const WebMouseEvent*>(input_event)); return true; - case WebInputEvent::MOUSE_WHEEL: + case WebInputEvent::MouseWheel: MouseWheel(*static_cast<const WebMouseWheelEvent*>(input_event)); return true; - case WebInputEvent::MOUSE_DOWN: - case WebInputEvent::MOUSE_DOUBLE_CLICK: + case WebInputEvent::MouseDown: + case WebInputEvent::MouseDoubleClick: MouseDown(*static_cast<const WebMouseEvent*>(input_event)); return true; - case WebInputEvent::MOUSE_UP: + case WebInputEvent::MouseUp: MouseUp(*static_cast<const WebMouseEvent*>(input_event)); return true; - case WebInputEvent::RAW_KEY_DOWN: - case WebInputEvent::KEY_DOWN: - case WebInputEvent::KEY_UP: + case WebInputEvent::RawKeyDown: + case WebInputEvent::KeyDown: + case WebInputEvent::KeyUp: return KeyEvent(*static_cast<const WebKeyboardEvent*>(input_event)); default: diff --git a/webkit/glue/webwidget_impl.h b/webkit/glue/webwidget_impl.h index 83fc23b..5cf6cfe 100644 --- a/webkit/glue/webwidget_impl.h +++ b/webkit/glue/webwidget_impl.h @@ -16,19 +16,22 @@ #include "FramelessScrollViewClient.h" namespace WebCore { - class Frame; - class FramelessScrollView; - class KeyboardEvent; - class Page; - class PlatformKeyboardEvent; - class Range; - class Widget; +class Frame; +class FramelessScrollView; +class KeyboardEvent; +class Page; +class PlatformKeyboardEvent; +class Range; +class Widget; } -struct MenuItem; +namespace WebKit { class WebKeyboardEvent; class WebMouseEvent; class WebMouseWheelEvent; +} + +struct MenuItem; class WebWidgetDelegate; class WebWidgetImpl : public WebWidget, @@ -41,7 +44,7 @@ class WebWidgetImpl : public WebWidget, virtual gfx::Size GetSize() { return size(); } virtual void Layout(); virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& rect); - virtual bool HandleInputEvent(const WebInputEvent* input_event); + virtual bool HandleInputEvent(const WebKit::WebInputEvent* input_event); virtual void MouseCaptureLost(); virtual void SetFocus(bool enable); virtual bool ImeSetComposition(int string_type, @@ -67,13 +70,13 @@ class WebWidgetImpl : public WebWidget, return delegate_; } - void MouseMove(const WebMouseEvent& mouse_event); - void MouseLeave(const WebMouseEvent& mouse_event); - void MouseDown(const WebMouseEvent& mouse_event); - void MouseUp(const WebMouseEvent& mouse_event); - void MouseDoubleClick(const WebMouseEvent& mouse_event); - void MouseWheel(const WebMouseWheelEvent& wheel_event); - bool KeyEvent(const WebKeyboardEvent& key_event); + void MouseMove(const WebKit::WebMouseEvent& mouse_event); + void MouseLeave(const WebKit::WebMouseEvent& mouse_event); + void MouseDown(const WebKit::WebMouseEvent& mouse_event); + void MouseUp(const WebKit::WebMouseEvent& mouse_event); + void MouseDoubleClick(const WebKit::WebMouseEvent& mouse_event); + void MouseWheel(const WebKit::WebMouseWheelEvent& wheel_event); + bool KeyEvent(const WebKit::WebKeyboardEvent& key_event); protected: friend class WebWidget; // So WebWidget::Create can call our constructor |