Title: [222608] trunk/Source/WebCore
Revision
222608
Author
[email protected]
Date
2017-09-28 07:47:59 -0700 (Thu, 28 Sep 2017)

Log Message

[iOS WK2] DataTransfer DataInteractionTests debug assert under -_preLoadedDataConformingToType:forItemProviderAtIndex:
https://bugs.webkit.org/show_bug.cgi?id=177594

Reviewed by Tim Horton.

Currently, some API tests added in r222595 currently hit debug assertions under -preloadedDataConformingToType:
forItemProviderAtIndex:. This is because the page may call DataTransfer.types, which now calls into
PlatformPasteboard::typesSafeForDOMToReadAndWrite(). This calls on the AbstractPasteboard (either the
UIPasteboard or WebItemProviderPasteboard, in the case of drag and drop) to fetch the custom WebKit pasteboard
data blob, if it exists. For WebItemProviderPasteboard, this ends up calling into -[WebItemProviderPasteboard
_preLoadedDataConformingToType:forItemProviderAtIndex:], which was previously only called after loading data off
of the item providers. There's an existing sanity check in this preloaded data helper to make sure that the
number of load results is equal to the number of item providers loaded from, but this sanity check only makes
sense *after* the drop has happened, not before, since we should only attempt to read dropped data after any
data at all has been dropped.

We need to check whether or not this custom data blob exists in PlatformPasteboard::typesSafeForDOMToReadAndWrite
to fetch the list of DOM-exposed types to propagate back to the page. So to fix this, we make the helper methods
for fetching dropped data (-dataForPasteboardType:inItemSet: and -valuesForPasteboardType:inItemSet:) fail
gracefully when invoked prior to drop, when PlatformPasteboard::typesSafeForDOMToReadAndWrite is invoked.

No new tests; fixes iOS drag and drop API tests that currently hit this debug assertion.

* platform/ios/WebItemProviderPasteboard.mm:
(-[WebItemProviderPasteboard dataForPasteboardType:inItemSet:]):
(-[WebItemProviderPasteboard valuesForPasteboardType:inItemSet:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (222607 => 222608)


--- trunk/Source/WebCore/ChangeLog	2017-09-28 11:20:24 UTC (rev 222607)
+++ trunk/Source/WebCore/ChangeLog	2017-09-28 14:47:59 UTC (rev 222608)
@@ -1,3 +1,32 @@
+2017-09-28  Wenson Hsieh  <[email protected]>
+
+        [iOS WK2] DataTransfer DataInteractionTests debug assert under -_preLoadedDataConformingToType:forItemProviderAtIndex:
+        https://bugs.webkit.org/show_bug.cgi?id=177594
+
+        Reviewed by Tim Horton.
+
+        Currently, some API tests added in r222595 currently hit debug assertions under -preloadedDataConformingToType:
+        forItemProviderAtIndex:. This is because the page may call DataTransfer.types, which now calls into
+        PlatformPasteboard::typesSafeForDOMToReadAndWrite(). This calls on the AbstractPasteboard (either the
+        UIPasteboard or WebItemProviderPasteboard, in the case of drag and drop) to fetch the custom WebKit pasteboard
+        data blob, if it exists. For WebItemProviderPasteboard, this ends up calling into -[WebItemProviderPasteboard
+        _preLoadedDataConformingToType:forItemProviderAtIndex:], which was previously only called after loading data off
+        of the item providers. There's an existing sanity check in this preloaded data helper to make sure that the
+        number of load results is equal to the number of item providers loaded from, but this sanity check only makes
+        sense *after* the drop has happened, not before, since we should only attempt to read dropped data after any
+        data at all has been dropped.
+
+        We need to check whether or not this custom data blob exists in PlatformPasteboard::typesSafeForDOMToReadAndWrite
+        to fetch the list of DOM-exposed types to propagate back to the page. So to fix this, we make the helper methods
+        for fetching dropped data (-dataForPasteboardType:inItemSet: and -valuesForPasteboardType:inItemSet:) fail
+        gracefully when invoked prior to drop, when PlatformPasteboard::typesSafeForDOMToReadAndWrite is invoked.
+
+        No new tests; fixes iOS drag and drop API tests that currently hit this debug assertion.
+
+        * platform/ios/WebItemProviderPasteboard.mm:
+        (-[WebItemProviderPasteboard dataForPasteboardType:inItemSet:]):
+        (-[WebItemProviderPasteboard valuesForPasteboardType:inItemSet:]):
+
 2017-09-28  Ryosuke Niwa  <[email protected]>
 
         REGRESSION(r222595): Assertion failure in _preLoadedDataConformingToType

Modified: trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm (222607 => 222608)


--- trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm	2017-09-28 11:20:24 UTC (rev 222607)
+++ trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm	2017-09-28 14:47:59 UTC (rev 222608)
@@ -393,6 +393,9 @@
 
 - (NSArray *)dataForPasteboardType:(NSString *)pasteboardType inItemSet:(NSIndexSet *)itemSet
 {
+    if (_loadResults.isEmpty())
+        return @[ ];
+
     auto values = adoptNS([[NSMutableArray alloc] init]);
     RetainPtr<WebItemProviderPasteboard> retainedSelf = self;
     [itemSet enumerateIndexesUsingBlock:[retainedSelf, pasteboardType, values] (NSUInteger index, BOOL *) {
@@ -434,6 +437,9 @@
 
 - (NSArray *)valuesForPasteboardType:(NSString *)pasteboardType inItemSet:(NSIndexSet *)itemSet
 {
+    if (_loadResults.isEmpty())
+        return @[ ];
+
     auto values = adoptNS([[NSMutableArray alloc] init]);
     RetainPtr<WebItemProviderPasteboard> retainedSelf = self;
     [itemSet enumerateIndexesUsingBlock:[retainedSelf, pasteboardType, values] (NSUInteger index, BOOL *) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to