diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 21:29:36 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 21:29:36 +0000 |
commit | 11e04ce0c6a47c3fc6561816c01656875292622d (patch) | |
tree | da0826ec7e19ce06c42e1d65cd4b5166627ae8aa /webkit | |
parent | 4f6e87b9b51b050d45eb2f1175f80de94dd5892b (diff) | |
download | chromium_src-11e04ce0c6a47c3fc6561816c01656875292622d.zip chromium_src-11e04ce0c6a47c3fc6561816c01656875292622d.tar.gz chromium_src-11e04ce0c6a47c3fc6561816c01656875292622d.tar.bz2 |
Implement the grab/grabbing cursors (for Mac/GTK).
BUG=73356
TEST=comment 12 on the bug has a test page; ensure the last two cursors (grab and grabbing) show open and closed hand cursors (respectively) and don't crash
Review URL: http://codereview.chromium.org/6591105
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76616 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/webcursor_gtk.cc | 8 | ||||
-rw-r--r-- | webkit/glue/webcursor_gtk_data.h | 62 | ||||
-rw-r--r-- | webkit/glue/webcursor_mac.mm | 19 | ||||
-rw-r--r-- | webkit/glue/webcursor_win.cc | 7 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 2 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 4 |
6 files changed, 92 insertions, 10 deletions
diff --git a/webkit/glue/webcursor_gtk.cc b/webkit/glue/webcursor_gtk.cc index ca3555a..c315b2a 100644 --- a/webkit/glue/webcursor_gtk.cc +++ b/webkit/glue/webcursor_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -153,6 +153,8 @@ int WebCursor::GetCursorType() const { NOTIMPLEMENTED(); return GDK_LAST_CURSOR; case WebCursorInfo::TypeZoomIn: case WebCursorInfo::TypeZoomOut: + case WebCursorInfo::TypeGrab: + case WebCursorInfo::TypeGrabbing: case WebCursorInfo::TypeCustom: return GDK_CURSOR_IS_PIXMAP; } @@ -178,6 +180,10 @@ GdkCursor* WebCursor::GetCustomCursor() { return GetInlineCustomCursor(CustomCursorZoomIn); case WebCursorInfo::TypeZoomOut: return GetInlineCustomCursor(CustomCursorZoomOut); + case WebCursorInfo::TypeGrab: + return GetInlineCustomCursor(CustomCursorGrab); + case WebCursorInfo::TypeGrabbing: + return GetInlineCustomCursor(CustomCursorGrabbing); } if (type_ != WebCursorInfo::TypeCustom) { diff --git a/webkit/glue/webcursor_gtk_data.h b/webkit/glue/webcursor_gtk_data.h index 8bffcb7..a983143 100644 --- a/webkit/glue/webcursor_gtk_data.h +++ b/webkit/glue/webcursor_gtk_data.h @@ -193,14 +193,70 @@ static const char moz_zoom_out_mask_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +/* MOZ_CURSOR_HAND_GRAB */ +static const char moz_hand_grab_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, + 0x60, 0x39, 0x00, 0x00, 0x90, 0x49, 0x00, 0x00, 0x90, 0x49, 0x01, 0x00, + 0x20, 0xc9, 0x02, 0x00, 0x20, 0x49, 0x02, 0x00, 0x58, 0x40, 0x02, 0x00, + 0x64, 0x00, 0x02, 0x00, 0x44, 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, 0x00, + 0x10, 0x00, 0x01, 0x00, 0x10, 0x80, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, + 0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const char moz_hand_grab_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x3f, 0x00, 0x00, + 0xf0, 0x7f, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf8, 0xff, 0x03, 0x00, + 0xf0, 0xff, 0x07, 0x00, 0xf8, 0xff, 0x07, 0x00, 0xfc, 0xff, 0x07, 0x00, + 0xfe, 0xff, 0x07, 0x00, 0xfe, 0xff, 0x03, 0x00, 0xfc, 0xff, 0x03, 0x00, + 0xf8, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x01, 0x00, + 0xe0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +/* MOZ_CURSOR_HAND_GRABBING */ +static const char moz_hand_grabbing_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xc0, 0x36, 0x00, 0x00, 0x20, 0xc9, 0x00, 0x00, 0x20, 0x40, 0x01, 0x00, + 0x40, 0x00, 0x01, 0x00, 0x60, 0x00, 0x01, 0x00, 0x10, 0x00, 0x01, 0x00, + 0x10, 0x00, 0x01, 0x00, 0x10, 0x80, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, + 0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const char moz_hand_grabbing_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x36, 0x00, 0x00, + 0xe0, 0xff, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x03, 0x00, + 0xe0, 0xff, 0x03, 0x00, 0xf0, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x03, 0x00, + 0xf8, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x01, 0x00, + 0xe0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + enum CustomCursorType { CustomCursorCopy = 0, CustomCursorAlias, CustomCursorContextMenu, CustomCursorZoomIn, CustomCursorZoomOut, - CustomCursorVerticalText -} ; + CustomCursorVerticalText, + CustomCursorGrab, + CustomCursorGrabbing, +}; typedef struct { const char* name; @@ -218,6 +274,8 @@ static const CustomCursor CustomCursors[] = { { "zoom-in", moz_zoom_in_bits, moz_zoom_in_mask_bits, 6, 6 }, { "zoom-out", moz_zoom_out_bits, moz_zoom_out_mask_bits, 6, 6 }, { "vertical-text", moz_vertical_text_bits, moz_vertical_text_mask_bits, 8, 4 }, + { "grab", moz_hand_grab_bits, moz_hand_grab_mask_bits, 10, 10 }, + { "grabbing", moz_hand_grabbing_bits, moz_hand_grabbing_mask_bits, 10, 10 } }; // This cursor intentionally left out of above structs. It is only used by diff --git a/webkit/glue/webcursor_mac.mm b/webkit/glue/webcursor_mac.mm index 680521d..da80efa 100644 --- a/webkit/glue/webcursor_mac.mm +++ b/webkit/glue/webcursor_mac.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -153,6 +153,10 @@ NSCursor* WebCursor::GetCursor() const { return LoadCursor("zoomInCursor", 7, 7); case WebCursorInfo::TypeZoomOut: return LoadCursor("zoomOutCursor", 7, 7); + case WebCursorInfo::TypeGrab: + return [NSCursor openHandCursor]; + case WebCursorInfo::TypeGrabbing: + return [NSCursor closedHandCursor]; case WebCursorInfo::TypeCustom: return CreateCustomCursor(custom_data_, custom_size_, hotspot_); } @@ -192,7 +196,11 @@ void WebCursor::InitFromThemeCursor(ThemeCursor cursor) { cursor_info.type = WebCursorInfo::TypeWait; break; case kThemeClosedHandCursor: + cursor_info.type = WebCursorInfo::TypeGrabbing; + break; case kThemeOpenHandCursor: + cursor_info.type = WebCursorInfo::TypeGrab; + break; case kThemePointingHandCursor: case kThemeCountingUpHandCursor: case kThemeCountingDownHandCursor: @@ -297,10 +305,13 @@ void WebCursor::InitFromNSCursor(NSCursor* cursor) { cursor_info.type = WebCursorInfo::TypeSouthResize; } else if ([cursor isEqual:[NSCursor resizeUpDownCursor]]) { cursor_info.type = WebCursorInfo::TypeNorthSouthResize; + } else if ([cursor isEqual:[NSCursor openHandCursor]]) { + cursor_info.type = WebCursorInfo::TypeGrab; + } else if ([cursor isEqual:[NSCursor closedHandCursor]]) { + cursor_info.type = WebCursorInfo::TypeGrabbing; } else { - // Also handles the [NSCursor closedHandCursor], [NSCursor openHandCursor], - // and [NSCursor disappearingItemCursor] cases. Quick-and-dirty image - // conversion; TODO(avi): do better. + // Also handles the [NSCursor disappearingItemCursor] case. Quick-and-dirty + // image conversion; TODO(avi): do better. CGImageRef cg_image = nil; NSImage* image = [cursor image]; for (id rep in [image representations]) { diff --git a/webkit/glue/webcursor_win.cc b/webkit/glue/webcursor_win.cc index 3399c7c..2acab4d 100644 --- a/webkit/glue/webcursor_win.cc +++ b/webkit/glue/webcursor_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -96,6 +96,11 @@ static LPCWSTR ToCursorID(WebCursorInfo::Type type) { return MAKEINTRESOURCE(IDC_ZOOMIN); case WebCursorInfo::TypeZoomOut: return MAKEINTRESOURCE(IDC_ZOOMOUT); + // TODO(avi): get cursor images for grab/grabbing + // http://crbug.com/74699 + case WebCursorInfo::TypeGrab: + case WebCursorInfo::TypeGrabbing: + return IDC_ARROW; } NOTREACHED(); return NULL; diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 3c24dfb..7b93ca7 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -153,6 +153,8 @@ COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_CURSORTYPE_NONE); COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_CURSORTYPE_NOTALLOWED); COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_CURSORTYPE_ZOOMIN); COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_CURSORTYPE_ZOOMOUT); +COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_CURSORTYPE_GRAB); +COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_CURSORTYPE_GRABBING); // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index c6ba2ec..f96abc7 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -321,7 +321,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> { // The plugin 3D interface. const PPP_Graphics3D_Dev* plugin_graphics_3d_interface_; - // Containes the cursor if it's set by the plugin. + // Contains the cursor if it's set by the plugin. scoped_ptr<WebKit::WebCursorInfo> cursor_; // Set to true if this plugin thinks it will always be on top. This allows us |