<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[245782] branches/safari-608.1.24.20-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/245782">245782</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2019-05-26 12:05:26 -0700 (Sun, 26 May 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/245637">r245637</a>. rdar://problem/35205373

    [Paste] Add support for preferred presentation size when pasting an image
    https://bugs.webkit.org/show_bug.cgi?id=198132
    <rdar://problem/50886917>

    Reviewed by Wenson Hsieh.

    Source/WebCore:

    Set the pasted <img> width/height attributes when the preferred presentation size is available.

    * editing/WebContentReader.h:
    * editing/cocoa/WebContentReaderCocoa.mm:
    (WebCore::createFragmentForImageAttachment):
    (WebCore::WebContentReader::readImage):
    * editing/markup.cpp:
    (WebCore::createFragmentForImageAndURL):
    * editing/markup.h:
    * platform/Pasteboard.h:
    (WebCore::PasteboardWebContentReader::readImage):
    * platform/PasteboardItemInfo.h:
    (WebCore::PasteboardItemInfo::encode const):
    (WebCore::PasteboardItemInfo::decode):
    * platform/ios/PasteboardIOS.mm:
    (WebCore::Pasteboard::readPasteboardWebContentDataForType):
    (WebCore::Pasteboard::read):
    (WebCore::Pasteboard::readRespectingUTIFidelities):
    * platform/ios/PlatformPasteboardIOS.mm:
    (WebCore::PlatformPasteboard::informationForItemAtIndex):

    Source/WebKit:

    * UIProcess/API/Cocoa/_WKElementAction.mm:
    (addToReadingList):
    * UIProcess/ios/WKActionSheetAssistant.mm:
    (-[WKActionSheetAssistant defaultActionsForLinkSheet:]):
    (-[WKActionSheetAssistant defaultActionsForImageSheet:]):

    Tools:

    * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
    (TestWebKitAPI::TEST):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245637 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari60812420branchSourceWebCoreChangeLog">branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari60812420branchSourceWebCoreeditingWebContentReaderh">branches/safari-608.1.24.20-branch/Source/WebCore/editing/WebContentReader.h</a></li>
<li><a href="#branchessafari60812420branchSourceWebCoreeditingcocoaWebContentReaderCocoamm">branches/safari-608.1.24.20-branch/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm</a></li>
<li><a href="#branchessafari60812420branchSourceWebCoreeditinggtkEditorGtkcpp">branches/safari-608.1.24.20-branch/Source/WebCore/editing/gtk/EditorGtk.cpp</a></li>
<li><a href="#branchessafari60812420branchSourceWebCoreeditingmarkupcpp">branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.cpp</a></li>
<li><a href="#branchessafari60812420branchSourceWebCoreeditingmarkuph">branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.h</a></li>
<li><a href="#branchessafari60812420branchSourceWebCoreplatformPasteboardh">branches/safari-608.1.24.20-branch/Source/WebCore/platform/Pasteboard.h</a></li>
<li><a href="#branchessafari60812420branchSourceWebCoreplatformPasteboardItemInfoh">branches/safari-608.1.24.20-branch/Source/WebCore/platform/PasteboardItemInfo.h</a></li>
<li><a href="#branchessafari60812420branchSourceWebCoreplatformiosPasteboardIOSmm">branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PasteboardIOS.mm</a></li>
<li><a href="#branchessafari60812420branchSourceWebCoreplatformiosPlatformPasteboardIOSmm">branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm</a></li>
<li><a href="#branchessafari60812420branchSourceWebKitChangeLog">branches/safari-608.1.24.20-branch/Source/WebKit/ChangeLog</a></li>
<li><a href="#branchessafari60812420branchToolsChangeLog">branches/safari-608.1.24.20-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari60812420branchToolsTestWebKitAPITestsiosUIPasteboardTestsmm">branches/safari-608.1.24.20-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari60812420branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog      2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog 2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -1,5 +1,83 @@
</span><span class="cx"> 2019-05-26  Babak Shafiei  <bshafiei@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r245637. rdar://problem/35205373
+
+    [Paste] Add support for preferred presentation size when pasting an image
+    https://bugs.webkit.org/show_bug.cgi?id=198132
+    <rdar://problem/50886917>
+    
+    Reviewed by Wenson Hsieh.
+    
+    Source/WebCore:
+    
+    Set the pasted <img> width/height attributes when the preferred presentation size is available.
+    
+    * editing/WebContentReader.h:
+    * editing/cocoa/WebContentReaderCocoa.mm:
+    (WebCore::createFragmentForImageAttachment):
+    (WebCore::WebContentReader::readImage):
+    * editing/markup.cpp:
+    (WebCore::createFragmentForImageAndURL):
+    * editing/markup.h:
+    * platform/Pasteboard.h:
+    (WebCore::PasteboardWebContentReader::readImage):
+    * platform/PasteboardItemInfo.h:
+    (WebCore::PasteboardItemInfo::encode const):
+    (WebCore::PasteboardItemInfo::decode):
+    * platform/ios/PasteboardIOS.mm:
+    (WebCore::Pasteboard::readPasteboardWebContentDataForType):
+    (WebCore::Pasteboard::read):
+    (WebCore::Pasteboard::readRespectingUTIFidelities):
+    * platform/ios/PlatformPasteboardIOS.mm:
+    (WebCore::PlatformPasteboard::informationForItemAtIndex):
+    
+    Source/WebKit:
+    
+    * UIProcess/API/Cocoa/_WKElementAction.mm:
+    (addToReadingList):
+    * UIProcess/ios/WKActionSheetAssistant.mm:
+    (-[WKActionSheetAssistant defaultActionsForLinkSheet:]):
+    (-[WKActionSheetAssistant defaultActionsForImageSheet:]):
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245637 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-05-22  Zalan Bujtas  <zalan@apple.com>
+
+            [Paste] Add support for preferred presentation size when pasting an image
+            https://bugs.webkit.org/show_bug.cgi?id=198132
+            <rdar://problem/50886917>
+
+            Reviewed by Wenson Hsieh.
+
+            Set the pasted <img> width/height attributes when the preferred presentation size is available.
+
+            * editing/WebContentReader.h:
+            * editing/cocoa/WebContentReaderCocoa.mm:
+            (WebCore::createFragmentForImageAttachment):
+            (WebCore::WebContentReader::readImage):
+            * editing/markup.cpp:
+            (WebCore::createFragmentForImageAndURL):
+            * editing/markup.h:
+            * platform/Pasteboard.h:
+            (WebCore::PasteboardWebContentReader::readImage):
+            * platform/PasteboardItemInfo.h:
+            (WebCore::PasteboardItemInfo::encode const):
+            (WebCore::PasteboardItemInfo::decode):
+            * platform/ios/PasteboardIOS.mm:
+            (WebCore::Pasteboard::readPasteboardWebContentDataForType):
+            (WebCore::Pasteboard::read):
+            (WebCore::Pasteboard::readRespectingUTIFidelities):
+            * platform/ios/PlatformPasteboardIOS.mm:
+            (WebCore::PlatformPasteboard::informationForItemAtIndex):
+
+2019-05-26  Babak Shafiei  <bshafiei@apple.com>
+
</ins><span class="cx">         Cherry-pick r245778. rdar://problem/35205373
</span><span class="cx"> 
</span><span class="cx">     [iOS] Dropped text, attachments, and images should animate into place
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCoreeditingWebContentReaderh"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/editing/WebContentReader.h (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/editing/WebContentReader.h     2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/editing/WebContentReader.h        2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">     bool readHTML(const String&) override;
</span><span class="cx">     bool readRTFD(SharedBuffer&) override;
</span><span class="cx">     bool readRTF(SharedBuffer&) override;
</span><del>-    bool readImage(Ref<SharedBuffer>&&, const String& type) override;
</del><ins>+    bool readImage(Ref<SharedBuffer>&&, const String& type, Optional<FloatSize> preferredPresentationSize = { }) override;
</ins><span class="cx">     bool readURL(const URL&, const String& title) override;
</span><span class="cx">     bool readDataBuffer(SharedBuffer&, const String& type, const String& name, Optional<FloatSize> preferredPresentationSize = { }) override;
</span><span class="cx"> #endif
</span><span class="lines">@@ -100,7 +100,7 @@
</span><span class="cx">     bool readHTML(const String&) override;
</span><span class="cx">     bool readRTFD(SharedBuffer&) override;
</span><span class="cx">     bool readRTF(SharedBuffer&) override;
</span><del>-    bool readImage(Ref<SharedBuffer>&&, const String&) override { return false; }
</del><ins>+    bool readImage(Ref<SharedBuffer>&&, const String&, Optional<FloatSize> = { }) override { return false; }
</ins><span class="cx">     bool readURL(const URL&, const String&) override { return false; }
</span><span class="cx">     bool readDataBuffer(SharedBuffer&, const String&, const String&, Optional<FloatSize> = { }) override { return false; }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCoreeditingcocoaWebContentReaderCocoamm"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm    2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -246,7 +246,7 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-static Ref<DocumentFragment> createFragmentForImageAttachment(Frame& frame, Document& document, Ref<SharedBuffer>&& buffer, const String& contentType)
</del><ins>+static Ref<DocumentFragment> createFragmentForImageAttachment(Frame& frame, Document& document, Ref<SharedBuffer>&& buffer, const String& contentType, Optional<FloatSize> preferredSize)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(ATTACHMENT_ELEMENT)
</span><span class="cx">     auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document);
</span><span class="lines">@@ -260,6 +260,10 @@
</span><span class="cx">             auto image = HTMLImageElement::create(document);
</span><span class="cx">             image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, Blob::create(buffer.get(), contentType)));
</span><span class="cx">             image->setAttachmentElement(WTFMove(attachment));
</span><ins>+            if (preferredSize) {
+                image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomicString::number(preferredSize->width()));
+                image->setAttributeWithoutSynchronization(HTMLNames::heightAttr, AtomicString::number(preferredSize->height()));
+            }
</ins><span class="cx">             fragment->appendChild(WTFMove(image));
</span><span class="cx">         } else {
</span><span class="cx">             attachment->updateAttributes(buffer->size(), contentType, defaultImageAttachmentName);
</span><span class="lines">@@ -676,14 +680,14 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type)
</del><ins>+bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type, Optional<FloatSize> preferredPresentationSize)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(frame.document());
</span><span class="cx">     auto& document = *frame.document();
</span><span class="cx">     if (shouldReplaceRichContentWithAttachments())
</span><del>-        addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type));
</del><ins>+        addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type, preferredPresentationSize));
</ins><span class="cx">     else
</span><del>-        addFragment(createFragmentForImageAndURL(document, DOMURL::createObjectURL(document, Blob::create(buffer.get(), type))));
</del><ins>+        addFragment(createFragmentForImageAndURL(document, DOMURL::createObjectURL(document, Blob::create(buffer.get(), type)), preferredPresentationSize));
</ins><span class="cx"> 
</span><span class="cx">     return fragment;
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCoreeditinggtkEditorGtkcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/editing/gtk/EditorGtk.cpp (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/editing/gtk/EditorGtk.cpp      2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/editing/gtk/EditorGtk.cpp 2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">             auto blob = Blob::create(WTFMove(buffer), "image/png");
</span><span class="cx">             if (!frame.document())
</span><span class="cx">                 return nullptr;
</span><del>-            return createFragmentForImageAndURL(*frame.document(), DOMURL::createObjectURL(*frame.document(), blob));
</del><ins>+            return createFragmentForImageAndURL(*frame.document(), DOMURL::createObjectURL(*frame.document(), blob), { });
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCoreeditingmarkupcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.cpp (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.cpp     2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.cpp        2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -1226,10 +1226,14 @@
</span><span class="cx">     return fragment;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref<DocumentFragment> createFragmentForImageAndURL(Document& document, const String& url)
</del><ins>+Ref<DocumentFragment> createFragmentForImageAndURL(Document& document, const String& url, Optional<FloatSize> preferredSize)
</ins><span class="cx"> {
</span><span class="cx">     auto imageElement = HTMLImageElement::create(document);
</span><span class="cx">     imageElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, url);
</span><ins>+    if (preferredSize) {
+        imageElement->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomicString::number(preferredSize->width()));
+        imageElement->setAttributeWithoutSynchronization(HTMLNames::heightAttr, AtomicString::number(preferredSize->height()));
+    }
</ins><span class="cx"> 
</span><span class="cx">     auto fragment = document.createDocumentFragment();
</span><span class="cx">     fragment->appendChild(imageElement);
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCoreeditingmarkuph"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.h (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.h       2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/editing/markup.h  2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> WEBCORE_EXPORT Ref<DocumentFragment> createFragmentFromMarkup(Document&, const String& markup, const String& baseURL, ParserContentPolicy = AllowScriptingContent);
</span><span class="cx"> ExceptionOr<Ref<DocumentFragment>> createFragmentForInnerOuterHTML(Element&, const String& markup, ParserContentPolicy);
</span><span class="cx"> RefPtr<DocumentFragment> createFragmentForTransformToFragment(Document&, const String& sourceString, const String& sourceMIMEType);
</span><del>-Ref<DocumentFragment> createFragmentForImageAndURL(Document&, const String&);
</del><ins>+Ref<DocumentFragment> createFragmentForImageAndURL(Document&, const String&, Optional<FloatSize> preferredSize);
</ins><span class="cx"> ExceptionOr<Ref<DocumentFragment>> createContextualFragment(Element&, const String& markup, ParserContentPolicy);
</span><span class="cx"> 
</span><span class="cx"> bool isPlainTextMarkup(Node*);
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCoreplatformPasteboardh"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/platform/Pasteboard.h (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/platform/Pasteboard.h  2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/platform/Pasteboard.h     2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -141,7 +141,7 @@
</span><span class="cx">     virtual bool readHTML(const String&) = 0;
</span><span class="cx">     virtual bool readRTFD(SharedBuffer&) = 0;
</span><span class="cx">     virtual bool readRTF(SharedBuffer&) = 0;
</span><del>-    virtual bool readImage(Ref<SharedBuffer>&&, const String& type) = 0;
</del><ins>+    virtual bool readImage(Ref<SharedBuffer>&&, const String& type, Optional<FloatSize> preferredPresentationSize = { }) = 0;
</ins><span class="cx">     virtual bool readURL(const URL&, const String& title) = 0;
</span><span class="cx">     virtual bool readDataBuffer(SharedBuffer&, const String& type, const String& name, Optional<FloatSize> preferredPresentationSize = { }) = 0;
</span><span class="cx"> #endif
</span><span class="lines">@@ -289,7 +289,7 @@
</span><span class="cx">         DidNotReadType,
</span><span class="cx">         PasteboardWasChangedExternally
</span><span class="cx">     };
</span><del>-    ReaderResult readPasteboardWebContentDataForType(PasteboardWebContentReader&, PasteboardStrategy&, NSString *type, int itemIndex);
</del><ins>+    ReaderResult readPasteboardWebContentDataForType(PasteboardWebContentReader&, PasteboardStrategy&, NSString *type, const PasteboardItemInfo&, int itemIndex);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(WIN)
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCoreplatformPasteboardItemInfoh"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/platform/PasteboardItemInfo.h (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/platform/PasteboardItemInfo.h  2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/platform/PasteboardItemInfo.h     2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx">     Vector<String> contentTypesForFileUpload;
</span><span class="cx">     Vector<String> contentTypesByFidelity;
</span><span class="cx">     String suggestedFileName;
</span><ins>+    Optional<FloatSize> preferredPresentationSize;
</ins><span class="cx">     bool isNonTextType { false };
</span><span class="cx">     bool containsFileURLAndFileUploadContent { false };
</span><span class="cx">     PasteboardItemPresentationStyle preferredPresentationStyle { PasteboardItemPresentationStyle::Unspecified };
</span><span class="lines">@@ -97,7 +98,7 @@
</span><span class="cx"> template<class Encoder>
</span><span class="cx"> void PasteboardItemInfo::encode(Encoder& encoder) const
</span><span class="cx"> {
</span><del>-    encoder << pathsForFileUpload << contentTypesForFileUpload << contentTypesByFidelity << suggestedFileName << isNonTextType << containsFileURLAndFileUploadContent;
</del><ins>+    encoder << pathsForFileUpload << contentTypesForFileUpload << contentTypesByFidelity << suggestedFileName << preferredPresentationSize << isNonTextType << containsFileURLAndFileUploadContent;
</ins><span class="cx">     encoder.encodeEnum(preferredPresentationStyle);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -117,6 +118,9 @@
</span><span class="cx">     if (!decoder.decode(result.suggestedFileName))
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span><ins>+    if (!decoder.decode(result.preferredPresentationSize))
+        return WTF::nullopt;
+
</ins><span class="cx">     if (!decoder.decode(result.isNonTextType))
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCoreplatformiosPasteboardIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PasteboardIOS.mm (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PasteboardIOS.mm  2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PasteboardIOS.mm     2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -181,7 +181,7 @@
</span><span class="cx">         || [type isEqualToString:(__bridge NSString *)kUTTypeFlatRTFD];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Pasteboard::ReaderResult Pasteboard::readPasteboardWebContentDataForType(PasteboardWebContentReader& reader, PasteboardStrategy& strategy, NSString *type, int itemIndex)
</del><ins>+Pasteboard::ReaderResult Pasteboard::readPasteboardWebContentDataForType(PasteboardWebContentReader& reader, PasteboardStrategy& strategy, NSString *type, const PasteboardItemInfo& itemInfo, int itemIndex)
</ins><span class="cx"> {
</span><span class="cx">     if ([type isEqualToString:WebArchivePboardType] || [type isEqualToString:(__bridge NSString *)kUTTypeWebArchive]) {
</span><span class="cx">         auto buffer = strategy.readBufferFromPasteboard(itemIndex, type, m_pasteboardName);
</span><span class="lines">@@ -225,7 +225,7 @@
</span><span class="cx">         RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(itemIndex, type, m_pasteboardName);
</span><span class="cx">         if (m_changeCount != changeCount())
</span><span class="cx">             return ReaderResult::PasteboardWasChangedExternally;
</span><del>-        return buffer && reader.readImage(buffer.releaseNonNull(), type) ? ReaderResult::ReadType : ReaderResult::DidNotReadType;
</del><ins>+        return buffer && reader.readImage(buffer.releaseNonNull(), type, itemInfo.preferredPresentationSize) ? ReaderResult::ReadType : ReaderResult::DidNotReadType;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if ([type isEqualToString:(__bridge NSString *)kUTTypeURL]) {
</span><span class="lines">@@ -318,7 +318,7 @@
</span><span class="cx">             if (!isTypeAllowedByReadingPolicy(type, policy))
</span><span class="cx">                 continue;
</span><span class="cx"> 
</span><del>-            auto itemResult = readPasteboardWebContentDataForType(reader, strategy, type, i);
</del><ins>+            auto itemResult = readPasteboardWebContentDataForType(reader, strategy, type, info, i);
</ins><span class="cx">             if (itemResult == ReaderResult::PasteboardWasChangedExternally)
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="lines">@@ -358,7 +358,7 @@
</span><span class="cx">             if (!isTypeAllowedByReadingPolicy(type, policy))
</span><span class="cx">                 continue;
</span><span class="cx"> 
</span><del>-            result = readPasteboardWebContentDataForType(reader, strategy, type, index);
</del><ins>+            result = readPasteboardWebContentDataForType(reader, strategy, type, info, index);
</ins><span class="cx">             if (result == ReaderResult::PasteboardWasChangedExternally)
</span><span class="cx">                 return;
</span><span class="cx">             if (result == ReaderResult::ReadType)
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCoreplatformiosPlatformPasteboardIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm  2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm     2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -155,6 +155,8 @@
</span><span class="cx"> #if PASTEBOARD_SUPPORTS_PRESENTATION_STYLE_AND_TEAM_DATA
</span><span class="cx">     info.preferredPresentationStyle = pasteboardItemPresentationStyle(itemProvider.preferredPresentationStyle);
</span><span class="cx"> #endif
</span><ins>+    if (!CGSizeEqualToSize(itemProvider.preferredPresentationSize, CGSizeZero))
+        info.preferredPresentationSize = FloatSize { itemProvider.preferredPresentationSize };
</ins><span class="cx">     info.containsFileURLAndFileUploadContent = itemProvider.web_containsFileURLAndFileUploadContent;
</span><span class="cx">     info.suggestedFileName = itemProvider.suggestedName;
</span><span class="cx">     NSArray<NSString *> *registeredTypeIdentifiers = itemProvider.registeredTypeIdentifiers;
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebKit/ChangeLog (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebKit/ChangeLog       2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Source/WebKit/ChangeLog  2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -1,5 +1,68 @@
</span><span class="cx"> 2019-05-26  Babak Shafiei  <bshafiei@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r245637. rdar://problem/35205373
+
+    [Paste] Add support for preferred presentation size when pasting an image
+    https://bugs.webkit.org/show_bug.cgi?id=198132
+    <rdar://problem/50886917>
+    
+    Reviewed by Wenson Hsieh.
+    
+    Source/WebCore:
+    
+    Set the pasted <img> width/height attributes when the preferred presentation size is available.
+    
+    * editing/WebContentReader.h:
+    * editing/cocoa/WebContentReaderCocoa.mm:
+    (WebCore::createFragmentForImageAttachment):
+    (WebCore::WebContentReader::readImage):
+    * editing/markup.cpp:
+    (WebCore::createFragmentForImageAndURL):
+    * editing/markup.h:
+    * platform/Pasteboard.h:
+    (WebCore::PasteboardWebContentReader::readImage):
+    * platform/PasteboardItemInfo.h:
+    (WebCore::PasteboardItemInfo::encode const):
+    (WebCore::PasteboardItemInfo::decode):
+    * platform/ios/PasteboardIOS.mm:
+    (WebCore::Pasteboard::readPasteboardWebContentDataForType):
+    (WebCore::Pasteboard::read):
+    (WebCore::Pasteboard::readRespectingUTIFidelities):
+    * platform/ios/PlatformPasteboardIOS.mm:
+    (WebCore::PlatformPasteboard::informationForItemAtIndex):
+    
+    Source/WebKit:
+    
+    * UIProcess/API/Cocoa/_WKElementAction.mm:
+    (addToReadingList):
+    * UIProcess/ios/WKActionSheetAssistant.mm:
+    (-[WKActionSheetAssistant defaultActionsForLinkSheet:]):
+    (-[WKActionSheetAssistant defaultActionsForImageSheet:]):
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245637 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-05-22  Zalan Bujtas  <zalan@apple.com>
+
+            [Paste] Add support for preferred presentation size when pasting an image
+            https://bugs.webkit.org/show_bug.cgi?id=198132
+            <rdar://problem/50886917>
+
+            Reviewed by Wenson Hsieh.
+
+            * UIProcess/API/Cocoa/_WKElementAction.mm:
+            (addToReadingList):
+            * UIProcess/ios/WKActionSheetAssistant.mm:
+            (-[WKActionSheetAssistant defaultActionsForLinkSheet:]):
+            (-[WKActionSheetAssistant defaultActionsForImageSheet:]):
+
+2019-05-26  Babak Shafiei  <bshafiei@apple.com>
+
</ins><span class="cx">         Cherry-pick r245778. rdar://problem/35205373
</span><span class="cx"> 
</span><span class="cx">     [iOS] Dropped text, attachments, and images should animate into place
</span></span></pre></div>
<a id="branchessafari60812420branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Tools/ChangeLog (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Tools/ChangeLog       2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Tools/ChangeLog  2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -1,5 +1,65 @@
</span><span class="cx"> 2019-05-26  Babak Shafiei  <bshafiei@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r245637. rdar://problem/35205373
+
+    [Paste] Add support for preferred presentation size when pasting an image
+    https://bugs.webkit.org/show_bug.cgi?id=198132
+    <rdar://problem/50886917>
+    
+    Reviewed by Wenson Hsieh.
+    
+    Source/WebCore:
+    
+    Set the pasted <img> width/height attributes when the preferred presentation size is available.
+    
+    * editing/WebContentReader.h:
+    * editing/cocoa/WebContentReaderCocoa.mm:
+    (WebCore::createFragmentForImageAttachment):
+    (WebCore::WebContentReader::readImage):
+    * editing/markup.cpp:
+    (WebCore::createFragmentForImageAndURL):
+    * editing/markup.h:
+    * platform/Pasteboard.h:
+    (WebCore::PasteboardWebContentReader::readImage):
+    * platform/PasteboardItemInfo.h:
+    (WebCore::PasteboardItemInfo::encode const):
+    (WebCore::PasteboardItemInfo::decode):
+    * platform/ios/PasteboardIOS.mm:
+    (WebCore::Pasteboard::readPasteboardWebContentDataForType):
+    (WebCore::Pasteboard::read):
+    (WebCore::Pasteboard::readRespectingUTIFidelities):
+    * platform/ios/PlatformPasteboardIOS.mm:
+    (WebCore::PlatformPasteboard::informationForItemAtIndex):
+    
+    Source/WebKit:
+    
+    * UIProcess/API/Cocoa/_WKElementAction.mm:
+    (addToReadingList):
+    * UIProcess/ios/WKActionSheetAssistant.mm:
+    (-[WKActionSheetAssistant defaultActionsForLinkSheet:]):
+    (-[WKActionSheetAssistant defaultActionsForImageSheet:]):
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245637 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-05-22  Zalan Bujtas  <zalan@apple.com>
+
+            [Paste] Add support for preferred presentation size when pasting an image
+            https://bugs.webkit.org/show_bug.cgi?id=198132
+            <rdar://problem/50886917>
+
+            Reviewed by Wenson Hsieh.
+
+            * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
+            (TestWebKitAPI::TEST):
+
+2019-05-26  Babak Shafiei  <bshafiei@apple.com>
+
</ins><span class="cx">         Cherry-pick r245778. rdar://problem/35205373
</span><span class="cx"> 
</span><span class="cx">     [iOS] Dropped text, attachments, and images should animate into place
</span></span></pre></div>
<a id="branchessafari60812420branchToolsTestWebKitAPITestsiosUIPasteboardTestsmm"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm (245781 => 245782)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm    2019-05-26 18:21:55 UTC (rev 245781)
+++ branches/safari-608.1.24.20-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm       2019-05-26 19:05:26 UTC (rev 245782)
</span><span class="lines">@@ -302,6 +302,52 @@
</span><span class="cx">     EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"textData.textContent"]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(UIPasteboardTests, ValidPreferredPresentationSizeForImage)
+{
+    auto webView = setUpWebViewForPasteboardTests(@"autofocus-contenteditable");
+    auto itemProvider = adoptNS([[NSItemProvider alloc] init]);
+    [itemProvider setPreferredPresentationSize:CGSizeMake(10, 20)];
+    [itemProvider registerDataRepresentationForTypeIdentifier:(__bridge NSString *)kUTTypePNG visibility:NSItemProviderRepresentationVisibilityAll loadHandler:[] (DataLoadCompletionBlock completionHandler) -> NSProgress * {
+        completionHandler([NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"icon" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"]], nil);
+        return nil;
+    }];
+    [UIPasteboard generalPasteboard].itemProviders = @[ itemProvider.get() ];
+    [webView paste:nil];
+
+    EXPECT_WK_STREQ("10", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').width"]);
+    EXPECT_WK_STREQ("20", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').height"]);
+}
+
+TEST(UIPasteboardTests, InvalidPreferredPresentationSizeForImage)
+{
+    auto webView = setUpWebViewForPasteboardTests(@"autofocus-contenteditable");
+    auto itemProvider = adoptNS([[NSItemProvider alloc] init]);
+    [itemProvider setPreferredPresentationSize:CGSizeMake(-10, -20)];
+    [itemProvider registerDataRepresentationForTypeIdentifier:(__bridge NSString *)kUTTypePNG visibility:NSItemProviderRepresentationVisibilityAll loadHandler:[] (DataLoadCompletionBlock completionHandler) -> NSProgress * {
+        completionHandler([NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"icon" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"]], nil);
+        return nil;
+    }];
+    [UIPasteboard generalPasteboard].itemProviders = @[ itemProvider.get() ];
+    [webView paste:nil];
+
+    EXPECT_WK_STREQ("0", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').width"]);
+    EXPECT_WK_STREQ("174", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').height"]);
+}
+
+TEST(UIPasteboardTests, MissingPreferredPresentationSizeForImage)
+{
+    auto webView = setUpWebViewForPasteboardTests(@"autofocus-contenteditable");
+    auto itemProvider = adoptNS([[NSItemProvider alloc] init]);
+    [itemProvider registerDataRepresentationForTypeIdentifier:(__bridge NSString *)kUTTypePNG visibility:NSItemProviderRepresentationVisibilityAll loadHandler:[] (DataLoadCompletionBlock completionHandler) -> NSProgress * {
+        completionHandler([NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"icon" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"]], nil);
+        return nil;
+    }];
+    [UIPasteboard generalPasteboard].itemProviders = @[ itemProvider.get() ];
+    [webView paste:nil];
+
+    EXPECT_WK_STREQ("0", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').width"]);
+    EXPECT_WK_STREQ("174", [webView stringByEvaluatingJavaScript:@"document.querySelector('img').height"]);
+}
</ins><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx"> 
</span><span class="cx"> } // namespace TestWebKitAPI
</span></span></pre>
</div>
</div>

</body>
</html>