- Revision
- 222702
- Author
- [email protected]
- Date
- 2017-10-02 01:55:11 -0700 (Mon, 02 Oct 2017)
Log Message
Pasteboard shouldn't add "Files" as a type
https://bugs.webkit.org/show_bug.cgi?id=177731
Reviewed by Wenson Hsieh.
Removed the platform specific code to add "Files" when there is a file present in platform's pasteboard.
DataTransfer::types now adds "Files" automatically when Pasteboard::containsFiles returns true.
No new tests since there should be no behavioral change.
* dom/DataTransfer.cpp:
(WebCore::DataTransfer::types const):
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::typesForLegacyUnsafeBindings):
* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::addHTMLClipboardTypesForCocoaType):
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::addHTMLClipboardTypesForCocoaType):
* platform/win/PasteboardWin.cpp:
(WebCore::addMimeTypesForFormat): Removed the code to add "Text" and "URL" as separate types since
this is not what the rest of ports do, and this type normalization is now taken care of by DataTransfer
since r221063.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (222701 => 222702)
--- trunk/Source/WebCore/ChangeLog 2017-10-02 08:25:53 UTC (rev 222701)
+++ trunk/Source/WebCore/ChangeLog 2017-10-02 08:55:11 UTC (rev 222702)
@@ -1,3 +1,28 @@
+2017-10-01 Ryosuke Niwa <[email protected]>
+
+ Pasteboard shouldn't add "Files" as a type
+ https://bugs.webkit.org/show_bug.cgi?id=177731
+
+ Reviewed by Wenson Hsieh.
+
+ Removed the platform specific code to add "Files" when there is a file present in platform's pasteboard.
+ DataTransfer::types now adds "Files" automatically when Pasteboard::containsFiles returns true.
+
+ No new tests since there should be no behavioral change.
+
+ * dom/DataTransfer.cpp:
+ (WebCore::DataTransfer::types const):
+ * platform/gtk/PasteboardGtk.cpp:
+ (WebCore::Pasteboard::typesForLegacyUnsafeBindings):
+ * platform/ios/PasteboardIOS.mm:
+ (WebCore::Pasteboard::addHTMLClipboardTypesForCocoaType):
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::addHTMLClipboardTypesForCocoaType):
+ * platform/win/PasteboardWin.cpp:
+ (WebCore::addMimeTypesForFormat): Removed the code to add "Text" and "URL" as separate types since
+ this is not what the rest of ports do, and this type normalization is now taken care of by DataTransfer
+ since r221063.
+
2017-10-02 Ryosuke Niwa <[email protected]>
Another attempt to fix Windows build after r222697.
Modified: trunk/Source/WebCore/dom/DataTransfer.cpp (222701 => 222702)
--- trunk/Source/WebCore/dom/DataTransfer.cpp 2017-10-02 08:25:53 UTC (rev 222701)
+++ trunk/Source/WebCore/dom/DataTransfer.cpp 2017-10-02 08:55:11 UTC (rev 222702)
@@ -172,12 +172,22 @@
if (!canReadTypes())
return { };
- if (!Settings::customPasteboardDataEnabled())
- return m_pasteboard->typesForLegacyUnsafeBindings();
+ if (!Settings::customPasteboardDataEnabled()) {
+ auto types = m_pasteboard->typesForLegacyUnsafeBindings();
+ ASSERT(!types.contains("Files"));
+ if (m_pasteboard->containsFiles())
+ types.append("Files");
+ return types;
+ }
- if (m_pasteboard->containsFiles())
+ if (m_pasteboard->containsFiles()) {
+ ASSERT(!m_pasteboard->typesSafeForBindings().contains("Files"));
return { "Files" };
- return m_pasteboard->typesSafeForBindings();
+ }
+
+ auto types = m_pasteboard->typesSafeForBindings();
+ ASSERT(!types.contains("Files"));
+ return types;
}
FileList& DataTransfer::files() const
Modified: trunk/Source/WebCore/platform/Pasteboard.h (222701 => 222702)
--- trunk/Source/WebCore/platform/Pasteboard.h 2017-10-02 08:25:53 UTC (rev 222701)
+++ trunk/Source/WebCore/platform/Pasteboard.h 2017-10-02 08:55:11 UTC (rev 222702)
@@ -278,7 +278,7 @@
#if PLATFORM(COCOA)
Vector<String> readFilenames();
String readPlatformValueAsString(const String& domType, long changeCount, const String& pasteboardName);
- static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName);
+ static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType);
String readStringForPlatformType(const String&);
Vector<String> readTypesWithSecurityCheck();
RefPtr<SharedBuffer> readBufferForTypeWithSecurityCheck(const String&);
Modified: trunk/Source/WebCore/platform/cocoa/PasteboardCocoa.mm (222701 => 222702)
--- trunk/Source/WebCore/platform/cocoa/PasteboardCocoa.mm 2017-10-02 08:25:53 UTC (rev 222701)
+++ trunk/Source/WebCore/platform/cocoa/PasteboardCocoa.mm 2017-10-02 08:55:11 UTC (rev 222702)
@@ -158,7 +158,7 @@
ListHashSet<String> result;
for (auto& cocoaType : cocoaTypes)
- addHTMLClipboardTypesForCocoaType(result, cocoaType, m_pasteboardName);
+ addHTMLClipboardTypesForCocoaType(result, cocoaType);
Vector<String> types;
copyToVector(result, types);
Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (222701 => 222702)
--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp 2017-10-02 08:25:53 UTC (rev 222701)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp 2017-10-02 08:55:11 UTC (rev 222702)
@@ -280,9 +280,6 @@
types.append(ASCIILiteral("URL"));
}
- if (m_selectionData->hasFilenames())
- types.append(ASCIILiteral("Files"));
-
for (auto& key : m_selectionData->unknownTypes().keys())
types.append(key);
Modified: trunk/Source/WebCore/platform/ios/PasteboardIOS.mm (222701 => 222702)
--- trunk/Source/WebCore/platform/ios/PasteboardIOS.mm 2017-10-02 08:25:53 UTC (rev 222701)
+++ trunk/Source/WebCore/platform/ios/PasteboardIOS.mm 2017-10-02 08:55:11 UTC (rev 222702)
@@ -345,7 +345,7 @@
return String();
}
-void Pasteboard::addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String&)
+void Pasteboard::addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType)
{
// UTI may not do these right, so make sure we get the right, predictable result.
if ([cocoaType isEqualToString:(NSString *)kUTTypePlainText]
@@ -358,10 +358,8 @@
resultTypes.add(ASCIILiteral("text/uri-list"));
return;
}
- if (Pasteboard::shouldTreatCocoaTypeAsFile(cocoaType)) {
- resultTypes.add(ASCIILiteral("Files"));
+ if (Pasteboard::shouldTreatCocoaTypeAsFile(cocoaType))
return;
- }
String utiType = utiTypeFromCocoaType(cocoaType);
if (!utiType.isEmpty()) {
resultTypes.add(utiType);
Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (222701 => 222702)
--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2017-10-02 08:25:53 UTC (rev 222701)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2017-10-02 08:55:11 UTC (rev 222702)
@@ -494,7 +494,7 @@
return String();
}
-void Pasteboard::addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName)
+void Pasteboard::addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType)
{
if (cocoaType == "NeXT plain ascii pasteboard type")
return; // Skip this ancient type that gets auto-supplied by some system conversion.
@@ -508,20 +508,8 @@
resultTypes.add(ASCIILiteral("text/uri-list"));
return;
}
- if (cocoaType == String(NSFilenamesPboardType)) {
- // If file list is empty, add nothing.
- // Note that there is a chance that the file list count could have changed since we grabbed the types array.
- // However, this is not really an issue for us doing a sanity check here.
- Vector<String> fileList;
- platformStrategies()->pasteboardStrategy()->getPathnamesForType(fileList, String(NSFilenamesPboardType), pasteboardName);
- if (!fileList.isEmpty())
- resultTypes.add(ASCIILiteral("Files"));
+ if (cocoaType == String(NSFilenamesPboardType) || Pasteboard::shouldTreatCocoaTypeAsFile(cocoaType))
return;
- }
- if (Pasteboard::shouldTreatCocoaTypeAsFile(cocoaType)) {
- resultTypes.add(ASCIILiteral("Files"));
- return;
- }
String utiType = utiTypeFromCocoaType(cocoaType);
if (!utiType.isEmpty()) {
resultTypes.add(utiType);
Modified: trunk/Source/WebCore/platform/win/PasteboardWin.cpp (222701 => 222702)
--- trunk/Source/WebCore/platform/win/PasteboardWin.cpp 2017-10-02 08:25:53 UTC (rev 222701)
+++ trunk/Source/WebCore/platform/win/PasteboardWin.cpp 2017-10-02 08:55:11 UTC (rev 222702)
@@ -231,16 +231,10 @@
static void addMimeTypesForFormat(ListHashSet<String>& results, const FORMATETC& format)
{
- // URL and Text are provided for compatibility with IE's model
- if (format.cfFormat == urlFormat()->cfFormat || format.cfFormat == urlWFormat()->cfFormat) {
- results.add("URL");
+ if (format.cfFormat == urlFormat()->cfFormat || format.cfFormat == urlWFormat()->cfFormat)
results.add("text/uri-list");
- }
-
- if (format.cfFormat == plainTextWFormat()->cfFormat || format.cfFormat == plainTextFormat()->cfFormat) {
- results.add("Text");
+ if (format.cfFormat == plainTextWFormat()->cfFormat || format.cfFormat == plainTextFormat()->cfFormat)
results.add("text/plain");
- }
}
Vector<String> Pasteboard::typesSafeForBindings()