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 /chrome/browser | |
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 'chrome/browser')
10 files changed, 80 insertions, 55 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 03251ec..35582d4 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -37,6 +37,7 @@ #include "webkit/glue/autofill_form.h" using base::TimeDelta; +using WebKit::WebInputEvent; namespace { @@ -1214,9 +1215,9 @@ void RenderViewHost::UnhandledKeyboardEvent( // TODO(brettw) why do we have to filter these types of events here. Can't // the renderer just send us the ones we care abount, or maybe the view // should be able to decide which ones it wants or not? - if ((event.type == WebInputEvent::RAW_KEY_DOWN) || - (event.type == WebInputEvent::KEY_DOWN) || - (event.type == WebInputEvent::CHAR)) { + if ((event.type == WebInputEvent::RawKeyDown) || + (event.type == WebInputEvent::KeyDown) || + (event.type == WebInputEvent::Char)) { view->HandleKeyboardEvent(event); } } diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index b761d42..bf1e5350 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -16,7 +16,6 @@ #include "chrome/common/render_messages.h" #include "chrome/views/view.h" #include "webkit/glue/webcursor.h" -#include "webkit/glue/webinputevent.h" #include "webkit/glue/webtextdirection.h" #if defined(OS_WIN) @@ -29,6 +28,11 @@ using base::Time; using base::TimeDelta; using base::TimeTicks; +using WebKit::WebInputEvent; +using WebKit::WebKeyboardEvent; +using WebKit::WebMouseEvent; +using WebKit::WebMouseWheelEvent; + // How long to (synchronously) wait for the renderer to respond with a // PaintRect message, when our backing-store is invalid, before giving up and // returning a null or incorrectly sized backing-store from GetBackingStore. @@ -278,7 +282,7 @@ void RenderWidgetHost::ForwardMouseEvent(const WebMouseEvent& mouse_event) { // to note that WM_MOUSEMOVE events are anyways synthetic, but since our // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way // more WM_MOUSEMOVE events than we wish to send to the renderer. - if (mouse_event.type == WebInputEvent::MOUSE_MOVE) { + if (mouse_event.type == WebInputEvent::MouseMove) { if (mouse_move_pending_) { next_mouse_move_.reset(new WebMouseEvent(mouse_event)); return; @@ -296,15 +300,15 @@ void RenderWidgetHost::ForwardWheelEvent( void RenderWidgetHost::ForwardKeyboardEvent( const NativeWebKeyboardEvent& key_event) { - if (key_event.type == WebKeyboardEvent::CHAR && - (key_event.windows_key_code == base::VKEY_RETURN || - key_event.windows_key_code == base::VKEY_SPACE)) { + if (key_event.type == WebKeyboardEvent::Char && + (key_event.windowsKeyCode == base::VKEY_RETURN || + key_event.windowsKeyCode == base::VKEY_SPACE)) { OnEnterOrSpace(); } // Double check the type to make sure caller hasn't sent us nonsense that // will mess up our key queue. - if (WebInputEvent::IsKeyboardEventType(key_event.type)) { + if (WebInputEvent::isKeyboardEventType(key_event.type)) { // Don't add this key to the queue if we have no way to send the message... if (!process_->channel()) return; @@ -577,17 +581,17 @@ void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) { bool r = message.ReadInt(&iter, &type); DCHECK(r); - if (type == WebInputEvent::MOUSE_MOVE) { + if (type == WebInputEvent::MouseMove) { mouse_move_pending_ = false; // now, we can send the next mouse move event if (next_mouse_move_.get()) { - DCHECK(next_mouse_move_->type == WebInputEvent::MOUSE_MOVE); + DCHECK(next_mouse_move_->type == WebInputEvent::MouseMove); ForwardMouseEvent(*next_mouse_move_); } } - if (WebInputEvent::IsKeyboardEventType(type)) { + if (WebInputEvent::isKeyboardEventType(type)) { if (key_queue_.size() == 0) { LOG(ERROR) << "Got a KeyEvent back from the renderer but we " << "don't seem to have sent it to the renderer!"; diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index 7ec1638..cac1f4e 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -14,21 +14,23 @@ #include "chrome/common/ipc_channel.h" #include "chrome/common/native_web_keyboard_event.h" #include "testing/gtest/include/gtest/gtest_prod.h" -#include "webkit/glue/webinputevent.h" #include "webkit/glue/webtextdirection.h" namespace gfx { class Rect; } +namespace WebKit { +class WebInputEvent; +class WebMouseEvent; +class WebMouseWheelEvent; +} + class BackingStore; class PaintObserver; class RenderProcessHost; class RenderWidgetHostView; class TransportDIB; -class WebInputEvent; -class WebMouseEvent; -class WebMouseWheelEvent; class WebCursor; struct ViewHostMsg_PaintRect_Params; struct ViewHostMsg_ScrollRect_Params; @@ -208,8 +210,8 @@ class RenderWidgetHost : public IPC::Channel::Listener { // Forwards the given message to the renderer. These are called by the view // when it has received a message. - void ForwardMouseEvent(const WebMouseEvent& mouse_event); - void ForwardWheelEvent(const WebMouseWheelEvent& wheel_event); + void ForwardMouseEvent(const WebKit::WebMouseEvent& mouse_event); + void ForwardWheelEvent(const WebKit::WebMouseWheelEvent& wheel_event); void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event); // Update the text direction of the focused input element and notify it to a @@ -250,7 +252,8 @@ class RenderWidgetHost : public IPC::Channel::Listener { protected: // Internal implementation of the public Forward*Event() methods. - void ForwardInputEvent(const WebInputEvent& input_event, int event_size); + void ForwardInputEvent( + const WebKit::WebInputEvent& input_event, int event_size); // Called when we receive a notification indicating that the renderer // process has gone. This will reset our state so that our state will be @@ -357,7 +360,7 @@ class RenderWidgetHost : public IPC::Channel::Listener { // The next mouse move event to send (only non-null while mouse_move_pending_ // is true). - scoped_ptr<WebMouseEvent> next_mouse_move_; + scoped_ptr<WebKit::WebMouseEvent> next_mouse_move_; // The time when an input event was sent to the RenderWidget. base::TimeTicks input_event_start_time_; diff --git a/chrome/browser/renderer_host/render_widget_host_unittest.cc b/chrome/browser/renderer_host/render_widget_host_unittest.cc index 82dc076..7ebb8e8 100644 --- a/chrome/browser/renderer_host/render_widget_host_unittest.cc +++ b/chrome/browser/renderer_host/render_widget_host_unittest.cc @@ -12,6 +12,8 @@ #include "chrome/common/render_messages.h" #include "testing/gtest/include/gtest/gtest.h" +using WebKit::WebInputEvent; + // RenderWidgetHostProcess ----------------------------------------------------- class RenderWidgetHostProcess : public MockRenderProcessHost { @@ -328,9 +330,9 @@ TEST_F(RenderWidgetHostTest, HiddenPaint) { TEST_F(RenderWidgetHostTest, HandleKeyEventsWeSent) { NativeWebKeyboardEvent key_event; - key_event.type = WebInputEvent::KEY_DOWN; - key_event.modifiers = WebInputEvent::CTRL_KEY; - key_event.windows_key_code = base::VKEY_L; // non-null made up value. + key_event.type = WebInputEvent::KeyDown; + key_event.modifiers = WebInputEvent::ControlKey; + key_event.windowsKeyCode = base::VKEY_L; // non-null made up value. host_->ForwardKeyboardEvent(key_event); @@ -353,7 +355,7 @@ TEST_F(RenderWidgetHostTest, IgnoreKeyEventsWeDidntSend) { // Send a simulated, unrequested key response. We should ignore this. scoped_ptr<IPC::Message> response( new ViewHostMsg_HandleInputEvent_ACK(0)); - response->WriteInt(WebInputEvent::KEY_DOWN); + response->WriteInt(WebInputEvent::KeyDown); response->WriteBool(false); host_->OnMessageReceived(*response); diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index 8f18af1..e1ab0b2 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -14,7 +14,9 @@ #include "chrome/common/x11_util.h" #include "chrome/browser/renderer_host/backing_store.h" #include "chrome/browser/renderer_host/render_widget_host.h" -#include "webkit/glue/webinputevent.h" +#include "third_party/WebKit/WebKit/chromium/public/gtk/WebInputEventFactory.h" + +using WebKit::WebInputEventFactory; namespace { @@ -102,8 +104,8 @@ class RenderWidgetHostViewGtkWidget { static gboolean ButtonPressReleaseEvent( GtkWidget* widget, GdkEventButton* event, RenderWidgetHostViewGtk* host_view) { - WebMouseEvent wme(event); - host_view->GetRenderWidgetHost()->ForwardMouseEvent(wme); + host_view->GetRenderWidgetHost()->ForwardMouseEvent( + WebInputEventFactory::mouseEvent(event)); // TODO(evanm): why is this necessary here but not in test shell? // This logic is the same as GtkButton. @@ -115,15 +117,15 @@ class RenderWidgetHostViewGtkWidget { static gboolean MouseMoveEvent(GtkWidget* widget, GdkEventMotion* event, RenderWidgetHostViewGtk* host_view) { - WebMouseEvent wme(event); - host_view->GetRenderWidgetHost()->ForwardMouseEvent(wme); + host_view->GetRenderWidgetHost()->ForwardMouseEvent( + WebInputEventFactory::mouseEvent(event)); return FALSE; } static gboolean MouseScrollEvent(GtkWidget* widget, GdkEventScroll* event, RenderWidgetHostViewGtk* host_view) { - WebMouseWheelEvent wmwe(event); - host_view->GetRenderWidgetHost()->ForwardWheelEvent(wmwe); + host_view->GetRenderWidgetHost()->ForwardWheelEvent( + WebInputEventFactory::mouseWheelEvent(event)); return FALSE; } diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index f726958..918fdd6 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -12,7 +12,12 @@ #include "chrome/browser/renderer_host/render_widget_host.h" #include "chrome/common/native_web_keyboard_event.h" #include "skia/ext/platform_canvas.h" -#include "webkit/glue/webinputevent.h" +#include "third_party/WebKit/WebKit/chromium/public/mac/WebInputEventFactory.h" +#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" + +using WebKit::WebInputEventFactory; +using WebKit::WebMouseEvent; +using WebKit::WebMouseWheelEvent; @interface RenderWidgetHostViewCocoa (Private) - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; @@ -290,7 +295,8 @@ void RenderWidgetHostViewMac::ShutdownHost() { } - (void)mouseEvent:(NSEvent *)theEvent { - WebMouseEvent event(theEvent, self); + const WebMouseEvent& event = + WebInputEventFactory::mouseEvent(theEvent, self); renderWidgetHostView_->render_widget_host()->ForwardMouseEvent(event); } @@ -303,7 +309,8 @@ void RenderWidgetHostViewMac::ShutdownHost() { } - (void)scrollWheel:(NSEvent *)theEvent { - WebMouseWheelEvent event(theEvent, self); + const WebMouseWheelEvent& event = + WebInputEventFactory::mouseWheelEvent(theEvent, self); renderWidgetHostView_->render_widget_host()->ForwardWheelEvent(event); } diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index 7ee8935..abd3817 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -29,14 +29,19 @@ // Included for views::kReflectedMessage - TODO(beng): move this to win_util.h! #include "chrome/views/widget/widget_win.h" #include "grit/webkit_resources.h" +#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" +#include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h" #include "webkit/glue/plugins/plugin_constants_win.h" #include "webkit/glue/plugins/webplugin_delegate_impl.h" #include "webkit/glue/webcursor.h" - using base::TimeDelta; using base::TimeTicks; +using WebKit::WebInputEvent; +using WebKit::WebInputEventFactory; +using WebKit::WebMouseEvent; + namespace { // Tooltips will wrap after this width. Yes, wrap. Imagine that! @@ -901,7 +906,8 @@ LRESULT RenderWidgetHostViewWin::OnWheelEvent(UINT message, WPARAM wparam, if (!handled_by_webcontents) { render_widget_host_->ForwardWheelEvent( - WebMouseWheelEvent(m_hWnd, message, wparam, lparam)); + WebInputEventFactory::mouseWheelEvent(m_hWnd, message, wparam, + lparam)); } handled = TRUE; return 0; @@ -1049,18 +1055,19 @@ void RenderWidgetHostViewWin::ResetTooltip() { void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, WPARAM wparam, LPARAM lparam) { - WebMouseEvent event(m_hWnd, message, wparam, lparam); + WebMouseEvent event( + WebInputEventFactory::mouseEvent(m_hWnd, message, wparam, lparam)); switch (event.type) { - case WebInputEvent::MOUSE_MOVE: + case WebInputEvent::MouseMove: TrackMouseLeave(true); break; - case WebInputEvent::MOUSE_LEAVE: + case WebInputEvent::MouseLeave: TrackMouseLeave(false); break; - case WebInputEvent::MOUSE_DOWN: + case WebInputEvent::MouseDown: SetCapture(); break; - case WebInputEvent::MOUSE_UP: + case WebInputEvent::MouseUp: if (GetCapture() == m_hWnd) ReleaseCapture(); break; @@ -1068,7 +1075,7 @@ void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, render_widget_host_->ForwardMouseEvent(event); - if (activatable_ && event.type == WebInputEvent::MOUSE_DOWN) { + if (activatable_ && event.type == WebInputEvent::MouseDown) { // This is a temporary workaround for bug 765011 to get focus when the // mouse is clicked. This happens after the mouse down event is sent to // the renderer because normally Windows does a WM_SETFOCUS after diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.h b/chrome/browser/renderer_host/render_widget_host_view_win.h index 274b2ec..ceec701 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.h +++ b/chrome/browser/renderer_host/render_widget_host_view_win.h @@ -19,13 +19,13 @@ namespace gfx { class Size; class Rect; } + namespace IPC { class Message; } class BackingStore; class RenderWidgetHost; -class WebMouseEvent; typedef CWinTraits<WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0> RenderWidgetHostHWNDTraits; diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.cc b/chrome/browser/tab_contents/web_contents_view_gtk.cc index a858fea..9eaaf39 100644 --- a/chrome/browser/tab_contents/web_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/web_contents_view_gtk.cc @@ -16,8 +16,6 @@ #include "chrome/browser/tab_contents/tab_contents_delegate.h" #include "chrome/browser/tab_contents/web_contents.h" -#include "webkit/glue/webinputevent.h" - namespace { // Called when the content view gtk widget is tabbed to. We always return true diff --git a/chrome/browser/tab_contents/web_contents_view_win.cc b/chrome/browser/tab_contents/web_contents_view_win.cc index 2a159c7..b6d4bb5 100644 --- a/chrome/browser/tab_contents/web_contents_view_win.cc +++ b/chrome/browser/tab_contents/web_contents_view_win.cc @@ -29,7 +29,8 @@ #include "net/base/net_util.h" #include "webkit/glue/plugins/webplugin_delegate_impl.h" #include "webkit/glue/webdropdata.h" -#include "webkit/glue/webinputevent.h" + +using WebKit::WebInputEvent; namespace { @@ -304,7 +305,7 @@ void WebContentsViewWin::HandleKeyboardEvent( // Previous calls to TranslateMessage can generate CHAR events as well as // RAW_KEY_DOWN events, even if the latter triggered an accelerator. In these // cases, we discard the CHAR events. - if (event.type == WebInputEvent::CHAR && ignore_next_char_event_) { + if (event.type == WebInputEvent::Char && ignore_next_char_event_) { ignore_next_char_event_ = false; return; } @@ -312,19 +313,19 @@ void WebContentsViewWin::HandleKeyboardEvent( // The renderer returned a keyboard event it did not process. This may be // a keyboard shortcut that we have to process. - if (event.type == WebInputEvent::RAW_KEY_DOWN) { + if (event.type == WebInputEvent::RawKeyDown) { views::FocusManager* focus_manager = views::FocusManager::GetFocusManager(GetNativeView()); // We may not have a focus_manager at this point (if the tab has been // switched by the time this message returned). if (focus_manager) { - views::Accelerator accelerator(event.windows_key_code, - (event.modifiers & WebInputEvent::SHIFT_KEY) == - WebInputEvent::SHIFT_KEY, - (event.modifiers & WebInputEvent::CTRL_KEY) == - WebInputEvent::CTRL_KEY, - (event.modifiers & WebInputEvent::ALT_KEY) == - WebInputEvent::ALT_KEY); + views::Accelerator accelerator(event.windowsKeyCode, + (event.modifiers & WebInputEvent::ShiftKey) == + WebInputEvent::ShiftKey, + (event.modifiers & WebInputEvent::ControlKey) == + WebInputEvent::ControlKey, + (event.modifiers & WebInputEvent::AltKey) == + WebInputEvent::AltKey); // This is tricky: we want to set ignore_next_char_event_ if // ProcessAccelerator returns true. But ProcessAccelerator might delete |