Changeset 245806 in webkit
- Timestamp:
- May 27, 2019, 9:06:07 PM (7 years ago)
- Location:
- branches/safari-608.1.24.20-branch
- Files:
-
- 7 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/editing/WebContentReader.h (modified) (4 diffs)
-
Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (modified) (8 diffs)
-
Source/WebCore/platform/Pasteboard.h (modified) (2 diffs)
-
Source/WebCore/platform/ios/PasteboardIOS.mm (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog
r245805 r245806 1 2019-05-27 Babak Shafiei <bshafiei@apple.com> 2 3 Revert r245775. rdar://problem/35205373 4 1 5 2019-05-27 Babak Shafiei <bshafiei@apple.com> 2 6 -
branches/safari-608.1.24.20-branch/Source/WebCore/editing/WebContentReader.h
r245805 r245806 72 72 #if PLATFORM(COCOA) 73 73 bool readWebArchive(SharedBuffer&) override; 74 bool readFilePath(const String&, Optional<FloatSize> preferredPresentationSize = { }) override;75 74 bool readFilePaths(const Vector<String>&) override; 76 75 bool readHTML(const String&) override; … … 79 78 bool readImage(Ref<SharedBuffer>&&, const String& type) override; 80 79 bool readURL(const URL&, const String& title) override; 81 bool readDataBuffer(SharedBuffer&, const String& type, const String& name , Optional<FloatSize> preferredPresentationSize = { }) override;80 bool readDataBuffer(SharedBuffer&, const String& type, const String& name) override; 82 81 #endif 83 82 bool readPlainText(const String&) override; … … 96 95 #if PLATFORM(COCOA) 97 96 bool readWebArchive(SharedBuffer&) override; 98 bool readFilePath(const String&, Optional<FloatSize> = { }) override { return false; }99 97 bool readFilePaths(const Vector<String>&) override { return false; } 100 98 bool readHTML(const String&) override; … … 103 101 bool readImage(Ref<SharedBuffer>&&, const String&) override { return false; } 104 102 bool readURL(const URL&, const String&) override { return false; } 105 bool readDataBuffer(SharedBuffer&, const String&, const String& , Optional<FloatSize> = { }) override { return false; }103 bool readDataBuffer(SharedBuffer&, const String&, const String&) override { return false; } 106 104 #endif 107 105 bool readPlainText(const String&) override { return false; } -
branches/safari-608.1.24.20-branch/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
r245805 r245806 691 691 #if ENABLE(ATTACHMENT_ELEMENT) 692 692 693 static Ref<HTMLElement> attachmentForFilePath(Frame& frame, const String& path , Optional<FloatSize> preferredSize)693 static Ref<HTMLElement> attachmentForFilePath(Frame& frame, const String& path) 694 694 { 695 695 auto document = makeRef(*frame.document()); … … 719 719 image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(path))); 720 720 image->setAttachmentElement(WTFMove(attachment)); 721 if (preferredSize) {722 image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomicString::number(preferredSize->width()));723 image->setAttributeWithoutSynchronization(HTMLNames::heightAttr, AtomicString::number(preferredSize->height()));724 }725 721 return image; 726 722 } … … 730 726 } 731 727 732 static Ref<HTMLElement> attachmentForData(Frame& frame, SharedBuffer& buffer, const String& contentType, const String& name , Optional<FloatSize> preferredSize)728 static Ref<HTMLElement> attachmentForData(Frame& frame, SharedBuffer& buffer, const String& contentType, const String& name) 733 729 { 734 730 auto document = makeRef(*frame.document()); … … 757 753 image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(Blob::create(buffer, WTFMove(typeForAttachmentElement)), WTFMove(fileName)))); 758 754 image->setAttachmentElement(WTFMove(attachment)); 759 if (preferredSize) {760 image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomicString::number(preferredSize->width()));761 image->setAttributeWithoutSynchronization(HTMLNames::heightAttr, AtomicString::number(preferredSize->height()));762 }763 755 return image; 764 756 } … … 770 762 #endif // ENABLE(ATTACHMENT_ELEMENT) 771 763 772 bool WebContentReader::readFilePath (const String& path, Optional<FloatSize> preferredPresentationSize)773 { 774 if (path .isEmpty() || !frame.document())764 bool WebContentReader::readFilePaths(const Vector<String>& paths) 765 { 766 if (paths.isEmpty() || !frame.document()) 775 767 return false; 776 768 … … 780 772 781 773 #if ENABLE(ATTACHMENT_ELEMENT) 782 if (RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled()) 783 fragment->appendChild(attachmentForFilePath(frame, path, preferredPresentationSize)); 784 #endif 785 786 return true; 787 } 788 789 bool WebContentReader::readFilePaths(const Vector<String>& paths) 790 { 791 if (paths.isEmpty() || !frame.document()) 792 return false; 793 794 for (auto& path : paths) 795 readFilePath(path); 774 if (RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled()) { 775 for (auto& path : paths) 776 fragment->appendChild(attachmentForFilePath(frame, path)); 777 } 778 #endif 796 779 797 780 return true; … … 829 812 } 830 813 831 bool WebContentReader::readDataBuffer(SharedBuffer& buffer, const String& type, const String& name , Optional<FloatSize> preferredPresentationSize)814 bool WebContentReader::readDataBuffer(SharedBuffer& buffer, const String& type, const String& name) 832 815 { 833 816 if (buffer.isEmpty()) … … 845 828 846 829 #if ENABLE(ATTACHMENT_ELEMENT) 847 fragment->appendChild(attachmentForData(frame, buffer, type, name , preferredPresentationSize));830 fragment->appendChild(attachmentForData(frame, buffer, type, name)); 848 831 #else 849 832 UNUSED_PARAM(type); -
branches/safari-608.1.24.20-branch/Source/WebCore/platform/Pasteboard.h
r245805 r245806 137 137 #if PLATFORM(COCOA) 138 138 virtual bool readWebArchive(SharedBuffer&) = 0; 139 virtual bool readFilePath(const String&, Optional<FloatSize> preferredPresentationSize = { }) = 0;140 139 virtual bool readFilePaths(const Vector<String>&) = 0; 141 140 virtual bool readHTML(const String&) = 0; … … 144 143 virtual bool readImage(Ref<SharedBuffer>&&, const String& type) = 0; 145 144 virtual bool readURL(const URL&, const String& title) = 0; 146 virtual bool readDataBuffer(SharedBuffer&, const String& type, const String& name , Optional<FloatSize> preferredPresentationSize = { }) = 0;145 virtual bool readDataBuffer(SharedBuffer&, const String& type, const String& name) = 0; 147 146 #endif 148 147 virtual bool readPlainText(const String&) = 0; -
branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PasteboardIOS.mm
r245805 r245806 308 308 if (auto buffer = strategy.readBufferFromPasteboard(i, typeForFileUpload, m_pasteboardName)) { 309 309 readURLAlongsideAttachmentIfNecessary(reader, strategy, typeForFileUpload, m_pasteboardName, i); 310 reader.readDataBuffer(*buffer, typeForFileUpload, info.suggestedFileName , info.preferredPresentationSize);310 reader.readDataBuffer(*buffer, typeForFileUpload, info.suggestedFileName); 311 311 continue; 312 312 } … … 348 348 if (canReadAttachment && prefersAttachmentRepresentation(info)) { 349 349 readURLAlongsideAttachmentIfNecessary(reader, strategy, info.contentTypeForHighestFidelityItem(), m_pasteboardName, index); 350 reader.readFilePath (WTFMove(attachmentFilePath), info.preferredPresentationSize);350 reader.readFilePaths({ WTFMove(attachmentFilePath) }); 351 351 continue; 352 352 } … … 367 367 #if ENABLE(ATTACHMENT_ELEMENT) 368 368 if (canReadAttachment && result == ReaderResult::DidNotReadType) 369 reader.readFilePath (WTFMove(attachmentFilePath), info.preferredPresentationSize);369 reader.readFilePaths({ WTFMove(attachmentFilePath) }); 370 370 #endif 371 371 } -
branches/safari-608.1.24.20-branch/Tools/ChangeLog
r245805 r245806 1 2019-05-27 Babak Shafiei <bshafiei@apple.com> 2 3 Revert r245775. rdar://problem/35205373 4 1 5 2019-05-27 Babak Shafiei <bshafiei@apple.com> 2 6 -
branches/safari-608.1.24.20-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm
r245780 r245806 1632 1632 } 1633 1633 1634 TEST(WKAttachmentTestsIOS, InsertDroppedImageWithPreferredPresentationSize)1635 {1636 auto webView = webViewForTestingAttachments();1637 auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]);1638 auto item = adoptNS([[NSItemProvider alloc] init]);1639 [item registerData:testImageData() type:(__bridge NSString *)kUTTypePNG];1640 [item setPreferredPresentationSize:CGSizeMake(200, 100)];1641 [dragAndDropSimulator setExternalItemProviders:@[ item.get() ]];1642 [dragAndDropSimulator runFrom:CGPointZero to:CGPointMake(50, 50)];1643 1644 CGSize imageElementSize = [webView imageElementSize];1645 EXPECT_EQ(200, imageElementSize.width);1646 EXPECT_EQ(100, imageElementSize.height);1647 }1648 1649 1634 TEST(WKAttachmentTestsIOS, InsertDroppedAttributedStringContainingAttachment) 1650 1635 {
Note:
See TracChangeset
for help on using the changeset viewer.