REGRESSION (r230930): Link drag image is very blurry
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jun 2018 18:20:44 +0000 (18:20 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jun 2018 18:20:44 +0000 (18:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186435
<rdar://problem/40797202>

Reviewed by Tim Horton.

Source/WebCore:

Tell NSImage the proper display scale factor it needs when performing a 'lockFocus' by passing
the correct scaling transform as an NSImageHintCTM.

I reviewed the other drag operations (selection, image, and attachment) and confirmed through
manual testing that these operations already properly scale the images. It appears that links
were the only place where we relied on NSImage to determine and use the relevant device scale
factor.

* SourcesCocoa.txt: Add new WebKitNSImageExtras.mm file.
* WebCore.xcodeproj/project.pbxproj: Update for new files.
* platform/graphics/mac/WebKitNSImageExtras.h: Added.
* platform/graphics/mac/WebKitNSImageExtras.mm: Added.
(-[NSImage _web_lockFocusWithTransform:]): Helper method that takes a device scale factor, creates the
relevant scaling NSAffineTransform and passes it to the internal NSImage 'lockFocusWithRect' as the
NSImageHintCTM hint.
* platform/mac/DragImageMac.mm:
(WebCore::createDragImageForLink): Use the new helper function.

Source/WebCore/PAL:

Add the necessary NSImage SPI to our SPI headers.

* PAL.xcodeproj/project.pbxproj:
* pal/spi/mac/NSImageSPI.h: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232628 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
Source/WebCore/PAL/pal/spi/mac/NSImageSPI.h [new file with mode: 0644]
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/mac/WebKitNSImageExtras.h [new file with mode: 0644]
Source/WebCore/platform/graphics/mac/WebKitNSImageExtras.mm [new file with mode: 0644]
Source/WebCore/platform/mac/DragImageMac.mm

index 797f176..93572df 100644 (file)
@@ -1,3 +1,29 @@
+2018-06-08  Brent Fulgham  <bfulgham@apple.com>
+
+        REGRESSION (r230930): Link drag image is very blurry
+        https://bugs.webkit.org/show_bug.cgi?id=186435
+        <rdar://problem/40797202>
+
+        Reviewed by Tim Horton.
+
+        Tell NSImage the proper display scale factor it needs when performing a 'lockFocus' by passing
+        the correct scaling transform as an NSImageHintCTM.
+
+        I reviewed the other drag operations (selection, image, and attachment) and confirmed through
+        manual testing that these operations already properly scale the images. It appears that links
+        were the only place where we relied on NSImage to determine and use the relevant device scale
+        factor.
+
+        * SourcesCocoa.txt: Add new WebKitNSImageExtras.mm file.
+        * WebCore.xcodeproj/project.pbxproj: Update for new files.
+        * platform/graphics/mac/WebKitNSImageExtras.h: Added.
+        * platform/graphics/mac/WebKitNSImageExtras.mm: Added.
+        (-[NSImage _web_lockFocusWithTransform:]): Helper method that takes a device scale factor, creates the
+        relevant scaling NSAffineTransform and passes it to the internal NSImage 'lockFocusWithRect' as the
+        NSImageHintCTM hint.
+        * platform/mac/DragImageMac.mm:
+        (WebCore::createDragImageForLink): Use the new helper function.
+
 2018-06-08  Zalan Bujtas  <zalan@apple.com>
 
         [LFC] Add vertical margin computation for inline, block-level, inline-block and floating replaced elements
index 316b921..acde976 100644 (file)
@@ -1,3 +1,16 @@
+2018-06-08  Brent Fulgham  <bfulgham@apple.com>
+
+        REGRESSION (r230930): Link drag image is very blurry
+        https://bugs.webkit.org/show_bug.cgi?id=186435
+        <rdar://problem/40797202>
+
+        Reviewed by Tim Horton.
+
+        Add the necessary NSImage SPI to our SPI headers.
+
+        * PAL.xcodeproj/project.pbxproj:
+        * pal/spi/mac/NSImageSPI.h: Added.
+
 2018-06-07  Chris Dumez  <cdumez@apple.com>
 
         Add base class to get WeakPtrFactory member and avoid some boilerplate code
index e43e1b8..59e747a 100644 (file)
                570AB8F920AF6E3D00B8BE87 /* NSXPCConnectionSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 570AB8F820AF6E3D00B8BE87 /* NSXPCConnectionSPI.h */; };
                57F12518205787D7001AB8A6 /* DeviceIdentitySPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 57F12517205787C8001AB8A6 /* DeviceIdentitySPI.h */; };
                7A1656441F97B2B900BA3CE4 /* NSKeyedArchiverSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A1656431F97B2B800BA3CE4 /* NSKeyedArchiverSPI.h */; };
+               7A3A6A8020CADB4700317AAE /* NSImageSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */; };
                A10265871F56746100B4C844 /* FoundationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10265861F56746100B4C844 /* FoundationSPI.h */; };
                A10265891F56747A00B4C844 /* HIToolboxSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10265881F56747A00B4C844 /* HIToolboxSPI.h */; };
                A102658B1F56748C00B4C844 /* QuickDrawSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A102658A1F56748C00B4C844 /* QuickDrawSPI.h */; };
                570AB8F820AF6E3D00B8BE87 /* NSXPCConnectionSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSXPCConnectionSPI.h; sourceTree = "<group>"; };
                57F12517205787C8001AB8A6 /* DeviceIdentitySPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeviceIdentitySPI.h; sourceTree = "<group>"; };
                7A1656431F97B2B800BA3CE4 /* NSKeyedArchiverSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSKeyedArchiverSPI.h; sourceTree = "<group>"; };
+               7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSImageSPI.h; sourceTree = "<group>"; };
                93E5909C1F93BF1E0067F8CF /* UnencodableHandling.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UnencodableHandling.h; sourceTree = "<group>"; };
                A10265861F56746100B4C844 /* FoundationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FoundationSPI.h; sourceTree = "<group>"; };
                A10265881F56747A00B4C844 /* HIToolboxSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HIToolboxSPI.h; sourceTree = "<group>"; };
                                0C7785761F45130F00F4EBB6 /* NSEventSPI.h */,
                                0C7785771F45130F00F4EBB6 /* NSFontSPI.h */,
                                A10826FD1F58A433004772AC /* NSGraphicsSPI.h */,
+                               7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */,
                                0C7785781F45130F00F4EBB6 /* NSImmediateActionGestureRecognizerSPI.h */,
                                0C7785791F45130F00F4EBB6 /* NSMenuSPI.h */,
                                0C77857A1F45130F00F4EBB6 /* NSPasteboardSPI.h */,
                                F442915E1FA52473002CC93E /* NSFileSizeFormatterSPI.h in Headers */,
                                0C7785901F45130F00F4EBB6 /* NSFontSPI.h in Headers */,
                                A10826FE1F58A433004772AC /* NSGraphicsSPI.h in Headers */,
+                               7A3A6A8020CADB4700317AAE /* NSImageSPI.h in Headers */,
                                0C7785911F45130F00F4EBB6 /* NSImmediateActionGestureRecognizerSPI.h in Headers */,
                                7A1656441F97B2B900BA3CE4 /* NSKeyedArchiverSPI.h in Headers */,
                                0C7785921F45130F00F4EBB6 /* NSMenuSPI.h in Headers */,
diff --git a/Source/WebCore/PAL/pal/spi/mac/NSImageSPI.h b/Source/WebCore/PAL/pal/spi/mac/NSImageSPI.h
new file mode 100644 (file)
index 0000000..547c13b
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import <wtf/Platform.h>
+
+#if PLATFORM(MAC)
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AppKit/NSImage_Private.h>
+
+#else
+
+@interface NSImage ()
+- (void)lockFocusWithRect:(NSRect)rect context:(NSGraphicsContext *)context hints:(NSDictionary *)hints flipped:(BOOL)flipped;
+@end
+
+#endif
+
+#endif
index d1d831d..97fc9ee 100644 (file)
@@ -357,6 +357,7 @@ platform/graphics/mac/IntSizeMac.mm
 platform/graphics/mac/PDFDocumentImageMac.mm
 platform/graphics/mac/SimpleFontDataCoreText.cpp
 platform/graphics/mac/WebLayer.mm
+platform/graphics/mac/WebKitNSImageExtras.mm
 
 platform/graphics/opengl/Extensions3DOpenGL.cpp
 platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
index 1673aa9..5f747df 100644 (file)
                7A0E770F10C00A8800A0276E /* InspectorFrontendHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A0E770C10C00A8800A0276E /* InspectorFrontendHost.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A0E771D10C00DB100A0276E /* JSInspectorFrontendHost.h */; };
                7A1D7FCB18F85F0F00C385AD /* mediaControlsLocalizedStrings.js in Resources */ = {isa = PBXBuildFile; fileRef = 7A1D7FC918F85F0F00C385AD /* mediaControlsLocalizedStrings.js */; };
+               7A22732020C9F9DA00DB1DEF /* WebKitNSImageExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7A22731E20C9F9D900DB1DEF /* WebKitNSImageExtras.mm */; };
+               7A22732120C9FAFE00DB1DEF /* WebKitNSImageExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A22731F20C9F9DA00DB1DEF /* WebKitNSImageExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7A29F57218C69514004D0F81 /* OutOfBandTextTrackPrivateAVF.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A29F57118C69514004D0F81 /* OutOfBandTextTrackPrivateAVF.h */; };
                7A45032F18DB717200377B34 /* BufferedLineReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A45032D18DB717200377B34 /* BufferedLineReader.cpp */; };
                7A45033018DB717200377B34 /* BufferedLineReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A45032E18DB717200377B34 /* BufferedLineReader.h */; };
                7A0E771D10C00DB100A0276E /* JSInspectorFrontendHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInspectorFrontendHost.h; sourceTree = "<group>"; };
                7A1D7FCA18F85F0F00C385AD /* English */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = English; path = English.lproj/mediaControlsLocalizedStrings.js; sourceTree = SOURCE_ROOT; };
                7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorClient.cpp; sourceTree = "<group>"; };
+               7A22731E20C9F9D900DB1DEF /* WebKitNSImageExtras.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitNSImageExtras.mm; sourceTree = "<group>"; };
+               7A22731F20C9F9DA00DB1DEF /* WebKitNSImageExtras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebKitNSImageExtras.h; sourceTree = "<group>"; };
                7A29BA67187B732200F29CEB /* TemporaryOpenGLSetting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporaryOpenGLSetting.h; sourceTree = "<group>"; };
                7A29BA69187B781C00F29CEB /* TemporaryOpenGLSetting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporaryOpenGLSetting.cpp; sourceTree = "<group>"; };
                7A29F57118C69514004D0F81 /* OutOfBandTextTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OutOfBandTextTrackPrivateAVF.h; sourceTree = "<group>"; };
                                B27535510B053814002CE64F /* IntSizeMac.mm */,
                                2D6E468217D660F500ECF8BB /* PDFDocumentImageMac.mm */,
                                163E88F5118A39D200ED9231 /* SimpleFontDataCoreText.cpp */,
+                               7A22731F20C9F9DA00DB1DEF /* WebKitNSImageExtras.h */,
+                               7A22731E20C9F9D900DB1DEF /* WebKitNSImageExtras.mm */,
                                0FCF332B0F2B9A25004B6795 /* WebLayer.h */,
                                0FCF332A0F2B9A25004B6795 /* WebLayer.mm */,
                        );
                                2D06214E1DA63A8E00A7FB26 /* WebKitMediaKeys.h in Headers */,
                                2D0621501DA63A9400A7FB26 /* WebKitMediaKeySession.h in Headers */,
                                7C48A6D1191C9D6500026674 /* WebKitNamespace.h in Headers */,
+                               7A22732120C9FAFE00DB1DEF /* WebKitNSImageExtras.h in Headers */,
                                A5DEBDA416FB908700836FE0 /* WebKitPlaybackTargetAvailabilityEvent.h in Headers */,
                                494BD7950F55C8EE00747828 /* WebKitPoint.h in Headers */,
                                31C0FF250E4CEB6E007D6FE5 /* WebKitTransitionEvent.h in Headers */,
                                2D06214D1DA63A8B00A7FB26 /* WebKitMediaKeys.cpp in Sources */,
                                2D06214F1DA63A9100A7FB26 /* WebKitMediaKeySession.cpp in Sources */,
                                7C48A6D0191C9D6500026674 /* WebKitNamespace.cpp in Sources */,
+                               7A22732020C9F9DA00DB1DEF /* WebKitNSImageExtras.mm in Sources */,
                                0709D7921AE5557E004E42F8 /* WebMediaSessionManagerMac.cpp in Sources */,
                                1CAF34820A6C405200ABE06E /* WebScriptObject.mm in Sources */,
                                F12171F516A8CED2000053CA /* WebVTTElement.cpp in Sources */,
diff --git a/Source/WebCore/platform/graphics/mac/WebKitNSImageExtras.h b/Source/WebCore/platform/graphics/mac/WebKitNSImageExtras.h
new file mode 100644 (file)
index 0000000..2693fd9
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if !PLATFORM(IOS)
+
+#import <Cocoa/Cocoa.h>
+
+@interface NSImage (WebKitExtras)
+
+- (void)_web_lockFocusWithDeviceScaleFactor:(CGFloat)deviceScaleFactor;
+
+@end
+
+#endif
diff --git a/Source/WebCore/platform/graphics/mac/WebKitNSImageExtras.mm b/Source/WebCore/platform/graphics/mac/WebKitNSImageExtras.mm
new file mode 100644 (file)
index 0000000..4664f66
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if !PLATFORM(IOS)
+#import "config.h"
+#import "WebKitNSImageExtras.h"
+
+#import <pal/spi/mac/NSImageSPI.h>
+
+@implementation NSImage (WebKitExtras)
+
+- (void)_web_lockFocusWithDeviceScaleFactor:(CGFloat)deviceScaleFactor
+{
+    NSAffineTransform *transform = [NSAffineTransform transform];
+    [transform scaleBy:deviceScaleFactor];
+
+    NSRect bounds = { NSZeroPoint, self.size };
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+    BOOL flippedOrientation = self.isFlipped;
+#pragma clang diagnostic pop
+    [self lockFocusWithRect:bounds context:nil hints:@{ NSImageHintCTM : transform } flipped:flippedOrientation];
+}
+
+@end
+
+#endif // !PLATFORM(IOS)
index 4aaadac..386ed61 100644 (file)
@@ -39,6 +39,7 @@
 #import "StringTruncator.h"
 #import "TextIndicator.h"
 #import "URL.h"
+#import "WebKitNSImageExtras.h"
 #import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/cocoa/CoreTextSPI.h>
 #import <pal/spi/cocoa/URLFormattingSPI.h>
@@ -293,7 +294,7 @@ LinkImageLayout::LinkImageLayout(URL& url, const String& titleString)
     boundingRect.setHeight((static_cast<int>(boundingRect.height() / 2) * 2));
 }
 
-DragImageRef createDragImageForLink(Element&, URL& url, const String& title, TextIndicatorData&, FontRenderingMode, float)
+DragImageRef createDragImageForLink(Element&, URL& url, const String& title, TextIndicatorData&, FontRenderingMode, float deviceScaleFactor)
 {
     LinkImageLayout layout(url, title);
 
@@ -302,7 +303,7 @@ DragImageRef createDragImageForLink(Element&, URL& url, const String& title, Tex
     imageSize.expand(2 * linkImageShadowRadius, 2 * linkImageShadowRadius - linkImageShadowOffsetY);
 #endif
     RetainPtr<NSImage> dragImage = adoptNS([[NSImage alloc] initWithSize:imageSize]);
-    [dragImage lockFocus];
+    [dragImage _web_lockFocusWithDeviceScaleFactor:deviceScaleFactor];
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"