diff options
25 files changed, 253 insertions, 55 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 629a908..32eca24 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -1208,7 +1208,8 @@ void RenderViewHost::OnUserMetricsRecordAction(const std::wstring& action) { UserMetrics::RecordComputedAction(action.c_str(), process()->profile()); } -void RenderViewHost::UnhandledKeyboardEvent(const WebKeyboardEvent& event) { +void RenderViewHost::UnhandledKeyboardEvent( + const NativeWebKeyboardEvent& event) { RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); if (view) { // TODO(brettw) why do we have to filter these types of events here. Can't diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 29ed8e4..a10f421 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H__ -#define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H__ +#ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ +#define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ #include <string> #include <vector> @@ -428,7 +428,7 @@ class RenderViewHost : public RenderWidgetHost { protected: // RenderWidgetHost protected overrides. - virtual void UnhandledKeyboardEvent(const WebKeyboardEvent& event); + virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event); virtual void OnEnterOrSpace(); virtual void NotifyRendererUnresponsive(); virtual void NotifyRendererResponsive(); @@ -644,4 +644,4 @@ class RenderViewHostFactory { base::WaitableEvent* modal_dialog_event) = 0; }; -#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H__ +#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 30870af..302a1d0 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -12,6 +12,7 @@ #include "base/file_path.h" #include "base/gfx/rect.h" #include "base/logging.h" +#include "chrome/common/native_web_keyboard_event.h" #include "net/base/load_states.h" #include "webkit/glue/password_form.h" #include "webkit/glue/webpreferences.h" @@ -111,7 +112,7 @@ class RenderViewHostDelegate { // Callback to inform the browser that the renderer did not process the // specified events. This gives an opportunity to the browser to process the // event (used for keyboard shortcuts). - virtual void HandleKeyboardEvent(const WebKeyboardEvent& event) = 0; + virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0; // Forwards message to DevToolsClient in developer tools window open for // this page. diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index 3e45ba5..83d7bcf 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -291,13 +291,29 @@ void RenderWidgetHost::ForwardWheelEvent( ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent)); } -void RenderWidgetHost::ForwardKeyboardEvent(const WebKeyboardEvent& key_event) { +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)) { 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)) { + // Don't add this key to the queue if we have no way to send the message... + if (!process_->channel()) + return; + + // Put all WebKeyboardEvent objects in a queue since we can't trust the + // renderer and we need to give something to the UnhandledInputEvent + // handler. + key_queue_.push(key_event); + HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size()); + } + + // Only forward the non-native portions of our event. ForwardInputEvent(key_event, sizeof(WebKeyboardEvent)); } @@ -306,14 +322,6 @@ void RenderWidgetHost::ForwardInputEvent(const WebInputEvent& input_event, if (!process_->channel()) return; - if (WebInputEvent::IsKeyboardEventType(input_event.type)) { - // Put all WebKeyboardEvent objects in a queue since we can't trust the - // renderer and we need to give something to the UnhandledInputEvent - // handler. - key_queue_.push(static_cast<const WebKeyboardEvent&>(input_event)); - HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size()); - } - IPC::Message* message = new ViewMsg_HandleInputEvent(routing_id_); message->WriteData( reinterpret_cast<const char*>(&input_event), event_size); @@ -569,7 +577,8 @@ void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) { << "don't seem to have sent it to the renderer!"; } else if (key_queue_.front().type != type) { LOG(ERROR) << "We seem to have a different key type sent from " - << "the renderer. Ignoring event."; + << "the renderer. (" << key_queue_.front().type << " vs. " + << type << "). Ignoring event."; } else { bool processed = false; r = message.ReadBool(&iter, &processed); diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index 0a749b8..6e80a9d 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -11,6 +11,7 @@ #include "base/gfx/size.h" #include "base/timer.h" #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" @@ -24,7 +25,6 @@ class RenderProcessHost; class RenderWidgetHostView; class TransportDIB; class WebInputEvent; -class WebKeyboardEvent; class WebMouseEvent; class WebMouseWheelEvent; class WebCursor; @@ -208,14 +208,16 @@ class RenderWidgetHost : public IPC::Channel::Listener { // when it has received a message. void ForwardMouseEvent(const WebMouseEvent& mouse_event); void ForwardWheelEvent(const WebMouseWheelEvent& wheel_event); - void ForwardKeyboardEvent(const WebKeyboardEvent& key_event); - void ForwardInputEvent(const WebInputEvent& input_event, int event_size); + void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event); // This is for derived classes to give us access to the resizer rect. // And to also expose it to the RenderWidgetHostView. virtual gfx::Rect GetRootWindowResizerRect() const; protected: + // Internal implementation of the public Forward*Event() methods. + void ForwardInputEvent(const 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 // consistent if a new renderer is created. @@ -223,7 +225,7 @@ class RenderWidgetHost : public IPC::Channel::Listener { // Called when we an InputEvent was not processed by the renderer. This is // overridden by RenderView to send upwards to its delegate. - virtual void UnhandledKeyboardEvent(const WebKeyboardEvent& event) {} + virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} // Notification that the user pressed the enter key or the spacebar. The // render view host overrides this to forward the information to its delegate @@ -353,7 +355,7 @@ class RenderWidgetHost : public IPC::Channel::Listener { base::TimeTicks repaint_start_time_; // Queue of keyboard events that we need to track. - typedef std::queue<WebKeyboardEvent> KeyQueue; + typedef std::queue<NativeWebKeyboardEvent> KeyQueue; // A queue of keyboard events. We can't trust data from the renderer so we // stuff key events into a queue and pop them out on ACK, feeding our copy diff --git a/chrome/browser/renderer_host/render_widget_host_unittest.cc b/chrome/browser/renderer_host/render_widget_host_unittest.cc index da37f01..9e656f5 100644 --- a/chrome/browser/renderer_host/render_widget_host_unittest.cc +++ b/chrome/browser/renderer_host/render_widget_host_unittest.cc @@ -134,7 +134,7 @@ class MockRenderWidgetHost : public RenderWidgetHost { } protected: - virtual void UnhandledKeyboardEvent(const WebKeyboardEvent& event) { + virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) { unhandled_keyboard_event_called_ = true; } @@ -327,7 +327,7 @@ TEST_F(RenderWidgetHostTest, HiddenPaint) { } TEST_F(RenderWidgetHostTest, HandleKeyEventsWeSent) { - WebKeyboardEvent key_event; + 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. 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 13c1eb2..4b8749b 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -10,6 +10,7 @@ #include "base/logging.h" #include "base/string_util.h" +#include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/x11_util.h" #include "chrome/browser/renderer_host/backing_store.h" #include "chrome/browser/renderer_host/render_widget_host.h" @@ -75,7 +76,7 @@ class RenderWidgetHostViewGtkWidget { static gboolean KeyPressReleaseEvent(GtkWidget* widget, GdkEventKey* event, RenderWidgetHostViewGtk* host_view) { - WebKeyboardEvent wke(event); + NativeWebKeyboardEvent wke(event); host_view->GetRenderWidgetHost()->ForwardKeyboardEvent(wke); 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 85e29cc..549a22f 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -10,6 +10,7 @@ #include "chrome/browser/renderer_host/backing_store.h" #include "chrome/browser/renderer_host/render_process_host.h" #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" @@ -250,7 +251,7 @@ void RenderWidgetHostViewMac::ShutdownHost() { } - (void)keyEvent:(NSEvent *)theEvent { - WebKeyboardEvent event(theEvent); + NativeWebKeyboardEvent event(theEvent); renderWidgetHostView_->render_widget_host()->ForwardKeyboardEvent(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 1139000..f25cb86 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -20,6 +20,7 @@ #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/l10n_util.h" #include "chrome/common/l10n_util_win.h" +#include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/plugin_messages.h" #include "chrome/common/render_messages.h" #include "chrome/common/resource_bundle.h" @@ -823,7 +824,7 @@ LRESULT RenderWidgetHostViewWin::OnKeyEvent(UINT message, WPARAM wparam, } render_widget_host_->ForwardKeyboardEvent( - WebKeyboardEvent(m_hWnd, message, wparam, lparam)); + NativeWebKeyboardEvent(m_hWnd, message, wparam, lparam)); return 0; } diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index a56618b..33754fe 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -86,7 +86,7 @@ class InterstitialPage::InterstitialPageRVHViewDelegate virtual void StartDragging(const WebDropData& drop_data); virtual void UpdateDragCursor(bool is_drop_target); virtual void TakeFocus(bool reverse); - virtual void HandleKeyboardEvent(const WebKeyboardEvent& event); + virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); virtual void ForwardMessageToDevToolsClient(const IPC::Message& message); virtual void OnFindReply(int request_id, int number_of_matches, @@ -499,7 +499,7 @@ void InterstitialPage::InterstitialPageRVHViewDelegate::TakeFocus( } void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent( - const WebKeyboardEvent& event) { + const NativeWebKeyboardEvent& event) { if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event); } diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.cc b/chrome/browser/tab_contents/web_contents_view_gtk.cc index 5b14c08..35ca7b1 100644 --- a/chrome/browser/tab_contents/web_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/web_contents_view_gtk.cc @@ -146,7 +146,7 @@ void WebContentsViewGtk::TakeFocus(bool reverse) { web_contents_->delegate()->SetFocusToLocationBar(); } -void WebContentsViewGtk::HandleKeyboardEvent(const WebKeyboardEvent& event) { +void WebContentsViewGtk::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { // The renderer returned a keyboard event it did not process. This may be // a keyboard shortcut that we have to process. // The windows code forwards this event onwards to accelerator handling, diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.h b/chrome/browser/tab_contents/web_contents_view_gtk.h index ea5e38c..8975ce6 100644 --- a/chrome/browser/tab_contents/web_contents_view_gtk.h +++ b/chrome/browser/tab_contents/web_contents_view_gtk.h @@ -54,7 +54,7 @@ class WebContentsViewGtk : public WebContentsView { virtual void StartDragging(const WebDropData& drop_data); virtual void UpdateDragCursor(bool is_drop_target); virtual void TakeFocus(bool reverse); - virtual void HandleKeyboardEvent(const WebKeyboardEvent& event); + virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); virtual void OnFindReply(int request_id, int number_of_matches, const gfx::Rect& selection_rect, diff --git a/chrome/browser/tab_contents/web_contents_view_mac.h b/chrome/browser/tab_contents/web_contents_view_mac.h index 44772a5..497725c 100644 --- a/chrome/browser/tab_contents/web_contents_view_mac.h +++ b/chrome/browser/tab_contents/web_contents_view_mac.h @@ -69,7 +69,7 @@ class WebContentsViewMac : public WebContentsView, virtual void StartDragging(const WebDropData& drop_data); virtual void UpdateDragCursor(bool is_drop_target); virtual void TakeFocus(bool reverse); - virtual void HandleKeyboardEvent(const WebKeyboardEvent& event); + virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); virtual void OnFindReply(int request_id, int number_of_matches, const gfx::Rect& selection_rect, diff --git a/chrome/browser/tab_contents/web_contents_view_mac.mm b/chrome/browser/tab_contents/web_contents_view_mac.mm index acdf717..56f9d4e 100644 --- a/chrome/browser/tab_contents/web_contents_view_mac.mm +++ b/chrome/browser/tab_contents/web_contents_view_mac.mm @@ -155,9 +155,10 @@ void WebContentsViewMac::TakeFocus(bool reverse) { [cocoa_view_.get() becomeFirstResponder]; } -void WebContentsViewMac::HandleKeyboardEvent(const WebKeyboardEvent& event) { +void WebContentsViewMac::HandleKeyboardEvent( + const NativeWebKeyboardEvent& event) { // The renderer returned a keyboard event it did not process. TODO(avi): - // reconstruct an NSEvent and feed it to the view. + // Grab the NSEvent off |event| and feed it to the view. NOTIMPLEMENTED(); } diff --git a/chrome/browser/tab_contents/web_contents_view_win.cc b/chrome/browser/tab_contents/web_contents_view_win.cc index c66d339..c0e1aab 100644 --- a/chrome/browser/tab_contents/web_contents_view_win.cc +++ b/chrome/browser/tab_contents/web_contents_view_win.cc @@ -247,7 +247,8 @@ void WebContentsViewWin::TakeFocus(bool reverse) { focus_manager->AdvanceFocus(reverse); } -void WebContentsViewWin::HandleKeyboardEvent(const WebKeyboardEvent& event) { +void WebContentsViewWin::HandleKeyboardEvent( + const NativeWebKeyboardEvent& event) { // 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. @@ -291,10 +292,10 @@ void WebContentsViewWin::HandleKeyboardEvent(const WebKeyboardEvent& event) { // Any unhandled keyboard/character messages should be defproced. // This allows stuff like Alt+F4, etc to work correctly. - DefWindowProc(event.actual_message.hwnd, - event.actual_message.message, - event.actual_message.wParam, - event.actual_message.lParam); + DefWindowProc(event.os_event.hwnd, + event.os_event.message, + event.os_event.wParam, + event.os_event.lParam); } void WebContentsViewWin::ShowContextMenu(const ContextMenuParams& params) { diff --git a/chrome/browser/tab_contents/web_contents_view_win.h b/chrome/browser/tab_contents/web_contents_view_win.h index afa2c3a..15fd3f5 100644 --- a/chrome/browser/tab_contents/web_contents_view_win.h +++ b/chrome/browser/tab_contents/web_contents_view_win.h @@ -59,7 +59,7 @@ class WebContentsViewWin : public WebContentsView, virtual void StartDragging(const WebDropData& drop_data); virtual void UpdateDragCursor(bool is_drop_target); virtual void TakeFocus(bool reverse); - virtual void HandleKeyboardEvent(const WebKeyboardEvent& event); + virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); private: // Windows events ------------------------------------------------------------ diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index da41a40..43ff07a 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -208,6 +208,10 @@ 'common/modal_dialog_event.h', 'common/mru_cache.h', 'common/navigation_types.h', + 'common/native_web_keyboard_event.h', + 'common/native_web_keyboard_event_linux.cc', + 'common/native_web_keyboard_event_mac.mm', + 'common/native_web_keyboard_event_win.cc', 'common/notification_details.h', 'common/notification_observer.h', 'common/notification_registrar.cc', diff --git a/chrome/common/common.scons b/chrome/common/common.scons index 7ebad2e..b7fd21e 100644 --- a/chrome/common/common.scons +++ b/chrome/common/common.scons @@ -162,6 +162,8 @@ input_files = ChromeFileList([ 'message_router.cc', 'message_router.h', 'mru_cache.h', + 'native_web_keyboard_event.h', + 'native_web_keyboard_event_linux.cc', 'navigation_types.h', 'notification_details.h', 'notification_registrar.cc', diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj index e409d1d..53ac35f 100644 --- a/chrome/common/common.vcproj +++ b/chrome/common/common.vcproj @@ -562,6 +562,14 @@ > </File> <File + RelativePath=".\native_web_keyboard_event.h" + > + </File> + <File + RelativePath=".\native_web_keyboard_event_win.cc" + > + </File> + <File RelativePath=".\notification_details.h" > </File> diff --git a/chrome/common/native_web_keyboard_event.h b/chrome/common/native_web_keyboard_event.h new file mode 100644 index 0000000..f4c22c0 --- /dev/null +++ b/chrome/common/native_web_keyboard_event.h @@ -0,0 +1,50 @@ +// 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 CHROME_COMMON_NATIVE_WEB_KEYBOARD_EVENT_H_ +#define CHROME_COMMON_NATIVE_WEB_KEYBOARD_EVENT_H_ + +#include "base/basictypes.h" +#include "webkit/glue/webinputevent.h" + +#if defined(OS_WIN) +#include <windows.h> +#elif defined(OS_MACOSX) +#ifdef __OBJC__ +@class NSEvent; +#else +class NSEvent; +#endif // __OBJC__ +#elif defined(OS_LINUX) +#include <gdk/gdk.h> +#endif + +// Owns a platform specific event; used to pass own and pass event through +// platform independent code. +struct NativeWebKeyboardEvent : public WebKeyboardEvent { + NativeWebKeyboardEvent(); + +#if defined(OS_WIN) + NativeWebKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); +#elif defined(OS_MACOSX) + explicit NativeWebKeyboardEvent(NSEvent *event); +#elif defined(OS_LINUX) + explicit NativeWebKeyboardEvent(const GdkEventKey* event); +#endif + + NativeWebKeyboardEvent(const NativeWebKeyboardEvent& event); + ~NativeWebKeyboardEvent(); + + NativeWebKeyboardEvent& operator=(const NativeWebKeyboardEvent& event); + +#if defined(OS_WIN) + MSG os_event; +#elif defined(OS_MACOSX) + NSEvent* os_event; +#elif defined(OS_LINUX) + GdkEventKey* os_event; +#endif +}; + +#endif // CHROME_COMMON_NATIVE_WEB_KEYBOARD_EVENT_H_ diff --git a/chrome/common/native_web_keyboard_event_linux.cc b/chrome/common/native_web_keyboard_event_linux.cc new file mode 100644 index 0000000..744ba3d --- /dev/null +++ b/chrome/common/native_web_keyboard_event_linux.cc @@ -0,0 +1,53 @@ +// 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 "chrome/common/native_web_keyboard_event.h" + +namespace { + +void CopyEventTo(const GdkEventKey* in, GdkEventKey** out) { + if (in) { + *out = reinterpret_cast<GdkEventKey*>( + gdk_event_copy( + reinterpret_cast<GdkEvent*>(const_cast<GdkEventKey*>(in)))); + } else { + *out = NULL; + } +} + +void FreeEvent(GdkEventKey* event) { + if (event) { + gdk_event_free(reinterpret_cast<GdkEvent*>(event)); + } +} + +} // namespace + + +NativeWebKeyboardEvent::NativeWebKeyboardEvent() + : os_event(NULL) { +} + +NativeWebKeyboardEvent::NativeWebKeyboardEvent(const GdkEventKey* native_event) + : WebKeyboardEvent(native_event) { + CopyEventTo(native_event, &os_event); +} + +NativeWebKeyboardEvent::NativeWebKeyboardEvent( + const NativeWebKeyboardEvent& other) : WebKeyboardEvent(other) { + CopyEventTo(other.os_event, &os_event); +} + +NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( + const NativeWebKeyboardEvent& other) { + WebKeyboardEvent::operator=(other); + + FreeEvent(os_event); + CopyEventTo(other.os_event, &os_event); + return *this; +} + +NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { + FreeEvent(os_event); +} diff --git a/chrome/common/native_web_keyboard_event_mac.mm b/chrome/common/native_web_keyboard_event_mac.mm new file mode 100644 index 0000000..4e1b9b5 --- /dev/null +++ b/chrome/common/native_web_keyboard_event_mac.mm @@ -0,0 +1,37 @@ +// 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 "chrome/common/native_web_keyboard_event.h" + +#import <AppKit/AppKit.h> + +NativeWebKeyboardEvent::NativeWebKeyboardEvent() + : os_event(NULL) { +} + +NativeWebKeyboardEvent::NativeWebKeyboardEvent(NSEvent* event) + : WebKeyboardEvent(event), + os_event([event retain]) { +} + +NativeWebKeyboardEvent::NativeWebKeyboardEvent( + const NativeWebKeyboardEvent& other) + : WebKeyboardEvent(other), + os_event([other.os_event retain]) { +} + +NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( + const NativeWebKeyboardEvent& other) { + WebKeyboardEvent::operator=(other); + + NSObject* previous = os_event; + os_event = [other.os_event retain]; + [previous release]; + + return *this; +} + +NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { + [os_event release]; +} diff --git a/chrome/common/native_web_keyboard_event_win.cc b/chrome/common/native_web_keyboard_event_win.cc new file mode 100644 index 0000000..0e2e11f --- /dev/null +++ b/chrome/common/native_web_keyboard_event_win.cc @@ -0,0 +1,41 @@ +// 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 "chrome/common/native_web_keyboard_event.h" + +NativeWebKeyboardEvent::NativeWebKeyboardEvent() { +} + +NativeWebKeyboardEvent::NativeWebKeyboardEvent( + HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) + : WebKeyboardEvent(hwnd, message, wparam, lparam) { + os_event.hwnd = hwnd; + os_event.message = message; + os_event.wParam = wparam; + os_event.lParam = lparam; +} + +NativeWebKeyboardEvent::NativeWebKeyboardEvent( + const NativeWebKeyboardEvent& other) + : WebKeyboardEvent(other) { + os_event.hwnd = other.os_event.hwnd; + os_event.message = other.os_event.message; + os_event.wParam = other.os_event.wParam; + os_event.lParam = other.os_event.lParam; +} + +NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( + const NativeWebKeyboardEvent& other) { + WebKeyboardEvent::operator=(other); + + os_event.hwnd = other.os_event.hwnd; + os_event.message = other.os_event.message; + os_event.wParam = other.os_event.wParam; + os_event.lParam = other.os_event.lParam; + return *this; +} + +NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { + // Noop under windows +} diff --git a/webkit/glue/webinputevent.h b/webkit/glue/webinputevent.h index ab71b83..b4d2279 100644 --- a/webkit/glue/webinputevent.h +++ b/webkit/glue/webinputevent.h @@ -182,28 +182,18 @@ class WebKeyboardEvent : public WebInputEvent { // 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; - // References to the original event. -#if defined(OS_WIN) - MSG actual_message; // Set to the current keyboard message. TODO(avi): remove -#endif - 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) - memset(&actual_message, 0, sizeof(actual_message)); -#endif } #if defined(OS_WIN) - explicit WebKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, - LPARAM lparam); + WebKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); #elif defined(OS_MACOSX) explicit WebKeyboardEvent(NSEvent *event); #elif defined(OS_LINUX) diff --git a/webkit/glue/webinputevent_win.cc b/webkit/glue/webinputevent_win.cc index 8c82901..9a6ea7d 100644 --- a/webkit/glue/webinputevent_win.cc +++ b/webkit/glue/webinputevent_win.cc @@ -283,11 +283,6 @@ WebKeyboardEvent::WebKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { system_key = false; - actual_message.hwnd = hwnd; - actual_message.message = message; - actual_message.wParam = wparam; - actual_message.lParam = lparam; - windows_key_code = native_key_code = static_cast<int>(wparam); switch (message) { |