⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245805 in webkit


Ignore:
Timestamp:
May 27, 2019, 9:06:02 PM (7 years ago)
Author:
bshafiei@apple.com
Message:

Revert r245637. rdar://problem/35205373

Location:
branches/safari-608.1.24.20-branch
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog

    r245782 r245805  
     12019-05-27  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Revert r245637. rdar://problem/35205373
     4
    152019-05-26  Babak Shafiei  <bshafiei@apple.com>
    26
  • branches/safari-608.1.24.20-branch/Source/WebCore/editing/WebContentReader.h

    r245782 r245805  
    7777    bool readRTFD(SharedBuffer&) override;
    7878    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;
    8080    bool readURL(const URL&, const String& title) override;
    8181    bool readDataBuffer(SharedBuffer&, const String& type, const String& name, Optional<FloatSize> preferredPresentationSize = { }) override;
    … …  
    101101    bool readRTFD(SharedBuffer&) override;
    102102    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; }
    104104    bool readURL(const URL&, const String&) override { return false; }
    105105    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  
    247247#endif
    248248
    249 static Ref<DocumentFragment> createFragmentForImageAttachment(Frame& frame, Document& document, Ref<SharedBuffer>&& buffer, const String& contentType, Optional<FloatSize> preferredSize)
     249static Ref<DocumentFragment> createFragmentForImageAttachment(Frame& frame, Document& document, Ref<SharedBuffer>&& buffer, const String& contentType)
    250250{
    251251#if ENABLE(ATTACHMENT_ELEMENT)
    … …  
    261261            image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, Blob::create(buffer.get(), contentType)));
    262262            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             }
    267263            fragment->appendChild(WTFMove(image));
    268264        } else {
    … …  
    681677}
    682678
    683 bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type, Optional<FloatSize> preferredPresentationSize)
     679bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type)
    684680{
    685681    ASSERT(frame.document());
    686682    auto& document = *frame.document();
    687683    if (shouldReplaceRichContentWithAttachments())
    688         addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type, preferredPresentationSize));
     684        addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type));
    689685    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))));
    691687
    692688    return fragment;
  • branches/safari-608.1.24.20-branch/Source/WebCore/editing/gtk/EditorGtk.cpp

    r245782 r245805  
    7070            if (!frame.document())
    7171                return nullptr;
    72             return createFragmentForImageAndURL(*frame.document(), DOMURL::createObjectURL(*frame.document(), blob), { });
     72            return createFragmentForImageAndURL(*frame.document(), DOMURL::createObjectURL(*frame.document(), blob));
    7373        }
    7474    }
  • branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.cpp

    r245782 r245805  
    12271227}
    12281228
    1229 Ref<DocumentFragment> createFragmentForImageAndURL(Document& document, const String& url, Optional<FloatSize> preferredSize)
     1229Ref<DocumentFragment> createFragmentForImageAndURL(Document& document, const String& url)
    12301230{
    12311231    auto imageElement = HTMLImageElement::create(document);
    12321232    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     }
    12371233
    12381234    auto fragment = document.createDocumentFragment();
  • branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.h

    r245782 r245805  
    6060ExceptionOr<Ref<DocumentFragment>> createFragmentForInnerOuterHTML(Element&, const String& markup, ParserContentPolicy);
    6161RefPtr<DocumentFragment> createFragmentForTransformToFragment(Document&, const String& sourceString, const String& sourceMIMEType);
    62 Ref<DocumentFragment> createFragmentForImageAndURL(Document&, const String&, Optional<FloatSize> preferredSize);
     62Ref<DocumentFragment> createFragmentForImageAndURL(Document&, const String&);
    6363ExceptionOr<Ref<DocumentFragment>> createContextualFragment(Element&, const String& markup, ParserContentPolicy);
    6464
  • branches/safari-608.1.24.20-branch/Source/WebCore/platform/Pasteboard.h

    r245782 r245805  
    142142    virtual bool readRTFD(SharedBuffer&) = 0;
    143143    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;
    145145    virtual bool readURL(const URL&, const String& title) = 0;
    146146    virtual bool readDataBuffer(SharedBuffer&, const String& type, const String& name, Optional<FloatSize> preferredPresentationSize = { }) = 0;
    … …  
    290290        PasteboardWasChangedExternally
    291291    };
    292     ReaderResult readPasteboardWebContentDataForType(PasteboardWebContentReader&, PasteboardStrategy&, NSString *type, const PasteboardItemInfo&, int itemIndex);
     292    ReaderResult readPasteboardWebContentDataForType(PasteboardWebContentReader&, PasteboardStrategy&, NSString *type, int itemIndex);
    293293#endif
    294294
  • branches/safari-608.1.24.20-branch/Source/WebCore/platform/PasteboardItemInfo.h

    r245782 r245805  
    4343    Vector<String> contentTypesByFidelity;
    4444    String suggestedFileName;
    45     Optional<FloatSize> preferredPresentationSize;
    4645    bool isNonTextType { false };
    4746    bool containsFileURLAndFileUploadContent { false };
    … …  
    9998void PasteboardItemInfo::encode(Encoder& encoder) const
    10099{
    101     encoder << pathsForFileUpload << contentTypesForFileUpload << contentTypesByFidelity << suggestedFileName << preferredPresentationSize << isNonTextType << containsFileURLAndFileUploadContent;
     100    encoder << pathsForFileUpload << contentTypesForFileUpload << contentTypesByFidelity << suggestedFileName << isNonTextType << containsFileURLAndFileUploadContent;
    102101    encoder.encodeEnum(preferredPresentationStyle);
    103102}
    … …  
    117116
    118117    if (!decoder.decode(result.suggestedFileName))
    119         return WTF::nullopt;
    120 
    121     if (!decoder.decode(result.preferredPresentationSize))
    122118        return WTF::nullopt;
    123119
  • branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PasteboardIOS.mm

    r245782 r245805  
    182182}
    183183
    184 Pasteboard::ReaderResult Pasteboard::readPasteboardWebContentDataForType(PasteboardWebContentReader& reader, PasteboardStrategy& strategy, NSString *type, const PasteboardItemInfo& itemInfo, int itemIndex)
     184Pasteboard::ReaderResult Pasteboard::readPasteboardWebContentDataForType(PasteboardWebContentReader& reader, PasteboardStrategy& strategy, NSString *type, int itemIndex)
    185185{
    186186    if ([type isEqualToString:WebArchivePboardType] || [type isEqualToString:(__bridge NSString *)kUTTypeWebArchive]) {
    … …  
    226226        if (m_changeCount != changeCount())
    227227            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;
    229229    }
    230230
    … …  
    319319                continue;
    320320
    321             auto itemResult = readPasteboardWebContentDataForType(reader, strategy, type, info, i);
     321            auto itemResult = readPasteboardWebContentDataForType(reader, strategy, type, i);
    322322            if (itemResult == ReaderResult::PasteboardWasChangedExternally)
    323323                return;
    … …  
    359359                continue;
    360360
    361             result = readPasteboardWebContentDataForType(reader, strategy, type, info, index);
     361            result = readPasteboardWebContentDataForType(reader, strategy, type, index);
    362362            if (result == ReaderResult::PasteboardWasChangedExternally)
    363363                return;
  • branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm

    r245782 r245805  
    156156    info.preferredPresentationStyle = pasteboardItemPresentationStyle(itemProvider.preferredPresentationStyle);
    157157#endif
    158     if (!CGSizeEqualToSize(itemProvider.preferredPresentationSize, CGSizeZero))
    159         info.preferredPresentationSize = FloatSize { itemProvider.preferredPresentationSize };
    160158    info.containsFileURLAndFileUploadContent = itemProvider.web_containsFileURLAndFileUploadContent;
    161159    info.suggestedFileName = itemProvider.suggestedName;
  • branches/safari-608.1.24.20-branch/Source/WebKit/ChangeLog

    r245804 r245805  
     12019-05-27  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Revert r245637. rdar://problem/35205373
     4
    152019-05-27  Babak Shafiei  <bshafiei@apple.com>
    26
  • branches/safari-608.1.24.20-branch/Tools/ChangeLog

    r245804 r245805  
     12019-05-27  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Revert r245637. rdar://problem/35205373
     4
    152019-05-27  Babak Shafiei  <bshafiei@apple.com>
    26
  • branches/safari-608.1.24.20-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm

    r245782 r245805  
    303303}
    304304
    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 }
    351305#endif // PLATFORM(IOS)
    352306
Note: See TracChangeset for help on using the changeset viewer.