Changeset 239107 in webkit
- Timestamp:
- Dec 12, 2018 9:06:49 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r239102 r239107 1 2018-12-12 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] A few API tests are failing after r239086 4 https://bugs.webkit.org/show_bug.cgi?id=192608 5 6 Reviewed by Zalan Bujtas. 7 8 These test failures were caused by a missing Vector size check in `Pasteboard::readFilePaths` before accessing 9 the first item. Fix this by adding a helper method on PasteboardItemInfo to grab the file path for the highest 10 fidelity pasteboard item (returning the null string if there are none), and use this in a few places that grab 11 the highest fidelity path using Vector::first(). 12 13 While `Pasteboard::readRespectingUTIFidelities` does have a bounds check before accessing the list of paths, 14 this patch still replaces it with a call to `pathForHighestFidelityItem()`, so that the intent is more clear. 15 16 * platform/PasteboardItemInfo.h: 17 (WebCore::PasteboardItemInfo::pathForHighestFidelityItem const): 18 * platform/ios/PasteboardIOS.mm: 19 (WebCore::Pasteboard::readRespectingUTIFidelities): 20 (WebCore::Pasteboard::readFilePaths): 21 1 22 2018-12-12 Carlos Garcia Campos <cgarcia@igalia.com> 2 23 -
trunk/Source/WebCore/platform/PasteboardItemInfo.h
r239086 r239107 56 56 } 57 57 58 String pathForHighestFidelityItem() const 59 { 60 if (pathsForFileUpload.isEmpty()) 61 return { }; 62 63 ASSERT(!pathsForFileUpload.first().isEmpty()); 64 return pathsForFileUpload.first(); 65 } 66 58 67 template<class Encoder> void encode(Encoder&) const; 59 68 template<class Decoder> static std::optional<PasteboardItemInfo> decode(Decoder&); -
trunk/Source/WebCore/platform/ios/PasteboardIOS.mm
r239086 r239107 295 295 #if ENABLE(ATTACHMENT_ELEMENT) 296 296 auto info = strategy.informationForItemAtIndex(index, m_pasteboardName); 297 bool canReadAttachment = policy == WebContentReadingPolicy::AnyType && RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled() && !info.pathsForFileUpload.isEmpty(); 297 auto attachmentFilePath = info.pathForHighestFidelityItem(); 298 bool canReadAttachment = policy == WebContentReadingPolicy::AnyType && RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled() && !attachmentFilePath.isEmpty(); 298 299 if (canReadAttachment && info.preferredPresentationStyle == PasteboardItemPresentationStyle::Attachment) { 299 reader.readFilePaths({ info.pathsForFileUpload.first() });300 reader.readFilePaths({ WTFMove(attachmentFilePath) }); 300 301 continue; 301 302 } … … 318 319 #if ENABLE(ATTACHMENT_ELEMENT) 319 320 if (canReadAttachment && result == ReaderResult::DidNotReadType) 320 reader.readFilePaths({ info.pathsForFileUpload.first() });321 reader.readFilePaths({ WTFMove(attachmentFilePath) }); 321 322 #endif 322 323 } … … 460 461 for (NSUInteger index = 0, numberOfItems = strategy.getPasteboardItemsCount(m_pasteboardName); index < numberOfItems; ++index) { 461 462 // Currently, drag and drop is the only case on iOS where the "pasteboard" may contain file paths. 462 auto filePath = strategy.informationForItemAtIndex(index, m_pasteboardName).path sForFileUpload.first();463 auto filePath = strategy.informationForItemAtIndex(index, m_pasteboardName).pathForHighestFidelityItem(); 463 464 if (!filePath.isEmpty()) 464 465 filePaths.append(WTFMove(filePath));
Note: See TracChangeset
for help on using the changeset viewer.