WebKit Bugzilla
Attachment 343796 Details for
Bug 187130
: [iOS] DataTransfer.getData always returns the empty string when dropping text
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-187130-20180627223245.patch (text/plain), 30.61 KB, created by
Wenson Hsieh
on 2018-06-27 22:32:46 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2018-06-27 22:32:46 PDT
Size:
30.61 KB
patch
obsolete
>Subversion Revision: 233253 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index bedae4ed85eff1a9009ccce18cdb03d0df476231..5bf01acdaf977e0450e0280f5ae164131b6d4382 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,71 @@ >+2018-06-27 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] DataTransfer.getData always returns the empty string when dropping text >+ https://bugs.webkit.org/show_bug.cgi?id=187130 >+ <rdar://problem/41014117> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Currently, DataTransfer.getData() always returns the empty string on drop. This is because all data on drop is >+ backed by local files in the temporary directory, so the number of files is never 0; this, combined with the >+ fact that WebKit will suppress access to the DataTransfer object if there is one or more file in the pasteboard, >+ means that getData() never works for drag and drop on iOS at the moment. To fix this, we need to know whether a >+ dropped item provider is a file. >+ >+ Ideally, we'd have a flag to tell us whether or not an NSItemProvider being dropped is a file, or instead just >+ inline data - in fact, this flag already exists in the form of UIPreferredPresentationStyle. Unfortunately, not >+ all apps that vend draggable files specify this, so we can't simply ask the item provider whether it's intended >+ to be a file. As a workaround, we can use several heuristics to determine the "file content state" of the drag >+ pasteboard on iOS (see below for more details). >+ >+ This patch adds some plumbing through the client layers to grab a list of item information describing each >+ dropped item provider on iOS. Using this information, we tweak the logic in Pasteboard::fileContentState to make >+ an educated guess at whether or not the pasteboard really contains files; if we determine that the pasteboard >+ probably contains no files, we'll allow DataTransfer.getData() to retrieve information from the pasteboard. >+ Otherwise, if the pasteboard may contain files, we'll fall back to our current behavior of including the "Files" >+ type in DataTransfer.types and allowing the page to grab file data using DataTransfer.files or >+ DataTransfer.items. >+ >+ Tests: DataInteractionTests.DataTransferGetDataReadPlainAndRichText >+ DataInteractionTests.DataTransferSuppressGetDataDueToPresenceOfTextFile >+ >+ * dom/DataTransfer.cpp: >+ (WebCore::DataTransfer::filesFromPasteboardAndItemList const): >+ >+ Check Pasteboard::fileContentState() to ensure that we don't expose files when DataTransfer.types does not >+ contain the "Files" type, and vice versa. >+ >+ * dom/DataTransferItemList.cpp: >+ (WebCore::DataTransferItemList::ensureItems const): >+ * platform/PasteboardItemInfo.h: >+ >+ Add a couple of additional members to PasteboardItemInfo: suggestedFileName and hasDeclaredNonTextType, a flag >+ that indicates whether or not the pasteboard item has a type representation that is a declared type, but is not >+ a text type (i.e. does not conform to "public.text", "public.url", or rich text format with attachment types). >+ >+ (WebCore::PasteboardItemInfo::encode const): >+ (WebCore::PasteboardItemInfo::decode): >+ * platform/PasteboardStrategy.h: >+ * platform/PlatformPasteboard.h: >+ * platform/cocoa/PasteboardCocoa.mm: >+ (WebCore::Pasteboard::fileContentState): >+ >+ Instead of always considering a dropped item provider on iOS to represent a file, only do so if at least one of >+ the following conditions are met: >+ - The drop session contains multiple item providers (flocking text selections is a very rare use case). >+ - The item provider was explicitly marked as an attachment. >+ - The item provider has a suggested file name. >+ - The item provider has any other content that is not text. >+ >+ In the case where none of the above conditions are met, the item provider (if it ends up being a file) is >+ essentially indistinguishable from inline data. An example of this is dropping a plain text file that is >+ unnamed, with no presentation style, and alongside no other items nor other known type representations. These >+ are cases in which whether the item is treated as a file or as inline data is (hopefully) irrelevant. >+ >+ * platform/ios/PlatformPasteboardIOS.mm: >+ (WebCore::PlatformPasteboard::allPasteboardItemInfo): >+ (WebCore::PlatformPasteboard::informationForItemAtIndex): >+ > 2018-06-21 Emilio Cobos Ãlvarez <emilio@crisal.io> > > Move clearChildNeedsStyleRecalc into resetStyleForNonRenderedDescendants. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index dfd8848916637e45207cf62fcaf518b075a4c06c..84fd5eff8b109e758a3d99fb969d40189ee40d72 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,21 @@ >+2018-06-27 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] DataTransfer.getData always returns the empty string when dropping text >+ https://bugs.webkit.org/show_bug.cgi?id=187130 >+ <rdar://problem/41014117> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add plumbing to grab information for each item in the pasteboard. See WebCore ChangeLog for more detail. >+ >+ * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: >+ (WebKit::WebPasteboardProxy::allPasteboardItemInfo): >+ * UIProcess/WebPasteboardProxy.h: >+ * UIProcess/WebPasteboardProxy.messages.in: >+ * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: >+ (WebKit::WebPlatformStrategies::allPasteboardItemInfo): >+ * WebProcess/WebCoreSupport/WebPlatformStrategies.h: >+ > 2018-06-27 Tim Horton <timothy_horton@apple.com> > > When trying to print a very long email on iOS, the print preview is blank >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 61a241964f2eeed98eaf04b921da951c03a6e98f..4d0720457c43679e1bafccc6ded30556faf46d27 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,17 @@ >+2018-06-27 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] DataTransfer.getData always returns the empty string when dropping text >+ https://bugs.webkit.org/show_bug.cgi?id=187130 >+ <rdar://problem/41014117> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add plumbing to grab information for each item in the pasteboard. See WebCore ChangeLog for more detail. >+ >+ * WebCoreSupport/WebPlatformStrategies.h: >+ * WebCoreSupport/WebPlatformStrategies.mm: >+ (WebPlatformStrategies::allPasteboardItemInfo): >+ > 2018-06-26 Eric Carlson <eric.carlson@apple.com> > > [Mac] AirPlay picker uses incorrect theme in Dark mode >diff --git a/Source/WebCore/dom/DataTransfer.cpp b/Source/WebCore/dom/DataTransfer.cpp >index 2b91748a5b480896656877d56b320ad6131159b2..5141f472fe9b4915e8ba467f375a8322605f787d 100644 >--- a/Source/WebCore/dom/DataTransfer.cpp >+++ b/Source/WebCore/dom/DataTransfer.cpp >@@ -327,7 +327,7 @@ Vector<Ref<File>> DataTransfer::filesFromPasteboardAndItemList() const > { > bool addedFilesFromPasteboard = false; > Vector<Ref<File>> files; >- if (!forDrag() || forFileDrag()) { >+ if ((!forDrag() || forFileDrag()) && m_pasteboard->fileContentState() != Pasteboard::FileContentState::NoFileOrImageData) { > WebCorePasteboardFileReader reader; > m_pasteboard->read(reader); > files = WTFMove(reader.files); >diff --git a/Source/WebCore/dom/DataTransferItemList.cpp b/Source/WebCore/dom/DataTransferItemList.cpp >index cea8bc254c5b220e894f8e637e9416a5c385c119..7f6c8bac343e9dd6659013c953d91b02b7f8696a 100644 >--- a/Source/WebCore/dom/DataTransferItemList.cpp >+++ b/Source/WebCore/dom/DataTransferItemList.cpp >@@ -139,8 +139,10 @@ Vector<Ref<DataTransferItem>>& DataTransferItemList::ensureItems() const > items.append(DataTransferItem::create(makeWeakPtr(*const_cast<DataTransferItemList*>(this)), lowercasedType)); > } > >- for (auto& file : m_dataTransfer.files().files()) >- items.append(DataTransferItem::create(makeWeakPtr(*const_cast<DataTransferItemList*>(this)), file->type(), file.copyRef())); >+ if (m_dataTransfer.pasteboard().fileContentState() != Pasteboard::FileContentState::NoFileOrImageData) { >+ for (auto& file : m_dataTransfer.files().files()) >+ items.append(DataTransferItem::create(makeWeakPtr(*const_cast<DataTransferItemList*>(this)), file->type(), file.copyRef())); >+ } > > m_items = WTFMove(items); > >diff --git a/Source/WebCore/platform/PasteboardItemInfo.h b/Source/WebCore/platform/PasteboardItemInfo.h >index f7c35d237b625eda156c83ee6b691d97d225f10f..90f3f1b348954206bc9453650b042d6fb92c4c45 100644 >--- a/Source/WebCore/platform/PasteboardItemInfo.h >+++ b/Source/WebCore/platform/PasteboardItemInfo.h >@@ -39,6 +39,8 @@ enum class PasteboardItemPresentationStyle { > struct PasteboardItemInfo { > String pathForFileUpload; > String contentTypeForFileUpload; >+ String suggestedFileName; >+ bool hasDeclaredNonTextType { false }; > PasteboardItemPresentationStyle preferredPresentationStyle { PasteboardItemPresentationStyle::Unspecified }; > > template<class Encoder> void encode(Encoder&) const; >@@ -48,7 +50,7 @@ struct PasteboardItemInfo { > template<class Encoder> > void PasteboardItemInfo::encode(Encoder& encoder) const > { >- encoder << pathForFileUpload << contentTypeForFileUpload; >+ encoder << pathForFileUpload << contentTypeForFileUpload << suggestedFileName << hasDeclaredNonTextType; > encoder.encodeEnum(preferredPresentationStyle); > } > >@@ -62,6 +64,12 @@ std::optional<PasteboardItemInfo> PasteboardItemInfo::decode(Decoder& decoder) > if (!decoder.decode(result.contentTypeForFileUpload)) > return std::nullopt; > >+ if (!decoder.decode(result.suggestedFileName)) >+ return std::nullopt; >+ >+ if (!decoder.decode(result.hasDeclaredNonTextType)) >+ return std::nullopt; >+ > if (!decoder.decodeEnum(result.preferredPresentationStyle)) > return std::nullopt; > >diff --git a/Source/WebCore/platform/PasteboardStrategy.h b/Source/WebCore/platform/PasteboardStrategy.h >index 5837d91c9689ba7ea7fb1cd8f66c6751cca7124e..68317f41382061ce0b3c4175b06c14ca9a075c98 100644 >--- a/Source/WebCore/platform/PasteboardStrategy.h >+++ b/Source/WebCore/platform/PasteboardStrategy.h >@@ -51,6 +51,7 @@ public: > virtual String readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) = 0; > virtual RefPtr<SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) = 0; > virtual URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName, String& title) = 0; >+ virtual Vector<PasteboardItemInfo> allPasteboardItemInfo(const String& pasteboardName) = 0; > virtual PasteboardItemInfo informationForItemAtIndex(int index, const String& pasteboardName) = 0; > virtual void updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName) = 0; > virtual void getTypesByFidelityForItemAtIndex(Vector<String>& types, uint64_t index, const String& pasteboardName) = 0; >diff --git a/Source/WebCore/platform/PlatformPasteboard.h b/Source/WebCore/platform/PlatformPasteboard.h >index 24880536f9a2dd4ee01516cac2bd55229ced85b4..3caa5495cff500b9a052724c74594ca4ad869f36 100644 >--- a/Source/WebCore/platform/PlatformPasteboard.h >+++ b/Source/WebCore/platform/PlatformPasteboard.h >@@ -60,6 +60,7 @@ public: > WEBCORE_EXPORT explicit PlatformPasteboard(const String& pasteboardName); > #if PLATFORM(IOS) || PLATFORM(WPE) > WEBCORE_EXPORT PlatformPasteboard(); >+ WEBCORE_EXPORT Vector<PasteboardItemInfo> allPasteboardItemInfo(); > WEBCORE_EXPORT PasteboardItemInfo informationForItemAtIndex(int index); > WEBCORE_EXPORT void getTypesByFidelityForItemAtIndex(Vector<String>& types, int index); > WEBCORE_EXPORT void updateSupportedTypeIdentifiers(const Vector<String>& types); >diff --git a/Source/WebCore/platform/cocoa/PasteboardCocoa.mm b/Source/WebCore/platform/cocoa/PasteboardCocoa.mm >index 61e5fea70847d606d03f3ffee4af9d34631fd6b8..83ce8bfdb169a81a3e387c7f16e4e4e6136d9b21 100644 >--- a/Source/WebCore/platform/cocoa/PasteboardCocoa.mm >+++ b/Source/WebCore/platform/cocoa/PasteboardCocoa.mm >@@ -137,6 +137,38 @@ bool Pasteboard::shouldTreatCocoaTypeAsFile(const String& cocoaType) > Pasteboard::FileContentState Pasteboard::fileContentState() > { > bool mayContainFilePaths = platformStrategies()->pasteboardStrategy()->getNumberOfFiles(m_pasteboardName); >+ >+#if PLATFORM(IOS) >+ if (mayContainFilePaths) { >+ // On iOS, files are not written to the pasteboard using file URLs, so we need a heuristic to determine >+ // whether or not the pasteboard contains items that represent files. An example of when this gets tricky >+ // is differentiating between cases where the user is dragging a plain text file, versus selected text. >+ // Some common signs that indicate a file drop as opposed to dropping inline data are: >+ // >+ // 1. Multiple items - the system generally does not give opportunities to flock multiple pieces of >+ // selected text. >+ // 2. Preferred attachment presentation style - this means the source has explicitly marked the item >+ // as a file-like entity, as opposed to inline data. >+ // 3. A suggested name - this means that the source has explicitly specified a potential file name for >+ // the item when dropped. >+ // 4. The presence of any other declared non-text data in the same item indicates that the content being >+ // dropped can take on another non-text format, which could be a file. >+ // >+ // If none of these four conditions are satisfied, it's very likely that the content being dropped is just >+ // an inline piece of text, with no files in the pasteboard (and therefore, no risk of leaking file paths >+ // to web content). In cases such as these, we should not suppress DataTransfer access. >+ auto items = platformStrategies()->pasteboardStrategy()->allPasteboardItemInfo(m_pasteboardName); >+ mayContainFilePaths = items.size() != 1 || notFound != items.findMatching([] (auto& item) { >+ // The preferred presentation style is the most direct indication of whether this item represents file- >+ // like data. If the source has specified a presentation style, use this over other indirect cues. >+ if (item.preferredPresentationStyle != PasteboardItemPresentationStyle::Unspecified) >+ return item.preferredPresentationStyle == PasteboardItemPresentationStyle::Attachment; >+ >+ return !item.suggestedFileName.isEmpty() || item.hasDeclaredNonTextType; >+ }); >+ } >+#endif >+ > if (!mayContainFilePaths) { > Vector<String> cocoaTypes; > platformStrategies()->pasteboardStrategy()->getTypes(cocoaTypes, m_pasteboardName); >diff --git a/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm b/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm >index 7ee2ad9857b2a5941bfe17e8b31feb905cee2bf2..2ef51b706591abd0c8ba9f0fd0f692f0b4f1bea8 100644 >--- a/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm >+++ b/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm >@@ -122,6 +122,14 @@ static PasteboardItemPresentationStyle pasteboardItemPresentationStyle(UIPreferr > } > } > >+Vector<PasteboardItemInfo> PlatformPasteboard::allPasteboardItemInfo() >+{ >+ Vector<PasteboardItemInfo> itemInfo; >+ for (NSInteger itemIndex = 0; itemIndex < [m_pasteboard numberOfItems]; ++itemIndex) >+ itemInfo.append(informationForItemAtIndex(itemIndex)); >+ return itemInfo; >+} >+ > PasteboardItemInfo PlatformPasteboard::informationForItemAtIndex(int index) > { > if (index >= [m_pasteboard numberOfItems]) >@@ -136,6 +144,28 @@ PasteboardItemInfo PlatformPasteboard::informationForItemAtIndex(int index) > > NSItemProvider *itemProvider = [[m_pasteboard itemProviders] objectAtIndex:index]; > info.preferredPresentationStyle = pasteboardItemPresentationStyle(itemProvider.preferredPresentationStyle); >+ info.suggestedFileName = itemProvider.suggestedName; >+ for (NSString *typeIdentifier in itemProvider.registeredTypeIdentifiers) { >+ CFStringRef cfTypeIdentifier = (CFStringRef)typeIdentifier; >+ if (!UTTypeIsDeclared(cfTypeIdentifier)) >+ continue; >+ >+ if (UTTypeConformsTo(cfTypeIdentifier, kUTTypeText)) >+ continue; >+ >+ if (UTTypeConformsTo(cfTypeIdentifier, kUTTypeURL)) >+ continue; >+ >+ if (UTTypeConformsTo(cfTypeIdentifier, kUTTypeRTFD)) >+ continue; >+ >+ if (UTTypeConformsTo(cfTypeIdentifier, kUTTypeFlatRTFD)) >+ continue; >+ >+ info.hasDeclaredNonTextType = true; >+ break; >+ } >+ > return info; > } > >diff --git a/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm b/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm >index b20122b6a8dd4bc1e4575d136b6170a00ea3393d..ee917e3b604bad8c19b83c0b10e4bbe4f5758a24 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm >+++ b/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm >@@ -226,6 +226,11 @@ void WebPasteboardProxy::getPasteboardItemsCount(const String& pasteboardName, u > itemsCount = PlatformPasteboard(pasteboardName).count(); > } > >+void WebPasteboardProxy::allPasteboardItemInfo(const String& pasteboardName, Vector<PasteboardItemInfo>& allInfo) >+{ >+ allInfo = PlatformPasteboard(pasteboardName).allPasteboardItemInfo(); >+} >+ > void WebPasteboardProxy::informationForItemAtIndex(int index, const String& pasteboardName, PasteboardItemInfo& info) > { > info = PlatformPasteboard(pasteboardName).informationForItemAtIndex(index); >diff --git a/Source/WebKit/UIProcess/WebPasteboardProxy.h b/Source/WebKit/UIProcess/WebPasteboardProxy.h >index e84f8fe4dcf93d6f75547a3565edab26108bc24c..5fb4abce35d7f68e1a2df2b4471cfac7aacd2a84 100644 >--- a/Source/WebKit/UIProcess/WebPasteboardProxy.h >+++ b/Source/WebKit/UIProcess/WebPasteboardProxy.h >@@ -78,6 +78,7 @@ private: > void readURLFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, String& url, String& title); > void readBufferFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, SharedMemory::Handle&, uint64_t& size); > void getPasteboardItemsCount(const String& pasteboardName, uint64_t& itemsCount); >+ void allPasteboardItemInfo(const String& pasteboardName, Vector<WebCore::PasteboardItemInfo>&); > void informationForItemAtIndex(int index, const String& pasteboardName, WebCore::PasteboardItemInfo& filename); > void updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName); > #endif >diff --git a/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in b/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in >index c7b3b268071880aaf654adbd8dea960c9a98e6b3..3dc08ed9722ed84c06072352f1f375fa05850ed5 100644 >--- a/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in >+++ b/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in >@@ -30,6 +30,7 @@ messages -> WebPasteboardProxy { > ReadURLFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String url, String title) > ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (WebKit::SharedMemory::Handle handle, uint64_t size) > GetPasteboardItemsCount(String pasteboardName) -> (uint64_t itemsCount) >+ AllPasteboardItemInfo(String pasteboardName) -> (Vector<WebCore::PasteboardItemInfo> allInfo) > InformationForItemAtIndex(uint64_t index, String pasteboardName) -> (struct WebCore::PasteboardItemInfo info) > UpdateSupportedTypeIdentifiers(Vector<String> identifiers, String pasteboardName) > GetPasteboardTypesByFidelityForItemAtIndex(uint64_t index, String pasteboardName) -> (Vector<String> types) >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp >index 97a3270c75b228fbac154852209c5f537ac31a74..159f3da9b1d226c957c48037b1fd9d5b02671dd5 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp >@@ -322,6 +322,13 @@ int WebPlatformStrategies::getPasteboardItemsCount(const String& pasteboardName) > return itemsCount; > } > >+Vector<PasteboardItemInfo> WebPlatformStrategies::allPasteboardItemInfo(const String& pasteboardName) >+{ >+ Vector<PasteboardItemInfo> allInfo; >+ WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::AllPasteboardItemInfo(pasteboardName), Messages::WebPasteboardProxy::AllPasteboardItemInfo::Reply(allInfo), 0); >+ return allInfo; >+} >+ > PasteboardItemInfo WebPlatformStrategies::informationForItemAtIndex(int index, const String& pasteboardName) > { > PasteboardItemInfo info; >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h b/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h >index 659e763730fd54a0be69369e4de20026de9273a7..f8cd305bd27c1b0a5e1f8151332784f724dc943c 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h >@@ -65,6 +65,7 @@ private: > String readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override; > RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override; > WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName, String& title) override; >+ Vector<WebCore::PasteboardItemInfo> allPasteboardItemInfo(const String& pasteboardName) override; > WebCore::PasteboardItemInfo informationForItemAtIndex(int index, const String& pasteboardName) override; > void updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName) override; > void getTypesByFidelityForItemAtIndex(Vector<String>& types, uint64_t index, const String& pasteboardName) override; >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h b/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h >index 720fe6530a0388b0baf0a34169d71faa91d4987c..adc2ec476752836005c8abb5f460518f2cb4708f 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h >@@ -66,6 +66,7 @@ private: > String readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override; > RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override; > WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName, String& title) override; >+ Vector<WebCore::PasteboardItemInfo> allPasteboardItemInfo(const String& pasteboardName) override; > WebCore::PasteboardItemInfo informationForItemAtIndex(int index, const String& pasteboardName) override; > void updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName) override; > void getTypesByFidelityForItemAtIndex(Vector<String>& types, uint64_t index, const String& pasteboardName) override; >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm b/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm >index ebfcb6fd3708c01ac7d3d61e827c31cba91bef21..339bbbfba8fa336bf5d9462628cb3e455d6f3118 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm >@@ -240,6 +240,11 @@ String WebPlatformStrategies::readStringFromPasteboard(int index, const String& > return PlatformPasteboard(pasteboardName).readString(index, type); > } > >+Vector<WebCore::PasteboardItemInfo> WebPlatformStrategies::allPasteboardItemInfo(const String& pasteboardName) >+{ >+ return PlatformPasteboard(pasteboardName).allPasteboardItemInfo(); >+} >+ > WebCore::PasteboardItemInfo WebPlatformStrategies::informationForItemAtIndex(int index, const String& pasteboardName) > { > return PlatformPasteboard(pasteboardName).informationForItemAtIndex(index); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 2a79596940aae84b1f9b17b1def290ff1874aacd..a0c73704f3699915b53509a82806b3011b1ea371 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,26 @@ >+2018-06-27 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] DataTransfer.getData always returns the empty string when dropping text >+ https://bugs.webkit.org/show_bug.cgi?id=187130 >+ <rdar://problem/41014117> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add 2 new API tests to verify that: >+ - When dropping an item with text, markup, and URL representations, the page is allowed to get "text/html", >+ "text/plain" and "text/uri-list" data. >+ - Adding a suggested name to a plain text item causes WebKit to treat it as a file, and suppress access to >+ DataTransfer.getData(). >+ >+ Additionally tweaks a couple of existing API tests. Namely, in two API tests >+ (ExternalSourceOverrideDropFileUpload and ExternalSourceHTMLToUploadArea) only a markup string is dropped, and >+ we previously expected to handle the drop as a file. To allow this test to continue serving its purpose, tweak >+ them such that the registered items appear to be file-backed (i.e. by adding a suggested filename in one of the >+ tests, and specifying UIPreferredPresentationStyleAttachment in the other). >+ >+ * TestWebKitAPI/Tests/ios/DataInteractionTests.mm: >+ (TestWebKitAPI::TEST): >+ > 2018-06-26 Chris Dumez <cdumez@apple.com> > > Deal better with the network process crashing on startup >diff --git a/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm b/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm >index d060a22e4efb69e09ddd72a9dd346e524af823f4..21b1e1738ef4e04980c0eb4d89a934dd4acda2e4 100644 >--- a/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm >+++ b/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm >@@ -650,6 +650,7 @@ TEST(DataInteractionTests, ExternalSourceHTMLToUploadArea) > auto simulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]); > NSData *htmlData = [@"<body contenteditable></body>" dataUsingEncoding:NSUTF8StringEncoding]; > [simulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData]; >+ [simulatedHTMLItemProvider setSuggestedName:@"index.html"]; > > auto dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]); > [dataInteractionSimulator setShouldAllowMoveOperation:NO]; >@@ -980,6 +981,7 @@ TEST(DataInteractionTests, ExternalSourceOverrideDropFileUpload) > auto simulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]); > NSData *firstHTMLData = [@"<body contenteditable></body>" dataUsingEncoding:NSUTF8StringEncoding]; > [simulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:firstHTMLData]; >+ [simulatedHTMLItemProvider setPreferredPresentationStyle:UIPreferredPresentationStyleAttachment]; > > auto dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]); > [dataInteractionSimulator setOverridePerformDropBlock:^NSArray<UIDragItem *> *(id <UIDropSession> session) >@@ -1691,6 +1693,51 @@ TEST(DataInteractionTests, DataTransferSetDataCannotWritePlatformTypes) > }); > } > >+TEST(DataInteractionTests, DataTransferGetDataReadPlainAndRichText) >+{ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); >+ [webView synchronouslyLoadTestPageNamed:@"DataTransfer"]; >+ auto simulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]); >+ >+ auto itemProvider = adoptNS([[UIItemProvider alloc] init]); >+ NSDictionary *textAttributes = @{ NSFontAttributeName: [UIFont boldSystemFontOfSize:20] }; >+ NSAttributedString *richText = [[NSAttributedString alloc] initWithString:@"WebKit" attributes:textAttributes]; >+ [itemProvider registerObject:richText visibility:NSItemProviderRepresentationVisibilityAll]; >+ [itemProvider registerObject:[NSURL URLWithString:@"https://www.webkit.org/"] visibility:NSItemProviderRepresentationVisibilityAll]; >+ [itemProvider registerObject:@"WebKit" visibility:NSItemProviderRepresentationVisibilityAll]; >+ >+ [simulator setExternalItemProviders:@[ itemProvider.get() ]]; >+ [simulator runFrom:CGPointZero to:CGPointMake(50, 100)]; >+ >+ EXPECT_WK_STREQ("text/html, text/plain, text/uri-list", [webView stringByEvaluatingJavaScript:@"types.textContent"]); >+ EXPECT_WK_STREQ("WebKit", [webView stringByEvaluatingJavaScript:@"textData.textContent"]); >+ EXPECT_WK_STREQ("https://www.webkit.org/", [webView stringByEvaluatingJavaScript:@"urlData.textContent"]); >+ EXPECT_WK_STREQ("WebKit", [webView stringByEvaluatingJavaScript:@"htmlData.textContent"]); >+ EXPECT_WK_STREQ("(STRING, text/html), (STRING, text/plain), (STRING, text/uri-list)", [webView stringByEvaluatingJavaScript:@"items.textContent"]); >+ EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"files.textContent"]); >+} >+ >+TEST(DataInteractionTests, DataTransferSuppressGetDataDueToPresenceOfTextFile) >+{ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); >+ [webView synchronouslyLoadTestPageNamed:@"DataTransfer"]; >+ auto simulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]); >+ >+ auto itemProvider = adoptNS([[UIItemProvider alloc] init]); >+ [itemProvider registerObject:@"Hello world" visibility:NSItemProviderRepresentationVisibilityAll]; >+ [itemProvider setSuggestedName:@"hello.txt"]; >+ >+ [simulator setExternalItemProviders:@[ itemProvider.get() ]]; >+ [simulator runFrom:CGPointZero to:CGPointMake(50, 100)]; >+ >+ EXPECT_WK_STREQ("Files", [webView stringByEvaluatingJavaScript:@"types.textContent"]); >+ EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"textData.textContent"]); >+ EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"urlData.textContent"]); >+ EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"htmlData.textContent"]); >+ EXPECT_WK_STREQ("(FILE, text/plain)", [webView stringByEvaluatingJavaScript:@"items.textContent"]); >+ EXPECT_WK_STREQ("('hello.txt', text/plain)", [webView stringByEvaluatingJavaScript:@"files.textContent"]); >+} >+ > TEST(DataInteractionTests, DataTransferGetDataCannotReadPrivateArbitraryTypes) > { > auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
rniwa
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 187130
:
343794
| 343796 |
343805
|
343869