Changeset 182869 in webkit
- Timestamp:
- Apr 15, 2015 4:21:42 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r182865 r182869 1 2015-04-15 Timothy Horton <timothy_horton@apple.com> 2 3 Custom CSS cursors do not use -webkit-image-set on retina displays 4 https://bugs.webkit.org/show_bug.cgi?id=120783 5 6 Reviewed by Beth Dakin. 7 Patch by Evan Wallace <evan.exe@gmail.com>. 8 9 Add a manual test for custom CSS cursors on retina displays. 10 11 * ManualTests/retina-cursors.html: Added. 12 1 13 2015-04-15 Alex Christensen <achristensen@webkit.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r182866 r182869 1 2015-04-15 Timothy Horton <timothy_horton@apple.com> 2 3 Custom CSS cursors do not use -webkit-image-set on retina displays 4 https://bugs.webkit.org/show_bug.cgi?id=120783 5 <rdar://problem/14921432> 6 7 Reviewed by Beth Dakin. 8 Patch by Evan Wallace <evan.exe@gmail.com>. 9 10 Scale NSCursor images correctly so custom CSS cursors work with 11 -webkit-image-set on retina displays. 12 13 * WebCore.exp.in: 14 * page/EventHandler.cpp: 15 (WebCore::EventHandler::selectCursor): 16 * platform/mac/CursorMac.mm: 17 (WebCore::createCustomCursor): 18 (WebCore::Cursor::ensurePlatformCursor): 19 1 20 2015-04-15 Alexey Proskuryakov <ap@apple.com> 2 21 -
trunk/Source/WebCore/page/EventHandler.cpp
r182748 r182869 1414 1414 // Get hotspot and convert from logical pixels to physical pixels. 1415 1415 IntPoint hotSpot = (*cursors)[i].hotSpot(); 1416 hotSpot.scale(scale, scale);1417 1416 FloatSize size = cachedImage->imageForRenderer(renderer)->size(); 1418 1417 if (cachedImage->errorOccurred()) -
trunk/Source/WebCore/platform/Cursor.h
r179057 r182869 147 147 #if ENABLE(MOUSE_CURSOR_SCALE) 148 148 // Hot spot is in image pixels. 149 Cursor(Image*, const IntPoint& hotSpot, float imageScaleFactor);149 WEBCORE_EXPORT Cursor(Image*, const IntPoint& hotSpot, float imageScaleFactor); 150 150 #endif 151 151 -
trunk/Source/WebCore/platform/mac/CursorMac.mm
r175941 r182869 42 42 // but creating a cursor with a bad image might throw. 43 43 44 #if ENABLE(MOUSE_CURSOR_SCALE) 45 static RetainPtr<NSCursor> createCustomCursor(Image* image, const IntPoint& hotSpot, float scale) 46 #else 44 47 static RetainPtr<NSCursor> createCustomCursor(Image* image, const IntPoint& hotSpot) 48 #endif 45 49 { 46 50 // FIXME: The cursor won't animate. Not sure if that's a big deal. … … 49 53 return 0; 50 54 BEGIN_BLOCK_OBJC_EXCEPTIONS; 55 56 #if ENABLE(MOUSE_CURSOR_SCALE) 57 NSSize size = NSMakeSize(image->width() / scale, image->height() / scale); 58 NSSize expandedSize = NSMakeSize(ceil(size.width), ceil(size.height)); 59 60 // Pad the image with transparent pixels so it has an integer boundary. 61 if (size.width != expandedSize.width || size.height != expandedSize.height) { 62 RetainPtr<NSImage> expandedImage = adoptNS([[NSImage alloc] initWithSize:expandedSize]); 63 NSRect toRect = NSMakeRect(0, expandedSize.height - size.height, size.width, size.height); 64 NSRect fromRect = NSMakeRect(0, 0, image->width(), image->height()); 65 66 [expandedImage lockFocus]; 67 [nsImage drawInRect:toRect fromRect:fromRect operation:NSCompositeSourceOver fraction:1]; 68 [expandedImage unlockFocus]; 69 70 return adoptNS([[NSCursor alloc] initWithImage:expandedImage.get() hotSpot:hotSpot]); 71 } 72 73 // Scale the image and its representation to match retina resolution. 74 [nsImage setSize:expandedSize]; 75 [[[nsImage representations] objectAtIndex:0] setSize:expandedSize]; 76 #endif 77 51 78 return adoptNS([[NSCursor alloc] initWithImage:nsImage hotSpot:hotSpot]); 52 79 END_BLOCK_OBJC_EXCEPTIONS; 53 return 0;80 return nullptr; 54 81 } 55 82 … … 206 233 207 234 case Cursor::Custom: 235 #if ENABLE(MOUSE_CURSOR_SCALE) 236 m_platformCursor = createCustomCursor(m_image.get(), m_hotSpot, m_imageScaleFactor); 237 #else 208 238 m_platformCursor = createCustomCursor(m_image.get(), m_hotSpot); 239 #endif 209 240 break; 210 241 } -
trunk/Source/WebKit2/ChangeLog
r182865 r182869 1 2015-04-15 Timothy Horton <timothy_horton@apple.com> 2 3 Custom CSS cursors do not use -webkit-image-set on retina displays 4 https://bugs.webkit.org/show_bug.cgi?id=120783 5 6 Reviewed by Beth Dakin. 7 Patch by Evan Wallace <evan.exe@gmail.com>. 8 9 Serialize the cursor image scale for SetCursor messages so custom 10 CSS cursors work with -webkit-image-set on retina displays. 11 12 * Shared/WebCoreArgumentCoders.cpp: 13 (CoreIPC::ArgumentCoder<Cursor>::encode): 14 (CoreIPC::ArgumentCoder<Cursor>::decode): 15 1 16 2015-04-15 Alex Christensen <achristensen@webkit.org> 2 17 -
trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
r182764 r182869 767 767 encodeImage(encoder, cursor.image()); 768 768 encoder << cursor.hotSpot(); 769 #if ENABLE(MOUSE_CURSOR_SCALE) 770 encoder << cursor.imageScaleFactor(); 771 #endif 769 772 } 770 773 … … 808 811 return false; 809 812 813 #if ENABLE(MOUSE_CURSOR_SCALE) 814 float scale; 815 if (!decoder.decode(scale)) 816 return false; 817 818 cursor = Cursor(image.get(), hotSpot, scale); 819 #else 810 820 cursor = Cursor(image.get(), hotSpot); 821 #endif 811 822 return true; 812 823 }
Note: See TracChangeset
for help on using the changeset viewer.