diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-25 03:44:14 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-25 03:44:14 +0000 |
commit | a4e1bf741f2ef9712854f5b5a165545a846dd835 (patch) | |
tree | 398b35b4e57a0ac6cfc6b9abb15446631272b5a5 /webkit | |
parent | d9986776db9f373511615e73ae3411ad9b74b925 (diff) | |
download | chromium_src-a4e1bf741f2ef9712854f5b5a165545a846dd835.zip chromium_src-a4e1bf741f2ef9712854f5b5a165545a846dd835.tar.gz chromium_src-a4e1bf741f2ef9712854f5b5a165545a846dd835.tar.bz2 |
mac: Load cursor images from resource pak file instead of from the bundle.
Depends on https://bugs.webkit.org/show_bug.cgi?id=92148
Also, while I'm here, don't include the webkit .cur files on
platforms other than windows.
BUG=137588
TEST=Cursors show up fine in component builds.
Review URL: https://chromiumcodereview.appspot.com/10817031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148290 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/webcursor_mac.mm | 69 | ||||
-rw-r--r-- | webkit/glue/webkit_resources.grd | 39 |
2 files changed, 55 insertions, 53 deletions
diff --git a/webkit/glue/webcursor_mac.mm b/webkit/glue/webcursor_mac.mm index ab1958a..b69b8f7 100644 --- a/webkit/glue/webcursor_mac.mm +++ b/webkit/glue/webcursor_mac.mm @@ -11,11 +11,12 @@ #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" #include "base/memory/scoped_nsobject.h" +#include "grit/webkit_chromium_resources.h" #include "skia/ext/skia_utils_mac.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" -#include "ui/gfx/mac/nsimage_cache.h" +#include "ui/base/resource/resource_bundle.h" using WebKit::WebCursorInfo; using WebKit::WebImage; @@ -114,13 +115,9 @@ typedef long long CrCoreCursorType; namespace { -// Loads a cursor from the image cache. -NSCursor* LoadCursor(const char* name, int hotspot_x, int hotspot_y) { - NSString* file_name = [NSString stringWithUTF8String:name]; - DCHECK(file_name); - // TODO: This image fetch can (and probably should) be serviced by the - // resource resource bundle instead of going through the image cache. - NSImage* cursor_image = gfx::GetCachedImageWithName(file_name); +NSCursor* LoadCursor(int resource_id, int hotspot_x, int hotspot_y) { + NSImage* cursor_image = + ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); DCHECK(cursor_image); return [[[NSCursor alloc] initWithImage:cursor_image hotSpot:NSMakePoint(hotspot_x, @@ -130,7 +127,7 @@ NSCursor* LoadCursor(const char* name, int hotspot_x, int hotspot_y) { // Gets a specified cursor from CoreCursor, falling back to loading it from the // image cache if CoreCursor cannot provide it. NSCursor* GetCoreCursorWithFallback(CrCoreCursorType type, - const char* name, + int resource_id, int hotspot_x, int hotspot_y) { if (base::mac::IsOSLionOrLater()) { @@ -139,7 +136,7 @@ NSCursor* GetCoreCursorWithFallback(CrCoreCursorType type, return cursor; } - return LoadCursor(name, hotspot_x, hotspot_y); + return LoadCursor(resource_id, hotspot_x, hotspot_y); } // TODO(avi): When Skia becomes default, fold this function into the remaining @@ -227,59 +224,61 @@ gfx::NativeCursor WebCursor::GetNativeCursor() { if (base::mac::IsOSLionOrLater()) return [NSCursor pointingHandCursor]; else - return LoadCursor("linkCursor", 6, 1); + return LoadCursor(IDR_LINK_CURSOR, 6, 1); case WebCursorInfo::TypeIBeam: return [NSCursor IBeamCursor]; case WebCursorInfo::TypeWait: return GetCoreCursorWithFallback(kBusyButClickableCursor, - "waitCursor", 7, 7); + IDR_WAIT_CURSOR, 7, 7); case WebCursorInfo::TypeHelp: return GetCoreCursorWithFallback(kHelpCursor, - "helpCursor", 8, 8); + IDR_HELP_CURSOR, 8, 8); case WebCursorInfo::TypeEastResize: case WebCursorInfo::TypeEastPanning: return GetCoreCursorWithFallback(kResizeEastCursor, - "eastResizeCursor", 14, 7); + IDR_EAST_RESIZE_CURSOR, 14, 7); case WebCursorInfo::TypeNorthResize: case WebCursorInfo::TypeNorthPanning: return GetCoreCursorWithFallback(kResizeNorthCursor, - "northResizeCursor", 7, 1); + IDR_NORTH_RESIZE_CURSOR, 7, 1); case WebCursorInfo::TypeNorthEastResize: case WebCursorInfo::TypeNorthEastPanning: return GetCoreCursorWithFallback(kResizeNortheastCursor, - "northEastResizeCursor", 14, 1); + IDR_NORTHEAST_RESIZE_CURSOR, 14, 1); case WebCursorInfo::TypeNorthWestResize: case WebCursorInfo::TypeNorthWestPanning: return GetCoreCursorWithFallback(kResizeNorthwestCursor, - "northWestResizeCursor", 0, 0); + IDR_NORTHWEST_RESIZE_CURSOR, 0, 0); case WebCursorInfo::TypeSouthResize: case WebCursorInfo::TypeSouthPanning: return GetCoreCursorWithFallback(kResizeSouthCursor, - "southResizeCursor", 7, 14); + IDR_SOUTH_RESIZE_CURSOR, 7, 14); case WebCursorInfo::TypeSouthEastResize: case WebCursorInfo::TypeSouthEastPanning: return GetCoreCursorWithFallback(kResizeSoutheastCursor, - "southEastResizeCursor", 14, 14); + IDR_SOUTHEAST_RESIZE_CURSOR, 14, 14); case WebCursorInfo::TypeSouthWestResize: case WebCursorInfo::TypeSouthWestPanning: return GetCoreCursorWithFallback(kResizeSouthwestCursor, - "southWestResizeCursor", 1, 14); + IDR_SOUTHWEST_RESIZE_CURSOR, 1, 14); case WebCursorInfo::TypeWestResize: case WebCursorInfo::TypeWestPanning: return GetCoreCursorWithFallback(kResizeWestCursor, - "westResizeCursor", 1, 7); + IDR_WEST_RESIZE_CURSOR, 1, 7); case WebCursorInfo::TypeNorthSouthResize: return GetCoreCursorWithFallback(kResizeNorthSouthCursor, - "northSouthResizeCursor", 7, 7); + IDR_NORTHSOUTH_RESIZE_CURSOR, 7, 7); case WebCursorInfo::TypeEastWestResize: return GetCoreCursorWithFallback(kResizeEastWestCursor, - "eastWestResizeCursor", 7, 7); + IDR_EASTWEST_RESIZE_CURSOR, 7, 7); case WebCursorInfo::TypeNorthEastSouthWestResize: return GetCoreCursorWithFallback(kResizeNortheastSouthwestCursor, - "northEastSouthWestResizeCursor", 7, 7); + IDR_NORTHEASTSOUTHWEST_RESIZE_CURSOR, + 7, 7); case WebCursorInfo::TypeNorthWestSouthEastResize: return GetCoreCursorWithFallback(kResizeNorthwestSoutheastCursor, - "northWestSouthEastResizeCursor", 7, 7); + IDR_NORTHWESTSOUTHEAST_RESIZE_CURSOR, + 7, 7); case WebCursorInfo::TypeColumnResize: return [NSCursor resizeLeftRightCursor]; case WebCursorInfo::TypeRowResize: @@ -287,28 +286,28 @@ gfx::NativeCursor WebCursor::GetNativeCursor() { case WebCursorInfo::TypeMiddlePanning: case WebCursorInfo::TypeMove: return GetCoreCursorWithFallback(kMoveCursor, - "moveCursor", 7, 7); + IDR_MOVE_CURSOR, 7, 7); case WebCursorInfo::TypeVerticalText: // IBeamCursorForVerticalLayout is >= 10.7. if ([NSCursor respondsToSelector:@selector(IBeamCursorForVerticalLayout)]) return [NSCursor IBeamCursorForVerticalLayout]; else - return LoadCursor("verticalTextCursor", 7, 7); + return LoadCursor(IDR_VERTICALTEXT_CURSOR, 7, 7); case WebCursorInfo::TypeCell: return GetCoreCursorWithFallback(kCellCursor, - "cellCursor", 7, 7); + IDR_CELL_CURSOR, 7, 7); case WebCursorInfo::TypeContextMenu: // contextualMenuCursor is >= 10.6. if ([NSCursor respondsToSelector:@selector(contextualMenuCursor)]) return [NSCursor contextualMenuCursor]; else - return LoadCursor("contextMenuCursor", 3, 2); + return LoadCursor(IDR_CONTEXTMENU_CURSOR, 3, 2); case WebCursorInfo::TypeAlias: return GetCoreCursorWithFallback(kMakeAliasCursor, - "aliasCursor", 11, 3); + IDR_ALIAS_CURSOR, 11, 3); case WebCursorInfo::TypeProgress: return GetCoreCursorWithFallback(kBusyButClickableCursor, - "progressCursor", 3, 2); + IDR_PROGRESS_CURSOR, 3, 2); case WebCursorInfo::TypeNoDrop: case WebCursorInfo::TypeNotAllowed: // Docs say that operationNotAllowedCursor is >= 10.6, and it's not in the @@ -319,15 +318,15 @@ gfx::NativeCursor WebCursor::GetNativeCursor() { if ([NSCursor respondsToSelector:@selector(dragCopyCursor)]) return [NSCursor dragCopyCursor]; else - return LoadCursor("copyCursor", 3, 2); + return LoadCursor(IDR_COPY_CURSOR, 3, 2); case WebCursorInfo::TypeNone: - return LoadCursor("noneCursor", 7, 7); + return LoadCursor(IDR_NONE_CURSOR, 7, 7); case WebCursorInfo::TypeZoomIn: return GetCoreCursorWithFallback(kZoomInCursor, - "zoomInCursor", 7, 7); + IDR_ZOOMIN_CURSOR, 7, 7); case WebCursorInfo::TypeZoomOut: return GetCoreCursorWithFallback(kZoomOutCursor, - "zoomOutCursor", 7, 7); + IDR_ZOOMOUT_CURSOR, 7, 7); case WebCursorInfo::TypeGrab: return [NSCursor openHandCursor]; case WebCursorInfo::TypeGrabbing: diff --git a/webkit/glue/webkit_resources.grd b/webkit/glue/webkit_resources.grd index 8acb500..870bef9 100644 --- a/webkit/glue/webkit_resources.grd +++ b/webkit/glue/webkit_resources.grd @@ -9,12 +9,7 @@ </outputs> <release seq="1"> <includes> - <include name="IDC_ALIAS" file="resources\aliasb.cur" type="CURSOR" /> <include name="IDR_BROKENIMAGE" file="resources\broken-image.gif" type="BINDATA" /> - <include name="IDC_CELL" file="resources\cell.cur" type="CURSOR" /> - <include name="IDC_COLRESIZE" file="resources\col_resize.cur" type="CURSOR" /> - <include name="IDC_COPYCUR" file="resources\copy.cur" type="CURSOR" /> - <include name="IDC_CURSOR_NONE" file="resources\none.cur" type="CURSOR" /> <include name="IDR_INPUT_SPEECH" file="resources\input_speech.png" type="BINDATA" /> <include name="IDR_INPUT_SPEECH_RECORDING" file="resources\input_speech_recording.png" type="BINDATA" /> <include name="IDR_INPUT_SPEECH_WAITING" file="resources\input_speech_waiting.png" type="BINDATA" /> @@ -60,25 +55,33 @@ <if expr="is_macosx"> <include name="IDR_OVERHANG_PATTERN" file="resources\overhang_pattern.png" type="BINDATA" /> </if> - <include name="IDC_PAN_EAST" file="resources\pan_east.cur" type="CURSOR" /> - <include name="IDC_PAN_MIDDLE" file="resources\pan_middle.cur" type="CURSOR" /> - <include name="IDC_PAN_NORTH" file="resources\pan_north.cur" type="CURSOR" /> - <include name="IDC_PAN_NORTH_EAST" file="resources\pan_north_east.cur" type="CURSOR" /> - <include name="IDC_PAN_NORTH_WEST" file="resources\pan_north_west.cur" type="CURSOR" /> + <if expr="is_win"> + <include name="IDC_ALIAS" file="resources\aliasb.cur" type="CURSOR" /> + <include name="IDC_CELL" file="resources\cell.cur" type="CURSOR" /> + <include name="IDC_COLRESIZE" file="resources\col_resize.cur" type="CURSOR" /> + <include name="IDC_COPYCUR" file="resources\copy.cur" type="CURSOR" /> + <include name="IDC_CURSOR_NONE" file="resources\none.cur" type="CURSOR" /> + <include name="IDC_PAN_EAST" file="resources\pan_east.cur" type="CURSOR" /> + <include name="IDC_PAN_MIDDLE" file="resources\pan_middle.cur" type="CURSOR" /> + <include name="IDC_PAN_NORTH" file="resources\pan_north.cur" type="CURSOR" /> + <include name="IDC_PAN_NORTH_EAST" file="resources\pan_north_east.cur" type="CURSOR" /> + <include name="IDC_PAN_NORTH_WEST" file="resources\pan_north_west.cur" type="CURSOR" /> + <include name="IDC_PAN_SOUTH" file="resources\pan_south.cur" type="CURSOR" /> + <include name="IDC_PAN_SOUTH_EAST" file="resources\pan_south_east.cur" type="CURSOR" /> + <include name="IDC_PAN_SOUTH_WEST" file="resources\pan_south_west.cur" type="CURSOR" /> + <include name="IDC_PAN_WEST" file="resources\pan_west.cur" type="CURSOR" /> + <include name="IDC_ROWRESIZE" file="resources\row_resize.cur" type="CURSOR" /> + <include name="IDC_VERTICALTEXT" file="resources\vertical_text.cur" type="CURSOR" /> + <include name="IDC_ZOOMIN" file="resources\zoom_in.cur" type="CURSOR" /> + <include name="IDC_ZOOMOUT" file="resources\zoom_out.cur" type="CURSOR" /> + </if> + <include name="IDR_PAN_SCROLL_ICON" file="resources\pan_icon.png" type="BINDATA" /> - <include name="IDC_PAN_SOUTH" file="resources\pan_south.cur" type="CURSOR" /> - <include name="IDC_PAN_SOUTH_EAST" file="resources\pan_south_east.cur" type="CURSOR" /> - <include name="IDC_PAN_SOUTH_WEST" file="resources\pan_south_west.cur" type="CURSOR" /> - <include name="IDC_PAN_WEST" file="resources\pan_west.cur" type="CURSOR" /> - <include name="IDC_ROWRESIZE" file="resources\row_resize.cur" type="CURSOR" /> <include name="IDR_SEARCH_CANCEL" file="resources\search_cancel.png" type="BINDATA" /> <include name="IDR_SEARCH_CANCEL_PRESSED" file="resources\search_cancel_pressed.png" type="BINDATA" /> <include name="IDR_SEARCH_MAGNIFIER" file="resources\search_magnifier.png" type="BINDATA" /> <include name="IDR_SEARCH_MAGNIFIER_RESULTS" file="resources\search_magnifier_results.png" type="BINDATA" /> <include name="IDR_TEXTAREA_RESIZER" file="resources\textarea_resize_corner.png" type="BINDATA" /> - <include name="IDC_VERTICALTEXT" file="resources\vertical_text.cur" type="CURSOR" /> - <include name="IDC_ZOOMIN" file="resources\zoom_in.cur" type="CURSOR" /> - <include name="IDC_ZOOMOUT" file="resources\zoom_out.cur" type="CURSOR" /> <include name="IDR_AUTOFILL_CC_AMEX" file="resources\amex.png" type="BINDATA" /> <include name="IDR_AUTOFILL_CC_DINERS" file="resources\diners.png" type="BINDATA" /> <include name="IDR_AUTOFILL_CC_DISCOVER" file="resources\discover.png" type="BINDATA" /> |