Diff
Modified: trunk/Source/WebCore/ChangeLog (222679 => 222680)
--- trunk/Source/WebCore/ChangeLog 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/ChangeLog 2017-09-30 10:31:05 UTC (rev 222680)
@@ -1,3 +1,74 @@
+2017-09-30 Ryosuke Niwa <rn...@webkit.org>
+
+ Share more pasteboard code between iOS and macOS and remove dependency on Settings
+ https://bugs.webkit.org/show_bug.cgi?id=177700
+
+ Reviewed by Wenson Hsieh.
+
+ Moved more code from PasteboardIOS.mm and PasteboardMac.mm into PasteboardCocoa.mm to share code.
+
+ This patch also removes the layering violation inadvertently introduced in r222595 whereby which
+ Pasteboard code depends on Settings. To do this, this patch splits readStringForBindings is into
+ readString and readStringInCustomData and typesForBindings into typesSafeForBindings and
+ typesForLegacyUnsafeBindings, and moves the logic to decide whether a given type or string is read
+ off of the native pasteboard entry or our custom data entry is moved to DataTransfer.
+
+ No new tests since there should be no behavioral change.
+
+ * dom/DataTransfer.cpp:
+ (WebCore::DataTransfer::getData const): Moved the code to decide whether string is
+ read off of custom data or native pasteboard from readStringForBindings.
+ (WebCore::DataTransfer::types const): Ditto from typesForBindings.
+ * platform/Pasteboard.cpp:
+ (WebCore::Pasteboard::isSafeTypeForDOMToReadAndWrite): Moved into Pasteboard.
+ * platform/Pasteboard.h:
+ * platform/StaticPasteboard.cpp:
+ (WebCore::StaticPasteboard::readString): Renamed from readStringForBindings.
+ (WebCore::StaticPasteboard::readStringInCustomData): Added.
+ (WebCore::StaticPasteboard::writeString):
+ * platform/StaticPasteboard.h:
+ * platform/cocoa/PasteboardCocoa.mm:
+ (WebCore::Pasteboard::typesSafeForBindings): Extracted out of typesForBindings in PasteboardIOS.mm
+ and PasteboardMac.mm.
+ (WebCore::Pasteboard::typesForLegacyUnsafeBindings): Ditto.
+ (WebCore::Pasteboard::readString): Ditto.
+ (WebCore::Pasteboard::readStringInCustomData): Ditto.
+ (WebCore::Pasteboard::writeCustomData): Moved here from PasteboardIOS.mm and PasteboardCocoa.mm.
+ (WebCore::Pasteboard::changeCount const): Ditto.
+ * platform/gtk/PasteboardGtk.cpp:
+ (WebCore::Pasteboard::typesSafeForBindings): Added.
+ (WebCore::Pasteboard::typesForLegacyUnsafeBindings): Renamed from readStringForBindings.
+ (WebCore::Pasteboard::readString):
+ (WebCore::Pasteboard::readStringInCustomData): Added.
+ * platform/ios/PasteboardIOS.mm:
+ (WebCore::Pasteboard::writeCustomData): Moved to PasteboardCocoa.mm.
+ (WebCore::Pasteboard::changeCount const): Ditto.
+ (WebCore::Pasteboard::readPlatformValueAsString): Moved into Pasteboard.
+ (WebCore::Pasteboard::addHTMLClipboardTypesForCocoaType): Ditto.
+ (WebCore::Pasteboard::readStringForBindings): Moved to PasteboardCocoa.mm.
+ (WebCore::Pasteboard::typesForBindings): Ditto.
+ * platform/ios/PlatformPasteboardIOS.mm:
+ (WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const):
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::changeCount const): Moved to PasteboardCocoa.mm.
+ (WebCore::Pasteboard::writeCustomData): Ditto.
+ (WebCore::Pasteboard::readPlatformValueAsString): Moved into Pasteboard.
+ (WebCore::Pasteboard::readStringForBindings): Moved to PasteboardCocoa.mm.
+ (WebCore::Pasteboard::addHTMLClipboardTypesForCocoaType): Moved into Pasteboard.
+ (WebCore::Pasteboard::typesForBindings): Moved to PasteboardCocoa.mm.
+ * platform/mac/PlatformPasteboardMac.mm:
+ (WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const):
+ * platform/win/PasteboardWin.cpp:
+ (WebCore::Pasteboard::typesSafeForBindings): Added.
+ (WebCore::Pasteboard::typesForLegacyUnsafeBindings): Renamed from readStringForBindings.
+ (WebCore::Pasteboard::readString): Renamed from readStringForBindings.
+ (WebCore::Pasteboard::readStringInCustomData): Added.
+ * platform/wpe/PasteboardWPE.cpp:
+ (WebCore::Pasteboard::typesSafeForBindings): Added.
+ (WebCore::PasteboardtypesForLegacyUnsafeBindings): Renamed from readStringForBindings.
+ (WebCore::Pasteboard::readString): Renamed from readStringForBindings.
+ (WebCore::Pasteboard::readStringInCustomData): Added.
+
2017-09-29 Antti Koivisto <an...@apple.com>
Use smart pointers for creating, adding and removing renderers
Modified: trunk/Source/WebCore/dom/DataTransfer.cpp (222679 => 222680)
--- trunk/Source/WebCore/dom/DataTransfer.cpp 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/dom/DataTransfer.cpp 2017-09-30 10:31:05 UTC (rev 222680)
@@ -37,6 +37,7 @@
#include "HTMLImageElement.h"
#include "Image.h"
#include "Pasteboard.h"
+#include "Settings.h"
#include "StaticPasteboard.h"
#include "WebCorePasteboardFileReader.h"
@@ -141,7 +142,10 @@
return { };
#endif
- return m_pasteboard->readStringForBindings(normalizeType(type));
+ auto normalizedType = normalizeType(type);
+ if (Settings::customPasteboardDataEnabled() && !Pasteboard::isSafeTypeForDOMToReadAndWrite(normalizedType))
+ return m_pasteboard->readStringInCustomData(normalizedType);
+ return m_pasteboard->readString(normalizedType);
}
void DataTransfer::setData(const String& type, const String& data)
@@ -172,7 +176,7 @@
if (!canReadTypes())
return { };
- return m_pasteboard->typesForBindings();
+ return Settings::customPasteboardDataEnabled() ? m_pasteboard->typesSafeForBindings() : m_pasteboard->typesForLegacyUnsafeBindings();
}
FileList& DataTransfer::files() const
Modified: trunk/Source/WebCore/editing/wpe/EditorWPE.cpp (222679 => 222680)
--- trunk/Source/WebCore/editing/wpe/EditorWPE.cpp 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/editing/wpe/EditorWPE.cpp 2017-09-30 10:31:05 UTC (rev 222680)
@@ -38,12 +38,12 @@
{
chosePlainText = false;
- Vector<String> types = pasteboard.typesForBindings();
+ Vector<String> types = pasteboard.typesForLegacyUnsafeBindings();
if (types.isEmpty())
return nullptr;
if (types.contains("text/html;charset=utf-8") && frame.document()) {
- String markup = pasteboard.readStringForBindings("text/html;charset=utf-8");
+ String markup = pasteboard.readString("text/html;charset=utf-8");
if (RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(*frame.document(), markup, emptyString(), DisallowScriptingAndPluginContent))
return fragment;
}
@@ -53,7 +53,7 @@
if (types.contains("text/plain;charset=utf-8")) {
chosePlainText = true;
- if (RefPtr<DocumentFragment> fragment = createFragmentFromText(range, pasteboard.readStringForBindings("text/plain;charset=utf-8")))
+ if (RefPtr<DocumentFragment> fragment = createFragmentFromText(range, pasteboard.readString("text/plain;charset=utf-8")))
return fragment;
}
Modified: trunk/Source/WebCore/platform/Pasteboard.cpp (222679 => 222680)
--- trunk/Source/WebCore/platform/Pasteboard.cpp 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/Pasteboard.cpp 2017-09-30 10:31:05 UTC (rev 222680)
@@ -39,7 +39,7 @@
PasteboardImage::PasteboardImage() = default;
PasteboardImage::~PasteboardImage() = default;
-bool isSafeTypeForDOMToReadAndWrite(const String& type)
+bool Pasteboard::isSafeTypeForDOMToReadAndWrite(const String& type)
{
return type == "text/plain" || type == "text/html" || type == "text/uri-list";
}
Modified: trunk/Source/WebCore/platform/Pasteboard.h (222679 => 222680)
--- trunk/Source/WebCore/platform/Pasteboard.h 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/Pasteboard.h 2017-09-30 10:31:05 UTC (rev 222680)
@@ -28,6 +28,7 @@
#include "DragImage.h"
#include "URL.h"
#include <wtf/HashMap.h>
+#include <wtf/ListHashSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
@@ -171,8 +172,6 @@
const char customWebKitPasteboardDataType[] = "com.apple.WebKit.custom-pasteboard-data";
#endif
-bool isSafeTypeForDOMToReadAndWrite(const String& type);
-
class Pasteboard {
WTF_MAKE_NONCOPYABLE(Pasteboard); WTF_MAKE_FAST_ALLOCATED;
public:
@@ -192,12 +191,16 @@
WEBCORE_EXPORT static std::unique_ptr<Pasteboard> createForCopyAndPaste();
+ static bool isSafeTypeForDOMToReadAndWrite(const String&);
+
virtual bool isStatic() const { return false; }
virtual bool hasData();
- virtual Vector<String> typesForBindings();
+ virtual Vector<String> typesSafeForBindings();
+ virtual Vector<String> typesForLegacyUnsafeBindings();
virtual Vector<String> typesTreatedAsFiles();
- virtual String readStringForBindings(const String& type);
+ virtual String readString(const String& type);
+ virtual String readStringInCustomData(const String& type);
virtual void writeString(const String& type, const String& data);
virtual void clear();
@@ -278,6 +281,8 @@
#endif
#if PLATFORM(COCOA)
+ String readPlatformValueAsString(const String& domType, long changeCount, const String& pasteboardName);
+ static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName);
String readStringForPlatformType(const String&);
#endif
Modified: trunk/Source/WebCore/platform/StaticPasteboard.cpp (222679 => 222680)
--- trunk/Source/WebCore/platform/StaticPasteboard.cpp 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/StaticPasteboard.cpp 2017-09-30 10:31:05 UTC (rev 222680)
@@ -40,20 +40,19 @@
return !m_platformData.isEmpty() || !m_customData.isEmpty();
}
-String StaticPasteboard::readStringForBindings(const String& type)
+String StaticPasteboard::readString(const String& type)
{
- if (m_platformData.contains(type))
- return m_platformData.get(type);
+ return m_platformData.get(type);
+}
- if (m_customData.contains(type))
- return m_customData.get(type);
-
- return { };
+String StaticPasteboard::readStringInCustomData(const String& type)
+{
+ return m_customData.get(type);
}
void StaticPasteboard::writeString(const String& type, const String& value)
{
- auto& pasteboardData = isSafeTypeForDOMToReadAndWrite(type) ? m_platformData : m_customData;
+ auto& pasteboardData = Pasteboard::isSafeTypeForDOMToReadAndWrite(type) ? m_platformData : m_customData;
if (pasteboardData.set(type, value).isNewEntry)
m_types.append(type);
else {
Modified: trunk/Source/WebCore/platform/StaticPasteboard.h (222679 => 222680)
--- trunk/Source/WebCore/platform/StaticPasteboard.h 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/StaticPasteboard.h 2017-09-30 10:31:05 UTC (rev 222680)
@@ -41,9 +41,11 @@
bool isStatic() const final { return true; }
bool hasData() final;
- Vector<String> typesForBindings() final { return m_types; }
+ Vector<String> typesSafeForBindings() final { return m_types; }
+ Vector<String> typesForLegacyUnsafeBindings() final { return m_types; }
Vector<String> typesTreatedAsFiles() final { return { }; }
- String readStringForBindings(const String& type) final;
+ String readString(const String& type) final;
+ String readStringInCustomData(const String& type) final;
void writeString(const String& type, const String& data) final;
void clear() final;
Modified: trunk/Source/WebCore/platform/cocoa/PasteboardCocoa.mm (222679 => 222680)
--- trunk/Source/WebCore/platform/cocoa/PasteboardCocoa.mm 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/cocoa/PasteboardCocoa.mm 2017-09-30 10:31:05 UTC (rev 222680)
@@ -151,6 +151,36 @@
return types;
}
+Vector<String> Pasteboard::typesSafeForBindings()
+{
+ Vector<String> types = platformStrategies()->pasteboardStrategy()->typesSafeForDOMToReadAndWrite(m_pasteboardName);
+
+ // Enforce changeCount ourselves for security. We check after reading instead of before to be
+ // sure it doesn't change between our testing the change count and accessing the data.
+ if (m_changeCount != platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
+ return { };
+
+ return types;
+}
+
+Vector<String> Pasteboard::typesForLegacyUnsafeBindings()
+{
+ Vector<String> types;
+ platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+
+ // Enforce changeCount ourselves for security. We check after reading instead of before to be
+ // sure it doesn't change between our testing the change count and accessing the data.
+ if (m_changeCount != platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
+ return { };
+
+ ListHashSet<String> result;
+ for (auto& cocoaType : types)
+ addHTMLClipboardTypesForCocoaType(result, cocoaType, m_pasteboardName);
+
+ copyToVector(result, types);
+ return types;
+}
+
void Pasteboard::read(PasteboardFileReader& reader)
{
auto imageType = mimeTypeToImageType(reader.type);
@@ -194,5 +224,32 @@
reader.read(imageTypeToFakeFilename(imageType), buffer.releaseNonNull());
}
+String Pasteboard::readString(const String& type)
+{
+ return readPlatformValueAsString(type, m_changeCount, m_pasteboardName);
}
+String Pasteboard::readStringInCustomData(const String& type)
+{
+ auto buffer = platformStrategies()->pasteboardStrategy()->bufferForType(customWebKitPasteboardDataType, m_pasteboardName);
+ if (!buffer)
+ return { };
+
+ NSString *customDataValue = customDataFromSharedBuffer(*buffer).sameOriginCustomData.get(type);
+ if (!customDataValue.length)
+ return { };
+ return customDataValue;
+}
+
+void Pasteboard::writeCustomData(const PasteboardCustomData& data)
+{
+ m_changeCount = platformStrategies()->pasteboardStrategy()->writeCustomData(data, m_pasteboardName);
+}
+
+long Pasteboard::changeCount() const
+{
+ return platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName);
+}
+
+}
+
Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (222679 => 222680)
--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp 2017-09-30 10:31:05 UTC (rev 222680)
@@ -252,8 +252,14 @@
return m_selectionData->hasText() || m_selectionData->hasMarkup() || m_selectionData->hasURIList() || m_selectionData->hasImage() || m_selectionData->hasUnknownTypeData();
}
-Vector<String> Pasteboard::typesForBindings()
+Vector<String> Pasteboard::typesSafeForBindings()
{
+ notImplemented(); // webkit.org/b/177633: [GTK] Move to new Pasteboard API
+ return { };
+}
+
+Vector<String> Pasteboard::typesForLegacyUnsafeBindings()
+{
readFromClipboard();
Vector<String> types;
@@ -285,7 +291,7 @@
return { };
}
-String Pasteboard::readStringForBindings(const String& type)
+String Pasteboard::readString(const String& type)
{
readFromClipboard();
@@ -307,6 +313,12 @@
return String();
}
+String Pasteboard::readStringInCustomData(const String&)
+{
+ notImplemented(); // webkit.org/b/177633: [GTK] Move to new Pasteboard API
+ return { };
+}
+
Vector<String> Pasteboard::readFilenames()
{
readFromClipboard();
Modified: trunk/Source/WebCore/platform/ios/PasteboardIOS.mm (222679 => 222680)
--- trunk/Source/WebCore/platform/ios/PasteboardIOS.mm 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/ios/PasteboardIOS.mm 2017-09-30 10:31:05 UTC (rev 222680)
@@ -25,35 +25,18 @@
#import "config.h"
#import "Pasteboard.h"
-#import "CachedImage.h"
-#import "Document.h"
-#import "DocumentFragment.h"
-#import "DocumentLoader.h"
#import "DragData.h"
-#import "Editing.h"
-#import "Editor.h"
-#import "EditorClient.h"
-#import "Frame.h"
-#import "FrameLoader.h"
-#import "FrameLoaderClient.h"
-#import "HTMLElement.h"
-#import "HTMLParserIdioms.h"
#import "Image.h"
-#import "LegacyWebArchive.h"
#import "NotImplemented.h"
#import "PasteboardStrategy.h"
#import "PlatformPasteboard.h"
#import "PlatformStrategies.h"
-#import "RenderImage.h"
-#import "RuntimeApplicationChecks.h"
-#import "Settings.h"
#import "SharedBuffer.h"
-#import "Text.h"
#import "URL.h"
#import "UTIUtilities.h"
#import "WebNSAttributedStringExtras.h"
-#import "markup.h"
#import <MobileCoreServices/MobileCoreServices.h>
+#import <wtf/text/StringHash.h>
@interface NSAttributedString (NSAttributedStringKitAdditions)
- (id)initWithRTF:(NSData *)data documentAttributes:(NSDictionary **)dict;
@@ -117,11 +100,6 @@
return std::make_unique<Pasteboard>(changeCountForPasteboard());
}
-void Pasteboard::writeCustomData(const PasteboardCustomData& data)
-{
- m_changeCount = platformStrategies()->pasteboardStrategy()->writeCustomData(data, m_pasteboardName);
-}
-
void Pasteboard::write(const PasteboardWebContent& content)
{
platformStrategies()->pasteboardStrategy()->writeToPasteboard(content, m_pasteboardName);
@@ -279,11 +257,6 @@
}
}
-long Pasteboard::changeCount() const
-{
- return platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName);
-}
-
NSArray *Pasteboard::supportedWebContentPasteboardTypes()
{
return @[(id)WebArchivePboardType, (id)kUTTypeFlatRTFD, (id)kUTTypeRTF, (id)kUTTypeHTML, (id)kUTTypePNG, (id)kUTTypeTIFF, (id)kUTTypeJPEG, (id)kUTTypeGIF, (id)kUTTypeURL, (id)kUTTypeText];
@@ -338,7 +311,7 @@
platformStrategies()->pasteboardStrategy()->writeToPasteboard(String(), String(), m_pasteboardName);
}
-static String readPlatformValueAsString(const String& domType, long changeCount, const String& pasteboardName)
+String Pasteboard::readPlatformValueAsString(const String& domType, long changeCount, const String& pasteboardName)
{
PasteboardStrategy& strategy = *platformStrategies()->pasteboardStrategy();
@@ -372,22 +345,8 @@
return String();
}
-String Pasteboard::readStringForBindings(const String& type)
+void Pasteboard::addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String&)
{
- if (!Settings::customPasteboardDataEnabled() || isSafeTypeForDOMToReadAndWrite(type))
- return readPlatformValueAsString(type, m_changeCount, m_pasteboardName);
-
- if (auto buffer = platformStrategies()->pasteboardStrategy()->bufferForType(customWebKitPasteboardDataType, m_pasteboardName)) {
- NSString *customDataValue = customDataFromSharedBuffer(*buffer).sameOriginCustomData.get(type);
- if (customDataValue.length)
- return customDataValue;
- }
-
- return { };
-}
-
-static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, NSString *cocoaType)
-{
// UTI may not do these right, so make sure we get the right, predictable result.
if ([cocoaType isEqualToString:(NSString *)kUTTypePlainText]
|| [cocoaType isEqualToString:(NSString *)kUTTypeUTF8PlainText]
@@ -421,32 +380,6 @@
platformStrategies()->pasteboardStrategy()->writeToPasteboard(cocoaType.get(), data, m_pasteboardName);
}
-Vector<String> Pasteboard::typesForBindings()
-{
- Vector<String> types;
- if (Settings::customPasteboardDataEnabled())
- types = platformStrategies()->pasteboardStrategy()->typesSafeForDOMToReadAndWrite(m_pasteboardName);
- else
- platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-
- // Enforce changeCount ourselves for security. We check after reading instead of before to be
- // sure it doesn't change between our testing the change count and accessing the data.
- auto changeCount = changeCountForPasteboard(m_pasteboardName);
- if (m_changeCount != changeCount)
- return { };
-
- if (Settings::customPasteboardDataEnabled())
- return types;
-
- ListHashSet<String> result;
- for (auto cocoaType : types)
- addHTMLClipboardTypesForCocoaType(result, cocoaType);
-
- Vector<String> vector;
- copyToVector(result, vector);
- return vector;
-}
-
Vector<String> Pasteboard::readFilenames()
{
Vector<String> filenames;
Modified: trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm (222679 => 222680)
--- trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm 2017-09-30 10:31:05 UTC (rev 222680)
@@ -375,7 +375,7 @@
if ([type isEqualToString:@(customWebKitPasteboardDataType)])
continue;
- if (isSafeTypeForDOMToReadAndWrite(type)) {
+ if (Pasteboard::isSafeTypeForDOMToReadAndWrite(type)) {
domPasteboardTypes.add(type);
continue;
}
Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (222679 => 222680)
--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2017-09-30 10:31:05 UTC (rev 222680)
@@ -26,34 +26,18 @@
#import "config.h"
#import "Pasteboard.h"
-#import "CachedImage.h"
-#import "Document.h"
-#import "DocumentFragment.h"
-#import "DocumentLoader.h"
#import "DragData.h"
-#import "Editing.h"
-#import "Editor.h"
-#import "EditorClient.h"
-#import "Frame.h"
-#import "FrameLoaderClient.h"
-#import "FrameView.h"
-#import "HitTestResult.h"
#import "Image.h"
-#import "LegacyWebArchive.h"
#import "LoaderNSURLExtras.h"
#import "MIMETypeRegistry.h"
#import "PasteboardStrategy.h"
#import "PlatformPasteboard.h"
#import "PlatformStrategies.h"
-#import "RenderImage.h"
-#import "Settings.h"
-#import "Text.h"
+#import "SharedBuffer.h"
#import "URL.h"
#import "UTIUtilities.h"
#import "WebCoreNSStringExtras.h"
-#import "WebCoreSystemInterface.h"
#import "WebNSAttributedStringExtras.h"
-#import "markup.h"
#import <pal/spi/cg/CoreGraphicsSPI.h>
#import <pal/spi/mac/HIServicesSPI.h>
#import <wtf/RetainPtr.h>
@@ -91,11 +75,6 @@
return types;
}
-long Pasteboard::changeCount() const
-{
- return platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName);
-}
-
NSArray *Pasteboard::supportedFileUploadPasteboardTypes()
{
return @[ (NSString *)NSFilesPromisePboardType, (NSString *)NSFilenamesPboardType ];
@@ -179,11 +158,6 @@
m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(content.dataInStringFormat, NSStringPboardType, m_pasteboardName);
}
-void Pasteboard::writeCustomData(const PasteboardCustomData& data)
-{
- m_changeCount = platformStrategies()->pasteboardStrategy()->writeCustomData(data, m_pasteboardName);
-}
-
void Pasteboard::writePlainText(const String& text, SmartReplaceOption smartReplaceOption)
{
Vector<String> types;
@@ -493,7 +467,7 @@
return urls;
}
-static String readPlatformValueAsString(const String& domType, long changeCount, const String& pasteboardName)
+String Pasteboard::readPlatformValueAsString(const String& domType, long changeCount, const String& pasteboardName)
{
const String& cocoaType = cocoaTypeFromHTMLClipboardType(domType);
String cocoaValue;
@@ -511,20 +485,6 @@
return String();
}
-String Pasteboard::readStringForBindings(const String& type)
-{
- if (!Settings::customPasteboardDataEnabled() || isSafeTypeForDOMToReadAndWrite(type))
- return readPlatformValueAsString(type, m_changeCount, m_pasteboardName);
-
- if (auto buffer = platformStrategies()->pasteboardStrategy()->bufferForType(customWebKitPasteboardDataType, m_pasteboardName)) {
- NSString *customDataValue = customDataFromSharedBuffer(*buffer).sameOriginCustomData.get(type);
- if (customDataValue.length)
- return customDataValue;
- }
-
- return { };
-}
-
static String utiTypeFromCocoaType(const String& type)
{
if (RetainPtr<CFStringRef> utiType = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, type.createCFString().get(), 0))) {
@@ -534,7 +494,7 @@
return String();
}
-static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName)
+void Pasteboard::addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName)
{
if (cocoaType == "NeXT plain ascii pasteboard type")
return; // Skip this ancient type that gets auto-supplied by some system conversion.
@@ -598,30 +558,6 @@
}
}
-Vector<String> Pasteboard::typesForBindings()
-{
- Vector<String> types;
- if (Settings::customPasteboardDataEnabled())
- types = platformStrategies()->pasteboardStrategy()->typesSafeForDOMToReadAndWrite(m_pasteboardName);
- else
- platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-
- // Enforce changeCount ourselves for security. We check after reading instead of before to be
- // sure it doesn't change between our testing the change count and accessing the data.
- if (m_changeCount != platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
- return { };
-
- if (Settings::customPasteboardDataEnabled())
- return types;
-
- ListHashSet<String> result;
- for (auto& cocoaType : types)
- addHTMLClipboardTypesForCocoaType(result, cocoaType, m_pasteboardName);
-
- copyToVector(result, types);
- return types;
-}
-
Vector<String> Pasteboard::readFilenames()
{
// FIXME: Seems silly to convert paths to URLs and then back to paths. Does that do anything helpful?
Modified: trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm (222679 => 222680)
--- trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm 2017-09-30 10:31:05 UTC (rev 222680)
@@ -28,7 +28,6 @@
#import "Color.h"
#import "Pasteboard.h"
-#import "Settings.h"
#import "URL.h"
#import "SharedBuffer.h"
#import <wtf/HashCountedSet.h>
@@ -125,7 +124,7 @@
if ([type isEqualToString:@(customWebKitPasteboardDataType)])
continue;
- if (isSafeTypeForDOMToReadAndWrite(type))
+ if (Pasteboard::isSafeTypeForDOMToReadAndWrite(type))
domPasteboardTypes.add(type);
else if (auto* domType = safeTypeForDOMToReadAndWriteForPlatformType(type)) {
auto coercedType = String::fromUTF8(domType);
Modified: trunk/Source/WebCore/platform/win/PasteboardWin.cpp (222679 => 222680)
--- trunk/Source/WebCore/platform/win/PasteboardWin.cpp 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/win/PasteboardWin.cpp 2017-09-30 10:31:05 UTC (rev 222680)
@@ -243,8 +243,14 @@
}
}
-Vector<String> Pasteboard::typesForBindings()
+Vector<String> Pasteboard::typesSafeForBindings()
{
+ notImplemented();
+ return { };
+}
+
+Vector<String> Pasteboard::typesForLegacyUnsafeBindings()
+{
ListHashSet<String> results;
if (!m_dataObject && m_dragDataMap.isEmpty())
@@ -282,7 +288,7 @@
return { };
}
-String Pasteboard::readStringForBindings(const String& type)
+String Pasteboard::readString(const String& type)
{
if (!m_dataObject && m_dragDataMap.isEmpty())
return "";
@@ -302,6 +308,12 @@
return "";
}
+String Pasteboard::readStringInCustomData(const String&)
+{
+ notImplemented();
+ return { };
+}
+
Vector<String> Pasteboard::readFilenames()
{
Vector<String> fileNames;
Modified: trunk/Source/WebCore/platform/wpe/PasteboardWPE.cpp (222679 => 222680)
--- trunk/Source/WebCore/platform/wpe/PasteboardWPE.cpp 2017-09-30 06:45:59 UTC (rev 222679)
+++ trunk/Source/WebCore/platform/wpe/PasteboardWPE.cpp 2017-09-30 10:31:05 UTC (rev 222680)
@@ -49,8 +49,14 @@
return !types.isEmpty();
}
-Vector<String> Pasteboard::typesForBindings()
+Vector<String> Pasteboard::typesSafeForBindings()
{
+ notImplemented();
+ return { };
+}
+
+Vector<String> Pasteboard::typesForLegacyUnsafeBindings()
+{
Vector<String> types;
platformStrategies()->pasteboardStrategy()->getTypes(types);
return types;
@@ -61,11 +67,17 @@
return { };
}
-String Pasteboard::readStringForBindings(const String& type)
+String Pasteboard::readString(const String& type)
{
return platformStrategies()->pasteboardStrategy()->readStringFromPasteboard(0, type);
}
+String Pasteboard::readStringInCustomData(const String&)
+{
+ notImplemented();
+ return { };
+}
+
void Pasteboard::writeString(const String& type, const String& text)
{
platformStrategies()->pasteboardStrategy()->writeToPasteboard(type, text);