Title: [258966] trunk/Source/WebCore
Revision
258966
Author
[email protected]
Date
2020-03-24 18:22:03 -0700 (Tue, 24 Mar 2020)

Log Message

Rename DragDataMac and DragImageMac to DragDataCocoa and DragImageCocoa
https://bugs.webkit.org/show_bug.cgi?id=209523

Reviewed by Megan Gardner.

Rename DragDataMac to DragDataCocoa, and DragImageMac to DragImageCocoa. These files contain logic relevant to
both macOS and iOS, and as such, belong in platform/cocoa rather than platform/mac.

No change in behavior.

* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/cocoa/DragDataCocoa.mm: Renamed from Source/WebCore/platform/mac/DragDataMac.mm.
(WebCore::rtfPasteboardType):
(WebCore::rtfdPasteboardType):
(WebCore::stringPasteboardType):
(WebCore::urlPasteboardType):
(WebCore::htmlPasteboardType):
(WebCore::colorPasteboardType):
(WebCore::pdfPasteboardType):
(WebCore::tiffPasteboardType):
(WebCore::DragData::DragData):
(WebCore::DragData::containsURLTypeIdentifier const):
(WebCore::DragData::canSmartReplace const):
(WebCore::DragData::containsColor const):
(WebCore::DragData::containsFiles const):
(WebCore::DragData::numberOfFiles const):
(WebCore::DragData::asFilenames const):
(WebCore::DragData::containsPlainText const):
(WebCore::DragData::asPlainText const):
(WebCore::DragData::asColor const):
(WebCore::DragData::containsCompatibleContent const):
(WebCore::DragData::containsPromise const):
(WebCore::DragData::containsURL const):
(WebCore::DragData::asURL const):
* platform/cocoa/DragImageCocoa.mm: Renamed from Source/WebCore/platform/mac/DragImageMac.mm.
(WebCore::dragImageSize):
(WebCore::deleteDragImage):
(WebCore::scaleDragImage):
(WebCore::dissolveDragImageToFraction):
(WebCore::createDragImageFromImage):
(WebCore::createDragImageIconForCachedImageFilename):
(WebCore::dragOffsetForLinkDragImage):
(WebCore::anchorPointForLinkDragImage):
(WebCore::LinkImageLayout::LinkImageLayout):
(WebCore::createDragImageForLink):
(WebCore::createDragImageForColor):
* platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm:

Unrelated build fix due to changing unified sources.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (258965 => 258966)


--- trunk/Source/WebCore/ChangeLog	2020-03-25 00:51:44 UTC (rev 258965)
+++ trunk/Source/WebCore/ChangeLog	2020-03-25 01:22:03 UTC (rev 258966)
@@ -1,3 +1,56 @@
+2020-03-24  Wenson Hsieh  <[email protected]>
+
+        Rename DragDataMac and DragImageMac to DragDataCocoa and DragImageCocoa
+        https://bugs.webkit.org/show_bug.cgi?id=209523
+
+        Reviewed by Megan Gardner.
+
+        Rename DragDataMac to DragDataCocoa, and DragImageMac to DragImageCocoa. These files contain logic relevant to
+        both macOS and iOS, and as such, belong in platform/cocoa rather than platform/mac.
+
+        No change in behavior.
+
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/cocoa/DragDataCocoa.mm: Renamed from Source/WebCore/platform/mac/DragDataMac.mm.
+        (WebCore::rtfPasteboardType):
+        (WebCore::rtfdPasteboardType):
+        (WebCore::stringPasteboardType):
+        (WebCore::urlPasteboardType):
+        (WebCore::htmlPasteboardType):
+        (WebCore::colorPasteboardType):
+        (WebCore::pdfPasteboardType):
+        (WebCore::tiffPasteboardType):
+        (WebCore::DragData::DragData):
+        (WebCore::DragData::containsURLTypeIdentifier const):
+        (WebCore::DragData::canSmartReplace const):
+        (WebCore::DragData::containsColor const):
+        (WebCore::DragData::containsFiles const):
+        (WebCore::DragData::numberOfFiles const):
+        (WebCore::DragData::asFilenames const):
+        (WebCore::DragData::containsPlainText const):
+        (WebCore::DragData::asPlainText const):
+        (WebCore::DragData::asColor const):
+        (WebCore::DragData::containsCompatibleContent const):
+        (WebCore::DragData::containsPromise const):
+        (WebCore::DragData::containsURL const):
+        (WebCore::DragData::asURL const):
+        * platform/cocoa/DragImageCocoa.mm: Renamed from Source/WebCore/platform/mac/DragImageMac.mm.
+        (WebCore::dragImageSize):
+        (WebCore::deleteDragImage):
+        (WebCore::scaleDragImage):
+        (WebCore::dissolveDragImageToFraction):
+        (WebCore::createDragImageFromImage):
+        (WebCore::createDragImageIconForCachedImageFilename):
+        (WebCore::dragOffsetForLinkDragImage):
+        (WebCore::anchorPointForLinkDragImage):
+        (WebCore::LinkImageLayout::LinkImageLayout):
+        (WebCore::createDragImageForLink):
+        (WebCore::createDragImageForColor):
+        * platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm:
+
+        Unrelated build fix due to changing unified sources.
+
 2020-03-24  Jer Noble  <[email protected]>
 
         REGRESSION(r258314): Leak in MediaPlayerPrivateMediaSourceAVFObjC::updateLastPixelBuffer()

Modified: trunk/Source/WebCore/SourcesCocoa.txt (258965 => 258966)


--- trunk/Source/WebCore/SourcesCocoa.txt	2020-03-25 00:51:44 UTC (rev 258965)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2020-03-25 01:22:03 UTC (rev 258966)
@@ -195,6 +195,8 @@
 platform/cocoa/ContentFilterUnblockHandlerCocoa.mm @no-unify
 platform/cocoa/CoreVideoSoftLink.cpp
 platform/cocoa/DataDetectorsCoreSoftLink.mm @no-unify
+platform/cocoa/DragDataCocoa.mm
+platform/cocoa/DragImageCocoa.mm
 platform/cocoa/FileMonitorCocoa.mm
 platform/cocoa/KeyEventCocoa.mm
 platform/cocoa/LocalizedStringsCocoa.mm
@@ -444,8 +446,6 @@
 
 platform/mac/BlacklistUpdater.mm
 platform/mac/CursorMac.mm @no-unify
-platform/mac/DragDataMac.mm
-platform/mac/DragImageMac.mm
 platform/mac/KeyEventMac.mm @no-unify
 platform/mac/PlaybackSessionInterfaceMac.mm @no-unify
 platform/mac/LocalCurrentGraphicsContext.mm

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (258965 => 258966)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-03-25 00:51:44 UTC (rev 258965)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-03-25 01:22:03 UTC (rev 258966)
@@ -11885,7 +11885,6 @@
 		A784941A0B5FE507001E237A /* DataTransfer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DataTransfer.cpp; sourceTree = "<group>"; };
 		A78FE13912366B1000ACE8D0 /* SpellChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpellChecker.cpp; sourceTree = "<group>"; };
 		A78FE13A12366B1000ACE8D0 /* SpellChecker.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = SpellChecker.h; sourceTree = "<group>"; };
-		A795463D0B5C4C80007B438F /* DragDataMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DragDataMac.mm; sourceTree = "<group>"; };
 		A79546420B5C4CB4007B438F /* DragData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DragData.cpp; sourceTree = "<group>"; };
 		A79BAD9D161E7F3F00C2E652 /* RuleFeature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleFeature.cpp; sourceTree = "<group>"; };
 		A79BAD9E161E7F3F00C2E652 /* RuleFeature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleFeature.h; sourceTree = "<group>"; };
@@ -11911,7 +11910,6 @@
 		A7CA59620B27C1F200FA021D /* DragClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragClient.h; sourceTree = "<group>"; };
 		A7CFB3CF0B7ED10A0070C32D /* DragImage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DragImage.cpp; sourceTree = "<group>"; };
 		A7CFB3D00B7ED10A0070C32D /* DragImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DragImage.h; sourceTree = "<group>"; };
-		A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DragImageMac.mm; sourceTree = "<group>"; };
 		A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImageDataCustom.cpp; sourceTree = "<group>"; };
 		A7D20F3B107F373800A80392 /* WebGLActiveInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLActiveInfo.idl; sourceTree = "<group>"; };
 		A7D20F60107F406900A80392 /* JSWebGLActiveInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLActiveInfo.cpp; sourceTree = "<group>"; };
@@ -15636,6 +15634,8 @@
 		F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AxisScrollSnapOffsets.cpp; sourceTree = "<group>"; };
 		F45C231C1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AxisScrollSnapOffsets.h; sourceTree = "<group>"; };
 		F4628A9E234D3BBF00BC884C /* PlatformPasteboardCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformPasteboardCocoa.mm; sourceTree = "<group>"; };
+		F462E79F242ADA3C00204DDD /* DragDataCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragDataCocoa.mm; sourceTree = "<group>"; };
+		F462E7A0242ADA3D00204DDD /* DragImageCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragImageCocoa.mm; sourceTree = "<group>"; };
 		F46729251E0DE5AB00ACC3D8 /* ScrollSnapOffsetsInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollSnapOffsetsInfo.h; sourceTree = "<group>"; };
 		F46C447A2346535E0039A79D /* ClipboardItemDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClipboardItemDataSource.h; sourceTree = "<group>"; };
 		F46C447C234654540039A79D /* ClipboardItemBindingsDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClipboardItemBindingsDataSource.h; sourceTree = "<group>"; };
@@ -20671,8 +20671,6 @@
 				1AFFC44D1D5E7EC700267A66 /* BlacklistUpdater.h */,
 				1AFFC44E1D5E7EC700267A66 /* BlacklistUpdater.mm */,
 				F58784F002DE375901EA4122 /* CursorMac.mm */,
-				A795463D0B5C4C80007B438F /* DragDataMac.mm */,
-				A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */,
 				E1BA66F01742BD8600C20251 /* DynamicLinkerInterposing.h */,
 				935C476E09AC4D7300A6AAB4 /* KeyEventMac.mm */,
 				F44A5F571FED3830007F5944 /* LegacyNSPasteboardTypes.h */,
@@ -23261,6 +23259,8 @@
 				CD7D33461C7A16BF00041293 /* CoreVideoSoftLink.h */,
 				7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */,
 				7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */,
+				F462E79F242ADA3C00204DDD /* DragDataCocoa.mm */,
+				F462E7A0242ADA3D00204DDD /* DragImageCocoa.mm */,
 				7A09CEF01F01D1F700E93BDB /* FileMonitorCocoa.mm */,
 				A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */,
 				A5C974D011485FF10066F2AB /* KeyEventCocoa.mm */,

Copied: trunk/Source/WebCore/platform/cocoa/DragDataCocoa.mm (from rev 258965, trunk/Source/WebCore/platform/mac/DragDataMac.mm) (0 => 258966)


--- trunk/Source/WebCore/platform/cocoa/DragDataCocoa.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/DragDataCocoa.mm	2020-03-25 01:22:03 UTC (rev 258966)
@@ -0,0 +1,347 @@
+/*
+ * Copyright (C) 2007-2020 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 "config.h"
+#import "DragData.h"
+
+#if ENABLE(DRAG_SUPPORT)
+#import "LegacyNSPasteboardTypes.h"
+#import "MIMETypeRegistry.h"
+#import "NotImplemented.h"
+#import "Pasteboard.h"
+#import "PasteboardStrategy.h"
+#import "PlatformPasteboard.h"
+#import "PlatformStrategies.h"
+#import "RuntimeEnabledFeatures.h"
+#import "WebCoreNSURLExtras.h"
+#import <wtf/cocoa/NSURLExtras.h>
+
+#if PLATFORM(IOS_FAMILY)
+#import <MobileCoreServices/MobileCoreServices.h>
+#endif
+
+namespace WebCore {
+
+static inline String rtfPasteboardType()
+{
+#if PLATFORM(IOS_FAMILY)
+    return String(kUTTypeRTF);
+#else
+    return String(legacyRTFPasteboardType());
+#endif
+}
+
+static inline String rtfdPasteboardType()
+{
+#if PLATFORM(IOS_FAMILY)
+    return String(kUTTypeFlatRTFD);
+#else
+    return String(legacyRTFDPasteboardType());
+#endif
+}
+
+static inline String stringPasteboardType()
+{
+#if PLATFORM(IOS_FAMILY)
+    return String(kUTTypeText);
+#else
+    return String(legacyStringPasteboardType());
+#endif
+}
+
+static inline String urlPasteboardType()
+{
+#if PLATFORM(IOS_FAMILY)
+    return String(kUTTypeURL);
+#else
+    return String(legacyURLPasteboardType());
+#endif
+}
+
+static inline String htmlPasteboardType()
+{
+#if PLATFORM(IOS_FAMILY)
+    return String(kUTTypeHTML);
+#else
+    return String(legacyHTMLPasteboardType());
+#endif
+}
+
+static inline String colorPasteboardType()
+{
+#if PLATFORM(IOS_FAMILY)
+    return String { UIColorPboardType };
+#else
+    return String(legacyColorPasteboardType());
+#endif
+}
+
+static inline String pdfPasteboardType()
+{
+#if PLATFORM(IOS_FAMILY)
+    return String(kUTTypePDF);
+#else
+    return String(legacyPDFPasteboardType());
+#endif
+}
+
+static inline String tiffPasteboardType()
+{
+#if PLATFORM(IOS_FAMILY)
+    return String(kUTTypeTIFF);
+#else
+    return String(legacyTIFFPasteboardType());
+#endif
+}
+
+DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation sourceOperationMask, DragApplicationFlags flags, DragDestinationAction destinationAction)
+    : m_clientPosition(clientPosition)
+    , m_globalPosition(globalPosition)
+    , m_platformDragData(data)
+    , m_draggingSourceOperationMask(sourceOperationMask)
+    , m_applicationFlags(flags)
+    , m_dragDestinationAction(destinationAction)
+#if PLATFORM(MAC)
+    , m_pasteboardName([[m_platformDragData draggingPasteboard] name])
+#else
+    , m_pasteboardName("data interaction pasteboard")
+#endif
+{
+}
+
+DragData::DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation sourceOperationMask, DragApplicationFlags flags, DragDestinationAction destinationAction)
+    : m_clientPosition(clientPosition)
+    , m_globalPosition(globalPosition)
+    , m_platformDragData(0)
+    , m_draggingSourceOperationMask(sourceOperationMask)
+    , m_applicationFlags(flags)
+    , m_dragDestinationAction(destinationAction)
+    , m_pasteboardName(dragStorageName)
+{
+}
+
+bool DragData::containsURLTypeIdentifier() const
+{
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+    return types.contains(urlPasteboardType());
+}
+    
+bool DragData::canSmartReplace() const
+{
+    return Pasteboard(m_pasteboardName).canSmartReplace();
+}
+
+bool DragData::containsColor() const
+{
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+    return types.contains(colorPasteboardType());
+}
+
+bool DragData::containsFiles() const
+{
+    return numberOfFiles();
+}
+
+unsigned DragData::numberOfFiles() const
+{
+    return platformStrategies()->pasteboardStrategy()->getNumberOfFiles(m_pasteboardName);
+}
+
+Vector<String> DragData::asFilenames() const
+{
+#if PLATFORM(MAC)
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+    if (types.contains(String(legacyFilesPromisePasteboardType())))
+        return fileNames();
+
+    Vector<String> results;
+    platformStrategies()->pasteboardStrategy()->getPathnamesForType(results, String(legacyFilenamesPasteboardType()), m_pasteboardName);
+    return results;
+#else
+    return fileNames();
+#endif
+}
+
+bool DragData::containsPlainText() const
+{
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+
+    return types.contains(stringPasteboardType())
+        || types.contains(rtfdPasteboardType())
+        || types.contains(rtfPasteboardType())
+#if PLATFORM(MAC)
+        || types.contains(String(legacyFilenamesPasteboardType()))
+#endif
+        || platformStrategies()->pasteboardStrategy()->stringForType(urlPasteboardType(), m_pasteboardName).length();
+}
+
+String DragData::asPlainText() const
+{
+    Pasteboard pasteboard(m_pasteboardName);
+    PasteboardPlainText text;
+    pasteboard.read(text);
+    String string = text.text;
+
+    // FIXME: It's not clear this is 100% correct since we know -[NSURL URLWithString:] does not handle
+    // all the same cases we handle well in the URL code for creating an NSURL.
+    if (text.isURL)
+        return WTF::userVisibleString([NSURL URLWithString:string]);
+
+    // FIXME: WTF should offer a non-Mac-specific way to convert string to precomposed form so we can do it for all platforms.
+    return [(NSString *)string precomposedStringWithCanonicalMapping];
+}
+
+Color DragData::asColor() const
+{
+    return platformStrategies()->pasteboardStrategy()->color(m_pasteboardName);
+}
+
+bool DragData::containsCompatibleContent(DraggingPurpose purpose) const
+{
+    if (purpose == DraggingPurpose::ForFileUpload)
+        return containsFiles();
+
+    if (purpose == DraggingPurpose::ForColorControl)
+        return containsColor();
+
+    if (purpose == DraggingPurpose::ForEditing && RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled() && containsFiles())
+        return true;
+
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+    return types.contains(String(WebArchivePboardType))
+        || types.contains(htmlPasteboardType())
+        || types.contains(String(kUTTypeWebArchive))
+#if PLATFORM(MAC)
+        || types.contains(String(legacyFilenamesPasteboardType()))
+        || types.contains(String(legacyFilesPromisePasteboardType()))
+#endif
+        || types.contains(tiffPasteboardType())
+        || types.contains(pdfPasteboardType())
+        || types.contains(urlPasteboardType())
+        || types.contains(rtfdPasteboardType())
+        || types.contains(rtfPasteboardType())
+        || types.contains(String(kUTTypeUTF8PlainText))
+        || types.contains(stringPasteboardType())
+        || types.contains(colorPasteboardType())
+        || types.contains(String(kUTTypeJPEG))
+        || types.contains(String(kUTTypePNG));
+}
+
+bool DragData::containsPromise() const
+{
+    // FIXME: legacyFilesPromisePasteboardType() contains UTIs, not path names. Also, why do we
+    // think promises should only contain one file (or UTI)?
+    Vector<String> files;
+#if PLATFORM(MAC)
+    platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(legacyFilesPromisePasteboardType()), m_pasteboardName);
+#endif
+    return files.size() == 1;
+}
+
+bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
+{
+#if PLATFORM(IOS_FAMILY)
+    UNUSED_PARAM(filenamePolicy);
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+    if (!types.contains(urlPasteboardType()))
+        return false;
+
+    auto urlString = platformStrategies()->pasteboardStrategy()->stringForType(urlPasteboardType(), m_pasteboardName);
+    if (urlString.isEmpty()) {
+        // On iOS, we don't get access to the contents of NSItemProviders until we perform the drag operation.
+        // Thus, we consider DragData to contain an URL if it contains the `public.url` UTI type. Later down the
+        // road, when we perform the drag operation, we can then check if the URL's protocol is http or https,
+        // and if it isn't, we bail out of page navigation.
+        return true;
+    }
+
+    URL webcoreURL = [NSURL URLWithString:urlString];
+    return webcoreURL.protocolIs("http") || webcoreURL.protocolIs("https");
+#else
+    return !asURL(filenamePolicy).isEmpty();
+#endif
+}
+
+String DragData::asURL(FilenameConversionPolicy, String* title) const
+{
+    // FIXME: Use filenamePolicy.
+
+    if (title) {
+#if PLATFORM(MAC)
+        String URLTitleString = platformStrategies()->pasteboardStrategy()->stringForType(String(WebURLNamePboardType), m_pasteboardName);
+        if (!URLTitleString.isEmpty())
+            *title = URLTitleString;
+#endif
+    }
+    
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+
+    if (types.contains(urlPasteboardType())) {
+        NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(urlPasteboardType(), m_pasteboardName)];
+        NSString *scheme = [URLFromPasteboard scheme];
+        // Cannot drop other schemes unless <rdar://problem/10562662> and <rdar://problem/11187315> are fixed.
+        if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"])
+            return [URLByCanonicalizingURL(URLFromPasteboard) absoluteString];
+    }
+    
+    if (types.contains(stringPasteboardType())) {
+        NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(stringPasteboardType(), m_pasteboardName)];
+        NSString *scheme = [URLFromPasteboard scheme];
+        // Pasteboard content is not trusted, because _javascript_ code can modify it. We can sanitize it for URLs and other typed content, but not for strings.
+        // The result of this function is used to initiate navigation, so we shouldn't allow arbitrary file URLs.
+        // FIXME: Should we allow only http family schemes, or anything non-local?
+        if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"])
+            return [URLByCanonicalizingURL(URLFromPasteboard) absoluteString];
+    }
+    
+#if PLATFORM(MAC)
+    if (types.contains(String(legacyFilenamesPasteboardType()))) {
+        Vector<String> files;
+        platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(legacyFilenamesPasteboardType()), m_pasteboardName);
+        if (files.size() == 1) {
+            BOOL isDirectory;
+            if ([[NSFileManager defaultManager] fileExistsAtPath:files[0] isDirectory:&isDirectory] && isDirectory)
+                return String();
+            return [URLByCanonicalizingURL([NSURL fileURLWithPath:files[0]]) absoluteString];
+        }
+    }
+
+    if (types.contains(String(legacyFilesPromisePasteboardType())) && fileNames().size() == 1)
+        return [URLByCanonicalizingURL([NSURL fileURLWithPath:fileNames()[0]]) absoluteString];
+#endif
+
+    return String();        
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DRAG_SUPPORT)

Copied: trunk/Source/WebCore/platform/cocoa/DragImageCocoa.mm (from rev 258965, trunk/Source/WebCore/platform/mac/DragImageMac.mm) (0 => 258966)


--- trunk/Source/WebCore/platform/cocoa/DragImageCocoa.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/DragImageCocoa.mm	2020-03-25 01:22:03 UTC (rev 258966)
@@ -0,0 +1,340 @@
+/*
+ * Copyright (C) 2007, 2009, 2012-2020 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 "config.h"
+#import "DragImage.h"
+
+#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
+
+#import "BitmapImage.h"
+#import "ColorMac.h"
+#import "Element.h"
+#import "FloatRoundedRect.h"
+#import "FontCascade.h"
+#import "FontDescription.h"
+#import "FontSelector.h"
+#import "GraphicsContext.h"
+#import "Image.h"
+#import "LocalDefaultSystemAppearance.h"
+#import "Page.h"
+#import "StringTruncator.h"
+#import "TextIndicator.h"
+#import "WebKitNSImageExtras.h"
+#import <pal/spi/cg/CoreGraphicsSPI.h>
+#import <pal/spi/cocoa/CoreTextSPI.h>
+#import <pal/spi/cocoa/URLFormattingSPI.h>
+#import <wtf/SoftLinking.h>
+#import <wtf/URL.h>
+
+#if !HAVE(URL_FORMATTING)
+SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(LinkPresentation)
+#endif
+
+namespace WebCore {
+
+IntSize dragImageSize(RetainPtr<NSImage> image)
+{
+    return (IntSize)[image size];
+}
+
+void deleteDragImage(RetainPtr<NSImage>)
+{
+    // Since this is a RetainPtr, there's nothing additional we need to do to
+    // delete it. It will be released when it falls out of scope.
+}
+
+RetainPtr<NSImage> scaleDragImage(RetainPtr<NSImage> image, FloatSize scale)
+{
+    NSSize originalSize = [image size];
+    NSSize newSize = NSMakeSize((originalSize.width * scale.width()), (originalSize.height * scale.height()));
+    newSize.width = roundf(newSize.width);
+    newSize.height = roundf(newSize.height);
+    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+    [image setScalesWhenResized:YES];
+    ALLOW_DEPRECATED_DECLARATIONS_END
+    [image setSize:newSize];
+    return image;
+}
+    
+RetainPtr<NSImage> dissolveDragImageToFraction(RetainPtr<NSImage> image, float delta)
+{
+    if (!image)
+        return nil;
+
+    RetainPtr<NSImage> dissolvedImage = adoptNS([[NSImage alloc] initWithSize:[image size]]);
+    
+    [dissolvedImage lockFocus];
+    [image drawAtPoint:NSZeroPoint fromRect:NSMakeRect(0, 0, [image size].width, [image size].height) operation:NSCompositingOperationCopy fraction:delta];
+    [dissolvedImage unlockFocus];
+
+    return dissolvedImage;
+}
+
+RetainPtr<NSImage> createDragImageFromImage(Image* image, ImageOrientation orientation)
+{
+    if (is<BitmapImage>(*image)) {
+        BitmapImage& bitmapImage = downcast<BitmapImage>(*image);
+
+        if (orientation == ImageOrientation::FromImage)
+            orientation = bitmapImage.orientationForCurrentFrame();
+
+        if (orientation != ImageOrientation::None) {
+            // Construct a correctly-rotated copy of the image to use as the drag image.
+            FloatSize imageSize = image->size(orientation);
+            RetainPtr<NSImage> rotatedDragImage = adoptNS([[NSImage alloc] initWithSize:(NSSize)(imageSize)]);
+            [rotatedDragImage lockFocus];
+
+            // ImageOrientation uses top-left coordinates, need to flip to bottom-left, apply...
+            CGAffineTransform transform = CGAffineTransformMakeTranslation(0, imageSize.height());
+            transform = CGAffineTransformScale(transform, 1, -1);
+            transform = CGAffineTransformConcat(orientation.transformFromDefault(imageSize), transform);
+
+            if (orientation.usesWidthAsHeight())
+                imageSize = imageSize.transposedSize();
+
+            // ...and flip back.
+            transform = CGAffineTransformTranslate(transform, 0, imageSize.height());
+            transform = CGAffineTransformScale(transform, 1, -1);
+
+            RetainPtr<NSAffineTransform> cocoaTransform = adoptNS([[NSAffineTransform alloc] init]);
+            [cocoaTransform setTransformStruct:*(NSAffineTransformStruct*)&transform];
+            [cocoaTransform concat];
+
+            FloatRect imageRect(FloatPoint(), imageSize);
+            [image->snapshotNSImage() drawInRect:imageRect fromRect:imageRect operation:NSCompositingOperationSourceOver fraction:1.0];
+
+            [rotatedDragImage unlockFocus];
+
+            return rotatedDragImage;
+        }
+    }
+
+    FloatSize imageSize = image->size();
+    auto dragImage = image->snapshotNSImage();
+    [dragImage setSize:(NSSize)imageSize];
+    return dragImage;
+}
+    
+RetainPtr<NSImage> createDragImageIconForCachedImageFilename(const String& filename)
+{
+    NSString *extension = nil;
+    size_t dotIndex = filename.reverseFind('.');
+    
+    if (dotIndex != notFound && dotIndex < (filename.length() - 1)) // require that a . exists after the first character and before the last
+        extension = filename.substring(dotIndex + 1);
+    else {
+        // It might be worth doing a further lookup to pull the extension from the MIME type.
+        extension = @"";
+    }
+    
+    return [[NSWorkspace sharedWorkspace] iconForFileType:extension];
+}
+
+const CGFloat linkImagePadding = 10;
+const CGFloat linkImageDomainBaselineToTitleBaseline = 18;
+const CGFloat linkImageCornerRadius = 5;
+const CGFloat linkImageMaximumWidth = 400;
+const CGFloat linkImageFontSize = 11;
+const CFIndex linkImageTitleMaximumLineCount = 2;
+const int linkImageShadowRadius = 0;
+const int linkImageShadowOffsetY = 0;
+const int linkImageDragCornerOutsetX = 6 - linkImageShadowRadius;
+const int linkImageDragCornerOutsetY = 10 - linkImageShadowRadius + linkImageShadowOffsetY;
+
+IntPoint dragOffsetForLinkDragImage(DragImageRef dragImage)
+{
+    IntSize size = dragImageSize(dragImage);
+    return { linkImageDragCornerOutsetX, size.height() + linkImageDragCornerOutsetY };
+}
+
+FloatPoint anchorPointForLinkDragImage(DragImageRef dragImage)
+{
+    IntSize size = dragImageSize(dragImage);
+    return { -static_cast<float>(linkImageDragCornerOutsetX) / size.width(), -static_cast<float>(linkImageDragCornerOutsetY) / size.height() };
+}
+
+struct LinkImageLayout {
+    LinkImageLayout(URL&, const String& title);
+
+    struct Label {
+        FloatPoint origin;
+        RetainPtr<CTFrameRef> frame;
+    };
+    Vector<Label> labels;
+
+    FloatRect boundingRect;
+};
+
+LinkImageLayout::LinkImageLayout(URL& url, const String& titleString)
+{
+    NSString *title = nsStringNilIfEmpty(titleString);
+    NSURL *cocoaURL = url;
+    NSString *absoluteURLString = [cocoaURL absoluteString];
+
+    NSString *domain = absoluteURLString;
+#if HAVE(URL_FORMATTING)
+    domain = [cocoaURL _lp_simplifiedDisplayString];
+#else
+    if (LinkPresentationLibrary())
+        domain = [cocoaURL _lp_simplifiedDisplayString];
+#endif
+
+    if ([title isEqualToString:absoluteURLString])
+        title = nil;
+
+    NSFont *titleFont = [NSFont boldSystemFontOfSize:linkImageFontSize];
+    NSFont *domainFont = [NSFont systemFontOfSize:linkImageFontSize];
+
+    NSColor *titleColor = [NSColor labelColor];
+    NSColor *domainColor = [NSColor secondaryLabelColor];
+
+    CGFloat maximumAvailableWidth = linkImageMaximumWidth - linkImagePadding * 2;
+
+    CGFloat currentY = linkImagePadding;
+    CGFloat maximumUsedTextWidth = 0;
+
+    auto buildLines = [this, maximumAvailableWidth, &maximumUsedTextWidth, &currentY] (NSString *text, NSColor *color, NSFont *font, CFIndex maximumLines, CTLineBreakMode lineBreakMode) {
+        CTParagraphStyleSetting paragraphStyleSettings[1];
+        paragraphStyleSettings[0].spec = kCTParagraphStyleSpecifierLineBreakMode;
+        paragraphStyleSettings[0].valueSize = sizeof(CTLineBreakMode);
+        paragraphStyleSettings[0].value = &lineBreakMode;
+        RetainPtr<CTParagraphStyleRef> paragraphStyle = adoptCF(CTParagraphStyleCreate(paragraphStyleSettings, 1));
+
+        NSDictionary *textAttributes = @{
+            (id)kCTFontAttributeName: font,
+            (id)kCTForegroundColorAttributeName: color,
+            (id)kCTParagraphStyleAttributeName: (id)paragraphStyle.get()
+        };
+        NSDictionary *frameAttributes = @{
+            (id)kCTFrameMaximumNumberOfLinesAttributeName: @(maximumLines)
+        };
+
+        RetainPtr<NSAttributedString> attributedText = adoptNS([[NSAttributedString alloc] initWithString:text attributes:textAttributes]);
+        RetainPtr<CTFramesetterRef> textFramesetter = adoptCF(CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributedText.get()));
+
+        CFRange fitRange;
+        CGSize textSize = CTFramesetterSuggestFrameSizeWithConstraints(textFramesetter.get(), CFRangeMake(0, 0), (CFDictionaryRef)frameAttributes, CGSizeMake(maximumAvailableWidth, CGFLOAT_MAX), &fitRange);
+
+        RetainPtr<CGPathRef> textPath = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, textSize.width, textSize.height), nullptr));
+        RetainPtr<CTFrameRef> textFrame = adoptCF(CTFramesetterCreateFrame(textFramesetter.get(), fitRange, textPath.get(), (CFDictionaryRef)frameAttributes));
+
+        CFArrayRef ctLines = CTFrameGetLines(textFrame.get());
+        CFIndex lineCount = CFArrayGetCount(ctLines);
+        if (!lineCount)
+            return;
+
+        Vector<CGPoint> origins(lineCount);
+        CGRect lineBounds;
+        CGFloat height = 0;
+        CTFrameGetLineOrigins(textFrame.get(), CFRangeMake(0, 0), origins.data());
+        for (CFIndex lineIndex = 0; lineIndex < lineCount; ++lineIndex) {
+            CTLineRef line = (CTLineRef)CFArrayGetValueAtIndex(ctLines, lineIndex);
+
+            lineBounds = CTLineGetBoundsWithOptions(line, 0);
+            CGFloat trailingWhitespaceWidth = CTLineGetTrailingWhitespaceWidth(line);
+            CGFloat lineWidthIgnoringTrailingWhitespace = lineBounds.size.width - trailingWhitespaceWidth;
+            maximumUsedTextWidth = std::max(maximumUsedTextWidth, lineWidthIgnoringTrailingWhitespace);
+
+            if (lineIndex)
+                height += origins[lineIndex - 1].y - origins[lineIndex].y;
+        }
+
+        LinkImageLayout::Label label;
+        label.frame = textFrame;
+        label.origin = FloatPoint(linkImagePadding, currentY + origins[0].y);
+        labels.append(label);
+
+        currentY += height + lineBounds.size.height;
+    };
+
+    if (title)
+        buildLines(title, titleColor, titleFont, linkImageTitleMaximumLineCount, kCTLineBreakByTruncatingTail);
+
+    if (title && domain)
+        currentY += linkImageDomainBaselineToTitleBaseline - (domainFont.ascender - domainFont.descender);
+
+    if (domain)
+        buildLines(domain, domainColor, domainFont, 1, kCTLineBreakByTruncatingMiddle);
+
+    currentY += linkImagePadding;
+
+    boundingRect = FloatRect(0, 0, maximumUsedTextWidth + linkImagePadding * 2, currentY);
+
+    // To work around blurry drag images on 1x displays, make the width and height a multiple of 2.
+    // FIXME: remove this workaround when <rdar://problem/33059739> is fixed.
+    boundingRect.setWidth((static_cast<int>(boundingRect.width()) / 2) * 2);
+    boundingRect.setHeight((static_cast<int>(boundingRect.height() / 2) * 2));
+}
+
+DragImageRef createDragImageForLink(Element& element, URL& url, const String& title, TextIndicatorData&, FontRenderingMode, float deviceScaleFactor)
+{
+    LinkImageLayout layout(url, title);
+
+    LocalDefaultSystemAppearance localAppearance(element.document().useDarkAppearance(element.computedStyle()));
+
+    auto imageSize = layout.boundingRect.size();
+    RetainPtr<NSImage> dragImage = adoptNS([[NSImage alloc] initWithSize:imageSize]);
+    [dragImage _web_lockFocusWithDeviceScaleFactor:deviceScaleFactor];
+
+    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+    GraphicsContext context((CGContextRef)[NSGraphicsContext currentContext].graphicsPort);
+    ALLOW_DEPRECATED_DECLARATIONS_END
+
+    context.fillRoundedRect(FloatRoundedRect(layout.boundingRect, FloatRoundedRect::Radii(linkImageCornerRadius)), colorFromNSColor([NSColor controlBackgroundColor]));
+
+    for (const auto& label : layout.labels) {
+        GraphicsContextStateSaver saver(context);
+        context.translate(label.origin.x(), layout.boundingRect.height() - label.origin.y() - linkImagePadding);
+        CTFrameDraw(label.frame.get(), context.platformContext());
+    }
+
+    [dragImage unlockFocus];
+
+    return dragImage;
+}
+
+DragImageRef createDragImageForColor(const Color& color, const FloatRect&, float, Path&)
+{
+    auto dragImage = adoptNS([[NSImage alloc] initWithSize:NSMakeSize(ColorSwatchWidth, ColorSwatchWidth)]);
+
+    [dragImage lockFocus];
+
+    NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0, 0, ColorSwatchWidth, ColorSwatchWidth) xRadius:ColorSwatchCornerRadius yRadius:ColorSwatchCornerRadius];
+    [path setLineWidth:ColorSwatchStrokeSize];
+
+    [nsColor(color) setFill];
+    [path fill];
+
+    [[NSColor quaternaryLabelColor] setStroke];
+    [path stroke];
+
+    [dragImage unlockFocus];
+
+    return dragImage;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm (258965 => 258966)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm	2020-03-25 00:51:44 UTC (rev 258965)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm	2020-03-25 01:22:03 UTC (rev 258966)
@@ -29,6 +29,7 @@
 #if ENABLE(WEBGPU)
 
 #import "GPUDevice.h"
+#import "GPUErrorScopes.h"
 #import "GPUShaderModuleDescriptor.h"
 #import "Logging.h"
 

Deleted: trunk/Source/WebCore/platform/mac/DragDataMac.mm (258965 => 258966)


--- trunk/Source/WebCore/platform/mac/DragDataMac.mm	2020-03-25 00:51:44 UTC (rev 258965)
+++ trunk/Source/WebCore/platform/mac/DragDataMac.mm	2020-03-25 01:22:03 UTC (rev 258966)
@@ -1,347 +0,0 @@
-/*
- * Copyright (C) 2007 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 "config.h"
-#import "DragData.h"
-
-#if ENABLE(DRAG_SUPPORT)
-#import "LegacyNSPasteboardTypes.h"
-#import "MIMETypeRegistry.h"
-#import "NotImplemented.h"
-#import "Pasteboard.h"
-#import "PasteboardStrategy.h"
-#import "PlatformPasteboard.h"
-#import "PlatformStrategies.h"
-#import "RuntimeEnabledFeatures.h"
-#import "WebCoreNSURLExtras.h"
-#import <wtf/cocoa/NSURLExtras.h>
-
-#if PLATFORM(IOS_FAMILY)
-#import <MobileCoreServices/MobileCoreServices.h>
-#endif
-
-namespace WebCore {
-
-static inline String rtfPasteboardType()
-{
-#if PLATFORM(IOS_FAMILY)
-    return String(kUTTypeRTF);
-#else
-    return String(legacyRTFPasteboardType());
-#endif
-}
-
-static inline String rtfdPasteboardType()
-{
-#if PLATFORM(IOS_FAMILY)
-    return String(kUTTypeFlatRTFD);
-#else
-    return String(legacyRTFDPasteboardType());
-#endif
-}
-
-static inline String stringPasteboardType()
-{
-#if PLATFORM(IOS_FAMILY)
-    return String(kUTTypeText);
-#else
-    return String(legacyStringPasteboardType());
-#endif
-}
-
-static inline String urlPasteboardType()
-{
-#if PLATFORM(IOS_FAMILY)
-    return String(kUTTypeURL);
-#else
-    return String(legacyURLPasteboardType());
-#endif
-}
-
-static inline String htmlPasteboardType()
-{
-#if PLATFORM(IOS_FAMILY)
-    return String(kUTTypeHTML);
-#else
-    return String(legacyHTMLPasteboardType());
-#endif
-}
-
-static inline String colorPasteboardType()
-{
-#if PLATFORM(IOS_FAMILY)
-    return String { UIColorPboardType };
-#else
-    return String(legacyColorPasteboardType());
-#endif
-}
-
-static inline String pdfPasteboardType()
-{
-#if PLATFORM(IOS_FAMILY)
-    return String(kUTTypePDF);
-#else
-    return String(legacyPDFPasteboardType());
-#endif
-}
-
-static inline String tiffPasteboardType()
-{
-#if PLATFORM(IOS_FAMILY)
-    return String(kUTTypeTIFF);
-#else
-    return String(legacyTIFFPasteboardType());
-#endif
-}
-
-DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation sourceOperationMask, DragApplicationFlags flags, DragDestinationAction destinationAction)
-    : m_clientPosition(clientPosition)
-    , m_globalPosition(globalPosition)
-    , m_platformDragData(data)
-    , m_draggingSourceOperationMask(sourceOperationMask)
-    , m_applicationFlags(flags)
-    , m_dragDestinationAction(destinationAction)
-#if PLATFORM(MAC)
-    , m_pasteboardName([[m_platformDragData draggingPasteboard] name])
-#else
-    , m_pasteboardName("data interaction pasteboard")
-#endif
-{
-}
-
-DragData::DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation sourceOperationMask, DragApplicationFlags flags, DragDestinationAction destinationAction)
-    : m_clientPosition(clientPosition)
-    , m_globalPosition(globalPosition)
-    , m_platformDragData(0)
-    , m_draggingSourceOperationMask(sourceOperationMask)
-    , m_applicationFlags(flags)
-    , m_dragDestinationAction(destinationAction)
-    , m_pasteboardName(dragStorageName)
-{
-}
-
-bool DragData::containsURLTypeIdentifier() const
-{
-    Vector<String> types;
-    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-    return types.contains(urlPasteboardType());
-}
-    
-bool DragData::canSmartReplace() const
-{
-    return Pasteboard(m_pasteboardName).canSmartReplace();
-}
-
-bool DragData::containsColor() const
-{
-    Vector<String> types;
-    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-    return types.contains(colorPasteboardType());
-}
-
-bool DragData::containsFiles() const
-{
-    return numberOfFiles();
-}
-
-unsigned DragData::numberOfFiles() const
-{
-    return platformStrategies()->pasteboardStrategy()->getNumberOfFiles(m_pasteboardName);
-}
-
-Vector<String> DragData::asFilenames() const
-{
-#if PLATFORM(MAC)
-    Vector<String> types;
-    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-    if (types.contains(String(legacyFilesPromisePasteboardType())))
-        return fileNames();
-
-    Vector<String> results;
-    platformStrategies()->pasteboardStrategy()->getPathnamesForType(results, String(legacyFilenamesPasteboardType()), m_pasteboardName);
-    return results;
-#else
-    return fileNames();
-#endif
-}
-
-bool DragData::containsPlainText() const
-{
-    Vector<String> types;
-    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-
-    return types.contains(stringPasteboardType())
-        || types.contains(rtfdPasteboardType())
-        || types.contains(rtfPasteboardType())
-#if PLATFORM(MAC)
-        || types.contains(String(legacyFilenamesPasteboardType()))
-#endif
-        || platformStrategies()->pasteboardStrategy()->stringForType(urlPasteboardType(), m_pasteboardName).length();
-}
-
-String DragData::asPlainText() const
-{
-    Pasteboard pasteboard(m_pasteboardName);
-    PasteboardPlainText text;
-    pasteboard.read(text);
-    String string = text.text;
-
-    // FIXME: It's not clear this is 100% correct since we know -[NSURL URLWithString:] does not handle
-    // all the same cases we handle well in the URL code for creating an NSURL.
-    if (text.isURL)
-        return WTF::userVisibleString([NSURL URLWithString:string]);
-
-    // FIXME: WTF should offer a non-Mac-specific way to convert string to precomposed form so we can do it for all platforms.
-    return [(NSString *)string precomposedStringWithCanonicalMapping];
-}
-
-Color DragData::asColor() const
-{
-    return platformStrategies()->pasteboardStrategy()->color(m_pasteboardName);
-}
-
-bool DragData::containsCompatibleContent(DraggingPurpose purpose) const
-{
-    if (purpose == DraggingPurpose::ForFileUpload)
-        return containsFiles();
-
-    if (purpose == DraggingPurpose::ForColorControl)
-        return containsColor();
-
-    if (purpose == DraggingPurpose::ForEditing && RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled() && containsFiles())
-        return true;
-
-    Vector<String> types;
-    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-    return types.contains(String(WebArchivePboardType))
-        || types.contains(htmlPasteboardType())
-        || types.contains(String(kUTTypeWebArchive))
-#if PLATFORM(MAC)
-        || types.contains(String(legacyFilenamesPasteboardType()))
-        || types.contains(String(legacyFilesPromisePasteboardType()))
-#endif
-        || types.contains(tiffPasteboardType())
-        || types.contains(pdfPasteboardType())
-        || types.contains(urlPasteboardType())
-        || types.contains(rtfdPasteboardType())
-        || types.contains(rtfPasteboardType())
-        || types.contains(String(kUTTypeUTF8PlainText))
-        || types.contains(stringPasteboardType())
-        || types.contains(colorPasteboardType())
-        || types.contains(String(kUTTypeJPEG))
-        || types.contains(String(kUTTypePNG));
-}
-
-bool DragData::containsPromise() const
-{
-    // FIXME: legacyFilesPromisePasteboardType() contains UTIs, not path names. Also, why do we
-    // think promises should only contain one file (or UTI)?
-    Vector<String> files;
-#if PLATFORM(MAC)
-    platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(legacyFilesPromisePasteboardType()), m_pasteboardName);
-#endif
-    return files.size() == 1;
-}
-
-bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
-{
-#if PLATFORM(IOS_FAMILY)
-    UNUSED_PARAM(filenamePolicy);
-    Vector<String> types;
-    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-    if (!types.contains(urlPasteboardType()))
-        return false;
-
-    auto urlString = platformStrategies()->pasteboardStrategy()->stringForType(urlPasteboardType(), m_pasteboardName);
-    if (urlString.isEmpty()) {
-        // On iOS, we don't get access to the contents of NSItemProviders until we perform the drag operation.
-        // Thus, we consider DragData to contain an URL if it contains the `public.url` UTI type. Later down the
-        // road, when we perform the drag operation, we can then check if the URL's protocol is http or https,
-        // and if it isn't, we bail out of page navigation.
-        return true;
-    }
-
-    URL webcoreURL = [NSURL URLWithString:urlString];
-    return webcoreURL.protocolIs("http") || webcoreURL.protocolIs("https");
-#else
-    return !asURL(filenamePolicy).isEmpty();
-#endif
-}
-
-String DragData::asURL(FilenameConversionPolicy, String* title) const
-{
-    // FIXME: Use filenamePolicy.
-
-    if (title) {
-#if PLATFORM(MAC)
-        String URLTitleString = platformStrategies()->pasteboardStrategy()->stringForType(String(WebURLNamePboardType), m_pasteboardName);
-        if (!URLTitleString.isEmpty())
-            *title = URLTitleString;
-#endif
-    }
-    
-    Vector<String> types;
-    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-
-    if (types.contains(urlPasteboardType())) {
-        NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(urlPasteboardType(), m_pasteboardName)];
-        NSString *scheme = [URLFromPasteboard scheme];
-        // Cannot drop other schemes unless <rdar://problem/10562662> and <rdar://problem/11187315> are fixed.
-        if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"])
-            return [URLByCanonicalizingURL(URLFromPasteboard) absoluteString];
-    }
-    
-    if (types.contains(stringPasteboardType())) {
-        NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(stringPasteboardType(), m_pasteboardName)];
-        NSString *scheme = [URLFromPasteboard scheme];
-        // Pasteboard content is not trusted, because _javascript_ code can modify it. We can sanitize it for URLs and other typed content, but not for strings.
-        // The result of this function is used to initiate navigation, so we shouldn't allow arbitrary file URLs.
-        // FIXME: Should we allow only http family schemes, or anything non-local?
-        if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"])
-            return [URLByCanonicalizingURL(URLFromPasteboard) absoluteString];
-    }
-    
-#if PLATFORM(MAC)
-    if (types.contains(String(legacyFilenamesPasteboardType()))) {
-        Vector<String> files;
-        platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(legacyFilenamesPasteboardType()), m_pasteboardName);
-        if (files.size() == 1) {
-            BOOL isDirectory;
-            if ([[NSFileManager defaultManager] fileExistsAtPath:files[0] isDirectory:&isDirectory] && isDirectory)
-                return String();
-            return [URLByCanonicalizingURL([NSURL fileURLWithPath:files[0]]) absoluteString];
-        }
-    }
-
-    if (types.contains(String(legacyFilesPromisePasteboardType())) && fileNames().size() == 1)
-        return [URLByCanonicalizingURL([NSURL fileURLWithPath:fileNames()[0]]) absoluteString];
-#endif
-
-    return String();        
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(DRAG_SUPPORT)

Deleted: trunk/Source/WebCore/platform/mac/DragImageMac.mm (258965 => 258966)


--- trunk/Source/WebCore/platform/mac/DragImageMac.mm	2020-03-25 00:51:44 UTC (rev 258965)
+++ trunk/Source/WebCore/platform/mac/DragImageMac.mm	2020-03-25 01:22:03 UTC (rev 258966)
@@ -1,340 +0,0 @@
-/*
- * Copyright (C) 2007, 2009, 2012 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 "config.h"
-#import "DragImage.h"
-
-#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
-
-#import "BitmapImage.h"
-#import "ColorMac.h"
-#import "Element.h"
-#import "FloatRoundedRect.h"
-#import "FontCascade.h"
-#import "FontDescription.h"
-#import "FontSelector.h"
-#import "GraphicsContext.h"
-#import "Image.h"
-#import "LocalDefaultSystemAppearance.h"
-#import "Page.h"
-#import "StringTruncator.h"
-#import "TextIndicator.h"
-#import "WebKitNSImageExtras.h"
-#import <pal/spi/cg/CoreGraphicsSPI.h>
-#import <pal/spi/cocoa/CoreTextSPI.h>
-#import <pal/spi/cocoa/URLFormattingSPI.h>
-#import <wtf/SoftLinking.h>
-#import <wtf/URL.h>
-
-#if !HAVE(URL_FORMATTING)
-SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(LinkPresentation)
-#endif
-
-namespace WebCore {
-
-IntSize dragImageSize(RetainPtr<NSImage> image)
-{
-    return (IntSize)[image size];
-}
-
-void deleteDragImage(RetainPtr<NSImage>)
-{
-    // Since this is a RetainPtr, there's nothing additional we need to do to
-    // delete it. It will be released when it falls out of scope.
-}
-
-RetainPtr<NSImage> scaleDragImage(RetainPtr<NSImage> image, FloatSize scale)
-{
-    NSSize originalSize = [image size];
-    NSSize newSize = NSMakeSize((originalSize.width * scale.width()), (originalSize.height * scale.height()));
-    newSize.width = roundf(newSize.width);
-    newSize.height = roundf(newSize.height);
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    [image setScalesWhenResized:YES];
-    ALLOW_DEPRECATED_DECLARATIONS_END
-    [image setSize:newSize];
-    return image;
-}
-    
-RetainPtr<NSImage> dissolveDragImageToFraction(RetainPtr<NSImage> image, float delta)
-{
-    if (!image)
-        return nil;
-
-    RetainPtr<NSImage> dissolvedImage = adoptNS([[NSImage alloc] initWithSize:[image size]]);
-    
-    [dissolvedImage lockFocus];
-    [image drawAtPoint:NSZeroPoint fromRect:NSMakeRect(0, 0, [image size].width, [image size].height) operation:NSCompositingOperationCopy fraction:delta];
-    [dissolvedImage unlockFocus];
-
-    return dissolvedImage;
-}
-        
-RetainPtr<NSImage> createDragImageFromImage(Image* image, ImageOrientation orientation)
-{
-    if (is<BitmapImage>(*image)) {
-        BitmapImage& bitmapImage = downcast<BitmapImage>(*image);
-
-        if (orientation == ImageOrientation::FromImage)
-            orientation = bitmapImage.orientationForCurrentFrame();
-
-        if (orientation != ImageOrientation::None) {
-            // Construct a correctly-rotated copy of the image to use as the drag image.
-            FloatSize imageSize = image->size(orientation);
-            RetainPtr<NSImage> rotatedDragImage = adoptNS([[NSImage alloc] initWithSize:(NSSize)(imageSize)]);
-            [rotatedDragImage lockFocus];
-
-            // ImageOrientation uses top-left coordinates, need to flip to bottom-left, apply...
-            CGAffineTransform transform = CGAffineTransformMakeTranslation(0, imageSize.height());
-            transform = CGAffineTransformScale(transform, 1, -1);
-            transform = CGAffineTransformConcat(orientation.transformFromDefault(imageSize), transform);
-
-            if (orientation.usesWidthAsHeight())
-                imageSize = imageSize.transposedSize();
-
-            // ...and flip back.
-            transform = CGAffineTransformTranslate(transform, 0, imageSize.height());
-            transform = CGAffineTransformScale(transform, 1, -1);
-
-            RetainPtr<NSAffineTransform> cocoaTransform = adoptNS([[NSAffineTransform alloc] init]);
-            [cocoaTransform setTransformStruct:*(NSAffineTransformStruct*)&transform];
-            [cocoaTransform concat];
-
-            FloatRect imageRect(FloatPoint(), imageSize);
-            [image->snapshotNSImage() drawInRect:imageRect fromRect:imageRect operation:NSCompositingOperationSourceOver fraction:1.0];
-
-            [rotatedDragImage unlockFocus];
-
-            return rotatedDragImage;
-        }
-    }
-
-    FloatSize imageSize = image->size();
-    auto dragImage = image->snapshotNSImage();
-    [dragImage setSize:(NSSize)imageSize];
-    return dragImage;
-}
-    
-RetainPtr<NSImage> createDragImageIconForCachedImageFilename(const String& filename)
-{
-    NSString *extension = nil;
-    size_t dotIndex = filename.reverseFind('.');
-    
-    if (dotIndex != notFound && dotIndex < (filename.length() - 1)) // require that a . exists after the first character and before the last
-        extension = filename.substring(dotIndex + 1);
-    else {
-        // It might be worth doing a further lookup to pull the extension from the MIME type.
-        extension = @"";
-    }
-    
-    return [[NSWorkspace sharedWorkspace] iconForFileType:extension];
-}
-
-const CGFloat linkImagePadding = 10;
-const CGFloat linkImageDomainBaselineToTitleBaseline = 18;
-const CGFloat linkImageCornerRadius = 5;
-const CGFloat linkImageMaximumWidth = 400;
-const CGFloat linkImageFontSize = 11;
-const CFIndex linkImageTitleMaximumLineCount = 2;
-const int linkImageShadowRadius = 0;
-const int linkImageShadowOffsetY = 0;
-const int linkImageDragCornerOutsetX = 6 - linkImageShadowRadius;
-const int linkImageDragCornerOutsetY = 10 - linkImageShadowRadius + linkImageShadowOffsetY;
-
-IntPoint dragOffsetForLinkDragImage(DragImageRef dragImage)
-{
-    IntSize size = dragImageSize(dragImage);
-    return { linkImageDragCornerOutsetX, size.height() + linkImageDragCornerOutsetY };
-}
-
-FloatPoint anchorPointForLinkDragImage(DragImageRef dragImage)
-{
-    IntSize size = dragImageSize(dragImage);
-    return { -static_cast<float>(linkImageDragCornerOutsetX) / size.width(), -static_cast<float>(linkImageDragCornerOutsetY) / size.height() };
-}
-
-struct LinkImageLayout {
-    LinkImageLayout(URL&, const String& title);
-
-    struct Label {
-        FloatPoint origin;
-        RetainPtr<CTFrameRef> frame;
-    };
-    Vector<Label> labels;
-
-    FloatRect boundingRect;
-};
-
-LinkImageLayout::LinkImageLayout(URL& url, const String& titleString)
-{
-    NSString *title = nsStringNilIfEmpty(titleString);
-    NSURL *cocoaURL = url;
-    NSString *absoluteURLString = [cocoaURL absoluteString];
-
-    NSString *domain = absoluteURLString;
-#if HAVE(URL_FORMATTING)
-    domain = [cocoaURL _lp_simplifiedDisplayString];
-#else
-    if (LinkPresentationLibrary())
-        domain = [cocoaURL _lp_simplifiedDisplayString];
-#endif
-
-    if ([title isEqualToString:absoluteURLString])
-        title = nil;
-
-    NSFont *titleFont = [NSFont boldSystemFontOfSize:linkImageFontSize];
-    NSFont *domainFont = [NSFont systemFontOfSize:linkImageFontSize];
-
-    NSColor *titleColor = [NSColor labelColor];
-    NSColor *domainColor = [NSColor secondaryLabelColor];
-
-    CGFloat maximumAvailableWidth = linkImageMaximumWidth - linkImagePadding * 2;
-
-    CGFloat currentY = linkImagePadding;
-    CGFloat maximumUsedTextWidth = 0;
-
-    auto buildLines = [this, maximumAvailableWidth, &maximumUsedTextWidth, &currentY] (NSString *text, NSColor *color, NSFont *font, CFIndex maximumLines, CTLineBreakMode lineBreakMode) {
-        CTParagraphStyleSetting paragraphStyleSettings[1];
-        paragraphStyleSettings[0].spec = kCTParagraphStyleSpecifierLineBreakMode;
-        paragraphStyleSettings[0].valueSize = sizeof(CTLineBreakMode);
-        paragraphStyleSettings[0].value = &lineBreakMode;
-        RetainPtr<CTParagraphStyleRef> paragraphStyle = adoptCF(CTParagraphStyleCreate(paragraphStyleSettings, 1));
-
-        NSDictionary *textAttributes = @{
-            (id)kCTFontAttributeName: font,
-            (id)kCTForegroundColorAttributeName: color,
-            (id)kCTParagraphStyleAttributeName: (id)paragraphStyle.get()
-        };
-        NSDictionary *frameAttributes = @{
-            (id)kCTFrameMaximumNumberOfLinesAttributeName: @(maximumLines)
-        };
-
-        RetainPtr<NSAttributedString> attributedText = adoptNS([[NSAttributedString alloc] initWithString:text attributes:textAttributes]);
-        RetainPtr<CTFramesetterRef> textFramesetter = adoptCF(CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributedText.get()));
-
-        CFRange fitRange;
-        CGSize textSize = CTFramesetterSuggestFrameSizeWithConstraints(textFramesetter.get(), CFRangeMake(0, 0), (CFDictionaryRef)frameAttributes, CGSizeMake(maximumAvailableWidth, CGFLOAT_MAX), &fitRange);
-
-        RetainPtr<CGPathRef> textPath = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, textSize.width, textSize.height), nullptr));
-        RetainPtr<CTFrameRef> textFrame = adoptCF(CTFramesetterCreateFrame(textFramesetter.get(), fitRange, textPath.get(), (CFDictionaryRef)frameAttributes));
-
-        CFArrayRef ctLines = CTFrameGetLines(textFrame.get());
-        CFIndex lineCount = CFArrayGetCount(ctLines);
-        if (!lineCount)
-            return;
-
-        Vector<CGPoint> origins(lineCount);
-        CGRect lineBounds;
-        CGFloat height = 0;
-        CTFrameGetLineOrigins(textFrame.get(), CFRangeMake(0, 0), origins.data());
-        for (CFIndex lineIndex = 0; lineIndex < lineCount; ++lineIndex) {
-            CTLineRef line = (CTLineRef)CFArrayGetValueAtIndex(ctLines, lineIndex);
-
-            lineBounds = CTLineGetBoundsWithOptions(line, 0);
-            CGFloat trailingWhitespaceWidth = CTLineGetTrailingWhitespaceWidth(line);
-            CGFloat lineWidthIgnoringTrailingWhitespace = lineBounds.size.width - trailingWhitespaceWidth;
-            maximumUsedTextWidth = std::max(maximumUsedTextWidth, lineWidthIgnoringTrailingWhitespace);
-
-            if (lineIndex)
-                height += origins[lineIndex - 1].y - origins[lineIndex].y;
-        }
-
-        LinkImageLayout::Label label;
-        label.frame = textFrame;
-        label.origin = FloatPoint(linkImagePadding, currentY + origins[0].y);
-        labels.append(label);
-
-        currentY += height + lineBounds.size.height;
-    };
-
-    if (title)
-        buildLines(title, titleColor, titleFont, linkImageTitleMaximumLineCount, kCTLineBreakByTruncatingTail);
-
-    if (title && domain)
-        currentY += linkImageDomainBaselineToTitleBaseline - (domainFont.ascender - domainFont.descender);
-
-    if (domain)
-        buildLines(domain, domainColor, domainFont, 1, kCTLineBreakByTruncatingMiddle);
-
-    currentY += linkImagePadding;
-
-    boundingRect = FloatRect(0, 0, maximumUsedTextWidth + linkImagePadding * 2, currentY);
-
-    // To work around blurry drag images on 1x displays, make the width and height a multiple of 2.
-    // FIXME: remove this workaround when <rdar://problem/33059739> is fixed.
-    boundingRect.setWidth((static_cast<int>(boundingRect.width()) / 2) * 2);
-    boundingRect.setHeight((static_cast<int>(boundingRect.height() / 2) * 2));
-}
-
-DragImageRef createDragImageForLink(Element& element, URL& url, const String& title, TextIndicatorData&, FontRenderingMode, float deviceScaleFactor)
-{
-    LinkImageLayout layout(url, title);
-
-    LocalDefaultSystemAppearance localAppearance(element.document().useDarkAppearance(element.computedStyle()));
-
-    auto imageSize = layout.boundingRect.size();
-    RetainPtr<NSImage> dragImage = adoptNS([[NSImage alloc] initWithSize:imageSize]);
-    [dragImage _web_lockFocusWithDeviceScaleFactor:deviceScaleFactor];
-
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    GraphicsContext context((CGContextRef)[NSGraphicsContext currentContext].graphicsPort);
-    ALLOW_DEPRECATED_DECLARATIONS_END
-
-    context.fillRoundedRect(FloatRoundedRect(layout.boundingRect, FloatRoundedRect::Radii(linkImageCornerRadius)), colorFromNSColor([NSColor controlBackgroundColor]));
-
-    for (const auto& label : layout.labels) {
-        GraphicsContextStateSaver saver(context);
-        context.translate(label.origin.x(), layout.boundingRect.height() - label.origin.y() - linkImagePadding);
-        CTFrameDraw(label.frame.get(), context.platformContext());
-    }
-
-    [dragImage unlockFocus];
-
-    return dragImage;
-}
-
-DragImageRef createDragImageForColor(const Color& color, const FloatRect&, float, Path&)
-{
-    auto dragImage = adoptNS([[NSImage alloc] initWithSize:NSMakeSize(ColorSwatchWidth, ColorSwatchWidth)]);
-
-    [dragImage lockFocus];
-
-    NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0, 0, ColorSwatchWidth, ColorSwatchWidth) xRadius:ColorSwatchCornerRadius yRadius:ColorSwatchCornerRadius];
-    [path setLineWidth:ColorSwatchStrokeSize];
-
-    [nsColor(color) setFill];
-    [path fill];
-
-    [[NSColor quaternaryLabelColor] setStroke];
-    [path stroke];
-
-    [dragImage unlockFocus];
-
-    return dragImage;
-}
-   
-} // namespace WebCore
-
-#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to