diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-09 01:20:38 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-09 01:20:38 +0000 |
commit | cf4e5eb1df0fcbf192584b61e83e0b85cf23a1cf (patch) | |
tree | bce3c121d9679666d8acdf73cb082a684cf491e4 /webkit/tools/test_shell | |
parent | 710e056bd5005f8d0f9f9d5f4b8623f9c9dd7004 (diff) | |
download | chromium_src-cf4e5eb1df0fcbf192584b61e83e0b85cf23a1cf.zip chromium_src-cf4e5eb1df0fcbf192584b61e83e0b85cf23a1cf.tar.gz chromium_src-cf4e5eb1df0fcbf192584b61e83e0b85cf23a1cf.tar.bz2 |
Add support for custom cursors set by windowless plugins. Windowless plugins typically set the cursor in NPP_HandleEvent for WM_MOUSEMOVE.The current implementation looks for the cursor type and if the typedoes not match predefinedcursor types defaults to the pointer cursor.
The fixes are as below:-
1. Marshal the HCURSOR after copying it to ensure that it
remains valid. This works as a HCURSOR is a user object
and can be used across processes. Ideally we would
like to convert it to a skia bitmap but there are issues
with converting monochrome cursors.
2. Added support for marshaling platform specific data in
the webcursor Serialize/Deserialize functions. This is in
the form of functions like InitPlatformData,
SerializePlatformData, DeserializePlatformData, etc.
which are stubbed out for the other platforms.
3. Mimic webkit windowless plugin behavior where it sets a
flag to ignore the next setCursor after HandleEvent of
WM_MOUSEMOVE. If we don't do this the cursor keeps
changing between a pointerCursor and the cursor set by
the plugin which also causes flicker.
4. Fixed the WebCursor::IsEqual function to ensure that it
checks all fields for equality.
5. The browser(RenderWidgetHostViewWin) now maintains a
WebCursor instance representing the current cursor. Any
cursor updates received from the renderer update the
current cursor member maintained by the browser.
6. We intercept the SetCursor API for windowless plugins
like Flash and Silverlight and remember the cursor being
set. We don't invoke the original API as the browser UI
thread would do it anyways. This fixes the annoying
cursor flicker caused by the windowless flash plugin
instance constantly setting the cursor even when the tab
is not visible.
This fixes bug http://code.google.com/p/chromium/issues/detail?id=3800.
Review URL: http://codereview.chromium.org/15088
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell')
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 8 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate_gtk.cc | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate_win.cc | 16 |
3 files changed, 9 insertions, 20 deletions
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 5c05e34..77c7b8e 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -22,6 +22,7 @@ #include "base/basictypes.h" #include "base/ref_counted.h" +#include "webkit/glue/webcursor.h" #include "webkit/glue/webview_delegate.h" #include "webkit/glue/webwidget_delegate.h" #if defined(OS_WIN) @@ -66,9 +67,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, #else , select_trailing_whitespace_enabled_(false) #endif -#if defined(OS_WIN) - , custom_cursor_(NULL) -#elif defined(OS_LINUX) +#if defined(OS_LINUX) , cursor_type_(GDK_X_CURSOR) #endif { @@ -310,9 +309,8 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, // true if we want to enable selection of trailing whitespaces bool select_trailing_whitespace_enabled_; + WebCursor current_cursor_; #if defined(OS_WIN) - HCURSOR custom_cursor_; - // Classes needed by drag and drop. scoped_refptr<TestDragDelegate> drag_delegate_; scoped_refptr<TestDropDelegate> drop_delegate_; diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc index 6db73b4..831691a 100644 --- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc +++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc @@ -111,13 +111,14 @@ void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) { void TestWebViewDelegate::SetCursor(WebWidget* webwidget, const WebCursor& cursor) { - GdkCursorType cursor_type = cursor.GetCursorType(); + current_cursor_ = cursor; + GdkCursorType cursor_type = current_cursor_.GetCursorType(); GdkCursor* gdk_cursor; if (cursor_type == GDK_CURSOR_IS_PIXMAP) { // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is // that calling gdk_window_set_cursor repeatedly is expensive. We should // avoid it here where possible. - gdk_cursor = cursor.GetCustomCursor(); + gdk_cursor = current_cursor_.GetCustomCursor(); } else { // Optimize the common case, where the cursor hasn't changed. // However, we can switch between different pixmaps, so only on the diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc index cea089a..30431f6 100644 --- a/webkit/tools/test_shell/test_webview_delegate_win.cc +++ b/webkit/tools/test_shell/test_webview_delegate_win.cc @@ -36,8 +36,6 @@ // WebViewDelegate ----------------------------------------------------------- TestWebViewDelegate::~TestWebViewDelegate() { - if (custom_cursor_) - DestroyIcon(custom_cursor_); RevokeDragDrop(shell_->webViewWnd()); } @@ -89,17 +87,9 @@ void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) { void TestWebViewDelegate::SetCursor(WebWidget* webwidget, const WebCursor& cursor) { if (WebWidgetHost* host = GetHostForWidget(webwidget)) { - if (custom_cursor_) { - DestroyIcon(custom_cursor_); - custom_cursor_ = NULL; - } - if (cursor.IsCustom()) { - custom_cursor_ = cursor.GetCustomCursor(); - host->SetCursor(custom_cursor_); - } else { - HINSTANCE mod_handle = GetModuleHandle(NULL); - host->SetCursor(cursor.GetCursor(mod_handle)); - } + current_cursor_ = cursor; + HINSTANCE mod_handle = GetModuleHandle(NULL); + host->SetCursor(current_cursor_.GetCursor(mod_handle)); } } |