Changeset 245805 in webkit
- Timestamp:
- May 27, 2019, 9:06:02 PM (7 years ago)
- Location:
- branches/safari-608.1.24.20-branch
- Files:
-
- 13 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/editing/WebContentReader.h (modified) (2 diffs)
-
Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (modified) (3 diffs)
-
Source/WebCore/editing/gtk/EditorGtk.cpp (modified) (1 diff)
-
Source/WebCore/editing/markup.cpp (modified) (1 diff)
-
Source/WebCore/editing/markup.h (modified) (1 diff)
-
Source/WebCore/platform/Pasteboard.h (modified) (2 diffs)
-
Source/WebCore/platform/PasteboardItemInfo.h (modified) (3 diffs)
-
Source/WebCore/platform/ios/PasteboardIOS.mm (modified) (4 diffs)
-
Source/WebCore/platform/ios/PlatformPasteboardIOS.mm (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog
r245782 r245805 1 2019-05-27 Babak Shafiei <bshafiei@apple.com> 2 3 Revert r245637. rdar://problem/35205373 4 1 5 2019-05-26 Babak Shafiei <bshafiei@apple.com> 2 6 -
branches/safari-608.1.24.20-branch/Source/WebCore/editing/WebContentReader.h
r245782 r245805 77 77 bool readRTFD(SharedBuffer&) override; 78 78 bool readRTF(SharedBuffer&) override; 79 bool readImage(Ref<SharedBuffer>&&, const String& type , Optional<FloatSize> preferredPresentationSize = { }) override;79 bool readImage(Ref<SharedBuffer>&&, const String& type) override; 80 80 bool readURL(const URL&, const String& title) override; 81 81 bool readDataBuffer(SharedBuffer&, const String& type, const String& name, Optional<FloatSize> preferredPresentationSize = { }) override; … … 101 101 bool readRTFD(SharedBuffer&) override; 102 102 bool readRTF(SharedBuffer&) override; 103 bool readImage(Ref<SharedBuffer>&&, const String& , Optional<FloatSize> = { }) override { return false; }103 bool readImage(Ref<SharedBuffer>&&, const String&) override { return false; } 104 104 bool readURL(const URL&, const String&) override { return false; } 105 105 bool readDataBuffer(SharedBuffer&, const String&, const String&, Optional<FloatSize> = { }) override { return false; } -
branches/safari-608.1.24.20-branch/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
r245782 r245805 247 247 #endif 248 248 249 static Ref<DocumentFragment> createFragmentForImageAttachment(Frame& frame, Document& document, Ref<SharedBuffer>&& buffer, const String& contentType , Optional<FloatSize> preferredSize)249 static Ref<DocumentFragment> createFragmentForImageAttachment(Frame& frame, Document& document, Ref<SharedBuffer>&& buffer, const String& contentType) 250 250 { 251 251 #if ENABLE(ATTACHMENT_ELEMENT) … … 261 261 image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, Blob::create(buffer.get(), contentType))); 262 262 image->setAttachmentElement(WTFMove(attachment)); 263 if (preferredSize) {264 image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomicString::number(preferredSize->width()));265 image->setAttributeWithoutSynchronization(HTMLNames::heightAttr, AtomicString::number(preferredSize->height()));266 }267 263 fragment->appendChild(WTFMove(image)); 268 264 } else { … … 681 677 } 682 678 683 bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type , Optional<FloatSize> preferredPresentationSize)679 bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type) 684 680 { 685 681 ASSERT(frame.document()); 686 682 auto& document = *frame.document(); 687 683 if (shouldReplaceRichContentWithAttachments()) 688 addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type , preferredPresentationSize));684 addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type)); 689 685 else 690 addFragment(createFragmentForImageAndURL(document, DOMURL::createObjectURL(document, Blob::create(buffer.get(), type)) , preferredPresentationSize));686 addFragment(createFragmentForImageAndURL(document, DOMURL::createObjectURL(document, Blob::create(buffer.get(), type)))); 691 687 692 688 return fragment; -
branches/safari-608.1.24.20-branch/Source/WebCore/editing/gtk/EditorGtk.cpp
r245782 r245805 70 70 if (!frame.document()) 71 71 return nullptr; 72 return createFragmentForImageAndURL(*frame.document(), DOMURL::createObjectURL(*frame.document(), blob) , { });72 return createFragmentForImageAndURL(*frame.document(), DOMURL::createObjectURL(*frame.document(), blob)); 73 73 } 74 74 } -
branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.cpp
r245782 r245805 1227 1227 } 1228 1228 1229 Ref<DocumentFragment> createFragmentForImageAndURL(Document& document, const String& url , Optional<FloatSize> preferredSize)1229 Ref<DocumentFragment> createFragmentForImageAndURL(Document& document, const String& url) 1230 1230 { 1231 1231 auto imageElement = HTMLImageElement::create(document); 1232 1232 imageElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, url); 1233 if (preferredSize) {1234 imageElement->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomicString::number(preferredSize->width()));1235 imageElement->setAttributeWithoutSynchronization(HTMLNames::heightAttr, AtomicString::number(preferredSize->height()));1236 }1237 1233 1238 1234 auto fragment = document.createDocumentFragment(); -
branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.h
r245782 r245805 60 60 ExceptionOr<Ref<DocumentFragment>> createFragmentForInnerOuterHTML(Element&, const String& markup, ParserContentPolicy); 61 61 RefPtr<DocumentFragment> createFragmentForTransformToFragment(Document&, const String& sourceString, const String& sourceMIMEType); 62 Ref<DocumentFragment> createFragmentForImageAndURL(Document&, const String& , Optional<FloatSize> preferredSize);62 Ref<DocumentFragment> createFragmentForImageAndURL(Document&, const String&); 63 63 ExceptionOr<Ref<DocumentFragment>> createContextualFragment(Element&, const String& markup, ParserContentPolicy); 64 64 -
branches/safari-608.1.24.20-branch/Source/WebCore/platform/Pasteboard.h
r245782 r245805 142 142 virtual bool readRTFD(SharedBuffer&) = 0; 143 143 virtual bool readRTF(SharedBuffer&) = 0; 144 virtual bool readImage(Ref<SharedBuffer>&&, const String& type , Optional<FloatSize> preferredPresentationSize = { }) = 0;144 virtual bool readImage(Ref<SharedBuffer>&&, const String& type) = 0; 145 145 virtual bool readURL(const URL&, const String& title) = 0; 146 146 virtual bool readDataBuffer(SharedBuffer&, const String& type, const String& name, Optional<FloatSize> preferredPresentationSize = { }) = 0; … … 290 290 PasteboardWasChangedExternally 291 291 }; 292 ReaderResult readPasteboardWebContentDataForType(PasteboardWebContentReader&, PasteboardStrategy&, NSString *type, const PasteboardItemInfo&,int itemIndex);292 ReaderResult readPasteboardWebContentDataForType(PasteboardWebContentReader&, PasteboardStrategy&, NSString *type, int itemIndex); 293 293 #endif 294 294 -
branches/safari-608.1.24.20-branch/Source/WebCore/platform/PasteboardItemInfo.h
r245782 r245805 43 43 Vector<String> contentTypesByFidelity; 44 44 String suggestedFileName; 45 Optional<FloatSize> preferredPresentationSize;46 45 bool isNonTextType { false }; 47 46 bool containsFileURLAndFileUploadContent { false }; … … 99 98 void PasteboardItemInfo::encode(Encoder& encoder) const 100 99 { 101 encoder << pathsForFileUpload << contentTypesForFileUpload << contentTypesByFidelity << suggestedFileName << preferredPresentationSize <<isNonTextType << containsFileURLAndFileUploadContent;100 encoder << pathsForFileUpload << contentTypesForFileUpload << contentTypesByFidelity << suggestedFileName << isNonTextType << containsFileURLAndFileUploadContent; 102 101 encoder.encodeEnum(preferredPresentationStyle); 103 102 } … … 117 116 118 117 if (!decoder.decode(result.suggestedFileName)) 119 return WTF::nullopt;120 121 if (!decoder.decode(result.preferredPresentationSize))122 118 return WTF::nullopt; 123 119 -
branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PasteboardIOS.mm
r245782 r245805 182 182 } 183 183 184 Pasteboard::ReaderResult Pasteboard::readPasteboardWebContentDataForType(PasteboardWebContentReader& reader, PasteboardStrategy& strategy, NSString *type, const PasteboardItemInfo& itemInfo,int itemIndex)184 Pasteboard::ReaderResult Pasteboard::readPasteboardWebContentDataForType(PasteboardWebContentReader& reader, PasteboardStrategy& strategy, NSString *type, int itemIndex) 185 185 { 186 186 if ([type isEqualToString:WebArchivePboardType] || [type isEqualToString:(__bridge NSString *)kUTTypeWebArchive]) { … … 226 226 if (m_changeCount != changeCount()) 227 227 return ReaderResult::PasteboardWasChangedExternally; 228 return buffer && reader.readImage(buffer.releaseNonNull(), type , itemInfo.preferredPresentationSize) ? ReaderResult::ReadType : ReaderResult::DidNotReadType;228 return buffer && reader.readImage(buffer.releaseNonNull(), type) ? ReaderResult::ReadType : ReaderResult::DidNotReadType; 229 229 } 230 230 … … 319 319 continue; 320 320 321 auto itemResult = readPasteboardWebContentDataForType(reader, strategy, type, i nfo, i);321 auto itemResult = readPasteboardWebContentDataForType(reader, strategy, type, i); 322 322 if (itemResult == ReaderResult::PasteboardWasChangedExternally) 323 323 return; … … 359 359 continue; 360 360 361 result = readPasteboardWebContentDataForType(reader, strategy, type, in fo, index);361 result = readPasteboardWebContentDataForType(reader, strategy, type, index); 362 362 if (result == ReaderResult::PasteboardWasChangedExternally) 363 363 return; -
branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
r245782 r245805 156 156 info.preferredPresentationStyle = pasteboardItemPresentationStyle(itemProvider.preferredPresentationStyle); 157 157 #endif 158 if (!CGSizeEqualToSize(itemProvider.preferredPresentationSize, CGSizeZero))159 info.preferredPresentationSize = FloatSize { itemProvider.preferredPresentationSize };160 158 info.containsFileURLAndFileUploadContent = itemProvider.web_containsFileURLAndFileUploadContent; 161 159 info.suggestedFileName = itemProvider.suggestedName; -
branches/safari-608.1.24.20-branch/Source/WebKit/ChangeLog
r245804 r245805 1 2019-05-27 Babak Shafiei <bshafiei@apple.com> 2 3 Revert r245637. rdar://problem/35205373 4 1 5 2019-05-27 Babak Shafiei <bshafiei@apple.com> 2 6 -
branches/safari-608.1.24.20-branch/Tools/ChangeLog
r245804 r245805 1 2019-05-27 Babak Shafiei <bshafiei@apple.com> 2 3 Revert r245637. 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/ios/UIPasteboardTests.mm
r245782 r245805 303 303 } 304 304 305 TEST(UIPasteboardTests, ValidPreferredPresentationSizeForImage)306 {307 auto webView = setUpWebViewForPasteboardTests(@"autofocus-contenteditable");308 auto itemProvider = adoptNS([[NSItemProvider alloc] init]);309 [itemProvider setPreferredPresentationSize:CGSizeMake(10, 20)];310 [itemProvider registerDataRepresentationForTypeIdentifier:(__bridge NSString *)kUTTypePNG visibility:NSItemProviderRepresentationVisibilityAll loadHandler:[] (DataLoadCompletionBlock completionHandler) -> NSProgress * {311 completionHandler([NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"icon" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"]], nil);312 return nil;313 }];314 [UIPasteboard generalPasteboard].itemProviders = @[ itemProvider.get() ];315 [webView paste:nil];316 317 EXPECT_WK_STREQ("10", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').width"]);318 EXPECT_WK_STREQ("20", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').height"]);319 }320 321 TEST(UIPasteboardTests, InvalidPreferredPresentationSizeForImage)322 {323 auto webView = setUpWebViewForPasteboardTests(@"autofocus-contenteditable");324 auto itemProvider = adoptNS([[NSItemProvider alloc] init]);325 [itemProvider setPreferredPresentationSize:CGSizeMake(-10, -20)];326 [itemProvider registerDataRepresentationForTypeIdentifier:(__bridge NSString *)kUTTypePNG visibility:NSItemProviderRepresentationVisibilityAll loadHandler:[] (DataLoadCompletionBlock completionHandler) -> NSProgress * {327 completionHandler([NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"icon" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"]], nil);328 return nil;329 }];330 [UIPasteboard generalPasteboard].itemProviders = @[ itemProvider.get() ];331 [webView paste:nil];332 333 EXPECT_WK_STREQ("0", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').width"]);334 EXPECT_WK_STREQ("174", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').height"]);335 }336 337 TEST(UIPasteboardTests, MissingPreferredPresentationSizeForImage)338 {339 auto webView = setUpWebViewForPasteboardTests(@"autofocus-contenteditable");340 auto itemProvider = adoptNS([[NSItemProvider alloc] init]);341 [itemProvider registerDataRepresentationForTypeIdentifier:(__bridge NSString *)kUTTypePNG visibility:NSItemProviderRepresentationVisibilityAll loadHandler:[] (DataLoadCompletionBlock completionHandler) -> NSProgress * {342 completionHandler([NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"icon" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"]], nil);343 return nil;344 }];345 [UIPasteboard generalPasteboard].itemProviders = @[ itemProvider.get() ];346 [webView paste:nil];347 348 EXPECT_WK_STREQ("0", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').width"]);349 EXPECT_WK_STREQ("174", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').height"]);350 }351 305 #endif // PLATFORM(IOS) 352 306
Note:
See TracChangeset
for help on using the changeset viewer.