summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-09 01:20:38 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-09 01:20:38 +0000
commitcf4e5eb1df0fcbf192584b61e83e0b85cf23a1cf (patch)
treebce3c121d9679666d8acdf73cb082a684cf491e4 /chrome
parent710e056bd5005f8d0f9f9d5f4b8623f9c9dd7004 (diff)
downloadchromium_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 'chrome')
-rw-r--r--chrome/browser/render_widget_host_view_win.cc37
-rw-r--r--chrome/browser/render_widget_host_view_win.h7
2 files changed, 14 insertions, 30 deletions
diff --git a/chrome/browser/render_widget_host_view_win.cc b/chrome/browser/render_widget_host_view_win.cc
index d927868..04ad8f5 100644
--- a/chrome/browser/render_widget_host_view_win.cc
+++ b/chrome/browser/render_widget_host_view_win.cc
@@ -67,8 +67,6 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
: render_widget_host_(widget),
- cursor_(LoadCursor(NULL, IDC_ARROW)),
- cursor_is_custom_(false),
track_mouse_leave_(false),
ime_notification_(false),
is_hidden_(false),
@@ -85,8 +83,6 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
}
RenderWidgetHostViewWin::~RenderWidgetHostViewWin() {
- if (cursor_is_custom_)
- DestroyIcon(cursor_);
ResetTooltip();
}
@@ -218,33 +214,22 @@ gfx::Rect RenderWidgetHostViewWin::GetViewBounds() const {
}
void RenderWidgetHostViewWin::UpdateCursor(const WebCursor& cursor) {
- static HINSTANCE module_handle =
- GetModuleHandle(chrome::kBrowserResourcesDll);
-
- // If the last active cursor was a custom cursor, we need to destroy
- // it before setting the new one.
- if (cursor_is_custom_)
- DestroyIcon(cursor_);
-
- cursor_is_custom_ = cursor.IsCustom();
- if (cursor_is_custom_) {
- cursor_ = cursor.GetCustomCursor();
- } else {
- // We cannot pass in NULL as the module handle as this would only
- // work for standard win32 cursors. We can also receive cursor
- // types which are defined as webkit resources. We need to specify
- // the module handle of chrome.dll while loading these cursors.
- cursor_ = cursor.GetCursor(module_handle);
- }
-
+ current_cursor_ = cursor;
UpdateCursorIfOverSelf();
}
void RenderWidgetHostViewWin::UpdateCursorIfOverSelf() {
static HCURSOR kCursorArrow = LoadCursor(NULL, IDC_ARROW);
static HCURSOR kCursorAppStarting = LoadCursor(NULL, IDC_APPSTARTING);
+ static HINSTANCE module_handle =
+ GetModuleHandle(chrome::kBrowserResourcesDll);
+
+ // We cannot pass in NULL as the module handle as this would only work for
+ // standard win32 cursors. We can also receive cursor types which are defined
+ // as webkit resources. We need to specify the module handle of chrome.dll
+ // while loading these cursors.
+ HCURSOR display_cursor = current_cursor_.GetCursor(module_handle);
- HCURSOR display_cursor = cursor_;
// If a page is in the loading state, we want to show the Arrow+Hourglass
// cursor only when the current cursor is the ARROW cursor. In all other
// cases we should continue to display the current cursor.
@@ -780,6 +765,9 @@ LRESULT RenderWidgetHostViewWin::OnWheelEvent(UINT message, WPARAM wparam,
LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT, WPARAM, LPARAM,
BOOL& handled) {
+ if (!focus_on_show_)
+ return MA_NOACTIVATE;
+
HWND focus_window = GetFocus();
if (!::IsWindow(focus_window) || !IsChild(focus_window)) {
// We handle WM_MOUSEACTIVATE to set focus to the underlying plugin
@@ -916,4 +904,3 @@ void RenderWidgetHostViewWin::ShutdownHost() {
render_widget_host_->Shutdown();
// Do not touch any members at this point, |this| has been deleted.
}
-
diff --git a/chrome/browser/render_widget_host_view_win.h b/chrome/browser/render_widget_host_view_win.h
index be3c6b5..df6457c 100644
--- a/chrome/browser/render_widget_host_view_win.h
+++ b/chrome/browser/render_widget_host_view_win.h
@@ -212,11 +212,8 @@ class RenderWidgetHostViewWin :
// The associated Model.
RenderWidgetHost* render_widget_host_;
- // The cursor for the page. This is passed up from the renderer.
- HCURSOR cursor_;
-
- // True if cursor_ is a custom cursor that needs to be destroyed later.
- bool cursor_is_custom_;
+ // The cursor for the page. This is passed up from the renderer.
+ WebCursor current_cursor_;
// Indicates if the page is loading.
bool is_loading_;