<!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>[242317] trunk</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/242317">242317</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2019-03-02 13:50:43 -0800 (Sat, 02 Mar 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] Programmatic paste access should be granted when copying and pasting within the same origin
https://bugs.webkit.org/show_bug.cgi?id=195053
<rdar://problem/48134710>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Plumb the document pasteboard identifier through the client when making a DOM paste access request. See WebKit
ChangeLog for more details.

Test: editing/pasteboard/ios/dom-paste-same-origin.html

* WebCore.xcodeproj/project.pbxproj:
* dom/DOMPasteAccess.h: Renamed from Source/WebCore/dom/DOMPasteAccessPolicy.h.

Introduce DOMPasteAccessResponse, which is either DeniedForGesture, GrantedForCommand, or GrantedForGesture. In
particular, when pasteboard identifiers match, we only grant access for the current paste command, rather than
throughout the user gesture.

* dom/UserGestureIndicator.h:
(WebCore::UserGestureToken::didRequestDOMPasteAccess):
* loader/EmptyClients.cpp:
* page/EditorClient.h:
* page/Frame.cpp:
(WebCore::Frame::requestDOMPasteAccess):

Source/WebKit:

Add support for automatically granting programmatic pasteboard access when the pasteboard identifier of the
document requesting programmatic paste matches the identifier in the custom pasteboard data blob in the
UIPasteboard. To do this, we send the pasteboard identifier of the document requesting the DOM paste to the UI
process, and check this against the pasteboard identifiers for each item on the platform pasteboard. If all
items in the platform pasteboard match the given pasteboard identifier (since we don't support writing multiple
pasteboard items via bindings, this should only be a single item), we skip showing the paste callout and
immediately invoke the programmatic paste handler.

* Scripts/webkit/messages.py:
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::requestDOMPasteAccess):
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/API/wpe/PageClientImpl.cpp:
(WebKit::PageClientImpl::requestDOMPasteAccess):
* UIProcess/API/wpe/PageClientImpl.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::requestDOMPasteAccess):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:

Add plumbing to deliver the pasteboard identifier to the client when requesting DOM paste.

* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::requestDOMPasteAccess):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanupInteraction]):
(-[WKContentView resignFirstResponderForWebView]):
(-[WKContentView _webTouchEventsRecognized:]):
(-[WKContentView _willHideMenu:]):
(-[WKContentView pasteForWebView:]):
(-[WKContentView _handleDOMPasteRequestWithResult:]):
(-[WKContentView _willPerformAction:sender:]):
(-[WKContentView _didPerformAction:sender:]):
(-[WKContentView handleKeyWebEvent:withCompletionHandler:]):
(allPasteboardItemOriginsMatchOrigin):
(-[WKContentView _requestDOMPasteAccessWithElementRect:originIdentifier:completionHandler:]):
(-[WKContentView _requestDOMPasteAccessWithElementRect:completionHandler:]): Deleted.

Bail early in the case where all items' pasteboard identifiers (read via custom pasteboard data) match. When
this happens, we only grant access for the current paste command, rather than granting access for the user
gesture token.

* UIProcess/mac/PageClientImplMac.h:
* UIProcess/win/PageClientImpl.cpp:
(WebKit::PageClientImpl::requestDOMPasteAccess):
* UIProcess/win/PageClientImpl.h:
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::requestDOMPasteAccess):
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::requestDOMPasteAccess):
* WebProcess/WebPage/WebPage.h:

Source/WebKitLegacy/mac:

* WebCoreSupport/WebEditorClient.h:

Source/WebKitLegacy/win:

* WebCoreSupport/WebEditorClient.h:

LayoutTests:

Adjust several existing DOM paste tests to copy text from a child frame that has a different origin as the main
frame, such that we'll trigger the paste callout menu when performing a programmatic paste. Also add a new
layout test that copies and programmatically pastes within the same document, to verify that no paste callout is
displayed and the paste is allowed.

* editing/pasteboard/ios/dom-paste-confirmation-expected.txt:
* editing/pasteboard/ios/dom-paste-confirmation.html:
* editing/pasteboard/ios/dom-paste-consecutive-confirmations-expected.txt:
* editing/pasteboard/ios/dom-paste-consecutive-confirmations.html:
* editing/pasteboard/ios/dom-paste-rejection-expected.txt:
* editing/pasteboard/ios/dom-paste-rejection.html:
* editing/pasteboard/ios/dom-paste-requires-user-gesture-expected.txt:
* editing/pasteboard/ios/dom-paste-requires-user-gesture.html:
* editing/pasteboard/ios/dom-paste-same-origin-expected.txt: Copied from LayoutTests/editing/pasteboard/ios/dom-paste-confirmation-expected.txt.
* editing/pasteboard/ios/dom-paste-same-origin.html: Copied from LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardiosdompasteconfirmationexpectedtxt">trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardiosdompasteconfirmationhtml">trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardiosdompasteconsecutiveconfirmationsexpectedtxt">trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardiosdompasteconsecutiveconfirmationshtml">trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations.html</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardiosdompasterejectionexpectedtxt">trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardiosdompasterejectionhtml">trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection.html</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardiosdompasterequiresusergestureexpectedtxt">trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardiosdompasterequiresusergesturehtml">trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoredomUserGestureIndicatorh">trunk/Source/WebCore/dom/UserGestureIndicator.h</a></li>
<li><a href="#trunkSourceWebCoreloaderEmptyClientscpp">trunk/Source/WebCore/loader/EmptyClients.cpp</a></li>
<li><a href="#trunkSourceWebCorepageEditorClienth">trunk/Source/WebCore/page/EditorClient.h</a></li>
<li><a href="#trunkSourceWebCorepageFramecpp">trunk/Source/WebCore/page/Frame.cpp</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitScriptswebkitmessagespy">trunk/Source/WebKit/Scripts/webkit/messages.py</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIgtkPageClientImplcpp">trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIgtkPageClientImplh">trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIwpePageClientImplcpp">trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIwpePageClientImplh">trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessPageClienth">trunk/Source/WebKit/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxymessagesin">trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosPageClientImplIOSh">trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosPageClientImplIOSmm">trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionh">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacPageClientImplMach">trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h</a></li>
<li><a href="#trunkSourceWebKitUIProcesswinPageClientImplcpp">trunk/Source/WebKit/UIProcess/win/PageClientImpl.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcesswinPageClientImplh">trunk/Source/WebKit/UIProcess/win/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebEditorClientcpp">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebEditorClienth">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitLegacymacChangeLog">trunk/Source/WebKitLegacy/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebCoreSupportWebEditorClienth">trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h</a></li>
<li><a href="#trunkSourceWebKitLegacywinChangeLog">trunk/Source/WebKitLegacy/win/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacywinWebCoreSupportWebEditorClienth">trunk/Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestseditingpasteboardiosdompastesameoriginexpectedtxt">trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardiosdompastesameoriginhtml">trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin.html</a></li>
<li><a href="#trunkSourceWebCoredomDOMPasteAccessh">trunk/Source/WebCore/dom/DOMPasteAccess.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoredomDOMPasteAccessPolicyh">trunk/Source/WebCore/dom/DOMPasteAccessPolicy.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/LayoutTests/ChangeLog 2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2019-03-02  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Programmatic paste access should be granted when copying and pasting within the same origin
+        https://bugs.webkit.org/show_bug.cgi?id=195053
+        <rdar://problem/48134710>
+
+        Reviewed by Ryosuke Niwa.
+
+        Adjust several existing DOM paste tests to copy text from a child frame that has a different origin as the main
+        frame, such that we'll trigger the paste callout menu when performing a programmatic paste. Also add a new
+        layout test that copies and programmatically pastes within the same document, to verify that no paste callout is
+        displayed and the paste is allowed.
+
+        * editing/pasteboard/ios/dom-paste-confirmation-expected.txt:
+        * editing/pasteboard/ios/dom-paste-confirmation.html:
+        * editing/pasteboard/ios/dom-paste-consecutive-confirmations-expected.txt:
+        * editing/pasteboard/ios/dom-paste-consecutive-confirmations.html:
+        * editing/pasteboard/ios/dom-paste-rejection-expected.txt:
+        * editing/pasteboard/ios/dom-paste-rejection.html:
+        * editing/pasteboard/ios/dom-paste-requires-user-gesture-expected.txt:
+        * editing/pasteboard/ios/dom-paste-requires-user-gesture.html:
+        * editing/pasteboard/ios/dom-paste-same-origin-expected.txt: Copied from LayoutTests/editing/pasteboard/ios/dom-paste-confirmation-expected.txt.
+        * editing/pasteboard/ios/dom-paste-same-origin.html: Copied from LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html.
+
</ins><span class="cx"> 2019-03-02  Simon Fraser  <simon.fraser@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r242132): Incorrect positioning with multiple position:fixed elements
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardiosdompasteconfirmationexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation-expected.txt (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation-expected.txt     2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation-expected.txt        2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> Click here to copy
</span><span class="cx"> Click here to copy
</span><del>-Click here to copy
</del><ins>+
</ins><span class="cx"> Verifies that a callout is shown when the page programmatically triggers paste, and that tapping the callout allows the paste to happen. To manually test, tap the text on the bottom, tap the editable area above, and then select 'Paste' in the resulting callout menu. The text 'Click here to copy' should be pasted twice in the editable area.
</span><span class="cx"> 
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardiosdompasteconfirmationhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html     2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html        2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -10,12 +10,7 @@
</span><span class="cx">     margin: 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#copy, #editor {
-    text-align: center;
-}
-
</del><span class="cx"> #copy {
</span><del>-    font-size: 40px;
</del><span class="cx">     width: 100%;
</span><span class="cx">     height: 50px;
</span><span class="cx">     border: 1px dashed black;
</span><span class="lines">@@ -25,28 +20,29 @@
</span><span class="cx">     width: 100%;
</span><span class="cx">     height: 100px;
</span><span class="cx">     border: 1px dashed silver;
</span><ins>+    text-align: center;
</ins><span class="cx"> }
</span><span class="cx"> </style>
</span><span class="cx"> </head>
</span><span class="cx"> <body>
</span><span class="cx"> <div id="editor" contenteditable></div>
</span><del>-<div id="copy">Click here to copy</div>
</del><ins>+<iframe id="copy" src="data:text/html,<div id='copy' style='font-size: 40px; text-align: center;'>Click here to copy</div>
+    <script>
+    copy.addEventListener('click', () => {
+        getSelection().selectAllChildren(copy);
+        document.execCommand('Copy');
+        getSelection().removeAllRanges();
+    });
+    </script>"></iframe>
</ins><span class="cx"> <div id="description"></div>
</span><span class="cx"> <div id="console"></div>
</span><span class="cx"> <script>
</span><span class="cx"> jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-const copy = document.getElementById("copy");
</del><span class="cx"> const editor = document.getElementById("editor");
</span><span class="cx"> 
</span><span class="cx"> description("Verifies that a callout is shown when the page programmatically triggers paste, and that tapping the callout allows the paste to happen. To manually test, tap the text on the bottom, tap the editable area above, and then select 'Paste' in the resulting callout menu. The text 'Click here to copy' should be pasted <strong><em>twice</em></strong> in the editable area.");
</span><span class="cx"> 
</span><del>-copy.addEventListener("click", () => {
-    getSelection().selectAllChildren(copy);
-    document.execCommand("Copy");
-    getSelection().removeAllRanges();
-});
-
</del><span class="cx"> editor.addEventListener("paste", event => shouldBeEqualToString("event.clipboardData.getData('text/plain')", "Click here to copy"));
</span><span class="cx"> editor.addEventListener("click", event => {
</span><span class="cx">     getSelection().setPosition(editor);
</span><span class="lines">@@ -60,7 +56,7 @@
</span><span class="cx">     editor.blur();
</span><span class="cx"> });
</span><span class="cx"> 
</span><del>-(async () => {
</del><ins>+addEventListener("load", async () => {
</ins><span class="cx">     if (!window.testRunner)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -67,7 +63,7 @@
</span><span class="cx">     await UIHelper.activateAt(160, 125);
</span><span class="cx">     await triggerPasteMenuAfterTapAt(160, 50);
</span><span class="cx">     finishJSTest();
</span><del>-})();
</del><ins>+});
</ins><span class="cx"> </script>
</span><span class="cx"> </body>
</span><span class="cx"> </html>
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardiosdompasteconsecutiveconfirmationsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations-expected.txt (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations-expected.txt        2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations-expected.txt   2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-Click here to copy
</del><ins>+
</ins><span class="cx"> Verifies that no callout is shown when the page programmatically triggers paste on a timer after user interaction. To test manually, click the text on the bottom to copy, and then click the editable area above to trigger two programmatic pastes with the callout bar. Check that permissions for the first programmatic paste do not affect the second programmatic paste, since it is performed on a zero-delay timer.
</span><span class="cx"> 
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardiosdompasteconsecutiveconfirmationshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations.html (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations.html        2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations.html   2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -10,12 +10,7 @@
</span><span class="cx">     margin: 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#copy, #editor {
-    text-align: center;
-}
-
</del><span class="cx"> #copy {
</span><del>-    font-size: 40px;
</del><span class="cx">     width: 100%;
</span><span class="cx">     height: 50px;
</span><span class="cx">     border: 1px dashed black;
</span><span class="lines">@@ -25,18 +20,25 @@
</span><span class="cx">     width: 100%;
</span><span class="cx">     height: 100px;
</span><span class="cx">     border: 1px dashed silver;
</span><ins>+    text-align: center;
</ins><span class="cx"> }
</span><span class="cx"> </style>
</span><span class="cx"> </head>
</span><span class="cx"> <body>
</span><span class="cx"> <div id="editor" contenteditable></div>
</span><del>-<div id="copy">Click here to copy</div>
</del><ins>+<iframe id="copy" src="data:text/html,<div id='copy' style='font-size: 40px; text-align: center;'>Click here to copy</div>
+    <script>
+    copy.addEventListener('click', () => {
+        getSelection().selectAllChildren(copy);
+        document.execCommand('Copy');
+        getSelection().removeAllRanges();
+    });
+    </script>"></iframe>
</ins><span class="cx"> <div id="description"></div>
</span><span class="cx"> <div id="console"></div>
</span><span class="cx"> <script>
</span><span class="cx"> jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-const copy = document.getElementById("copy");
</del><span class="cx"> const editor = document.getElementById("editor");
</span><span class="cx"> 
</span><span class="cx"> description("Verifies that no callout is shown when the page programmatically triggers paste on a timer after user interaction. To test manually, click the text on the bottom to copy, and then click the editable area above to trigger two programmatic pastes with the callout bar. Check that permissions for the first programmatic paste do not affect the second programmatic paste, since it is performed on a zero-delay timer.");
</span><span class="lines">@@ -60,12 +62,6 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-copy.addEventListener("click", () => {
-    getSelection().selectAllChildren(copy);
-    document.execCommand("Copy");
-    getSelection().removeAllRanges();
-});
-
</del><span class="cx"> function paste() {
</span><span class="cx">     getSelection().setPosition(editor);
</span><span class="cx">     shouldBe("document.execCommand('Paste')", "true");
</span><span class="lines">@@ -80,7 +76,7 @@
</span><span class="cx">     setTimeout(paste, 0);
</span><span class="cx"> });
</span><span class="cx"> 
</span><del>-(async () => {
</del><ins>+addEventListener("load", async () => {
</ins><span class="cx">     if (!window.testRunner || !window.internals)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -87,7 +83,7 @@
</span><span class="cx">     waitForAndTapPasteMenuTwice().then(finishJSTest);
</span><span class="cx">     await UIHelper.activateAt(160, 125);
</span><span class="cx">     await UIHelper.activateAt(160, 50);
</span><del>-})();
</del><ins>+});
</ins><span class="cx"> </script>
</span><span class="cx"> </body>
</span><span class="cx"> </html>
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardiosdompasterejectionexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection-expected.txt (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection-expected.txt        2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection-expected.txt   2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-Click here to copy
</del><ins>+
</ins><span class="cx"> Verifies that a callout is shown when the page programmatically triggers paste, and that dismissing the callout prevents the paste from happening. To manually test, tap the text on the bottom, tap the editable area above, and then dismiss the resulting callout menu by scrolling or tapping elsewhere. The text 'Click here to copy' should not be pasted, and the callout bar should disappear.
</span><span class="cx"> 
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardiosdompasterejectionhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection.html (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection.html        2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection.html   2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -10,12 +10,7 @@
</span><span class="cx">     margin: 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#copy, #editor {
-    text-align: center;
-}
-
</del><span class="cx"> #copy {
</span><del>-    font-size: 40px;
</del><span class="cx">     width: 100%;
</span><span class="cx">     height: 50px;
</span><span class="cx">     border: 1px dashed black;
</span><span class="lines">@@ -25,28 +20,29 @@
</span><span class="cx">     width: 100%;
</span><span class="cx">     height: 100px;
</span><span class="cx">     border: 1px dashed silver;
</span><ins>+    text-align: center;
</ins><span class="cx"> }
</span><span class="cx"> </style>
</span><span class="cx"> </head>
</span><span class="cx"> <body>
</span><span class="cx"> <div id="editor" contenteditable></div>
</span><del>-<div id="copy">Click here to copy</div>
</del><ins>+<iframe id="copy" src="data:text/html,<div id='copy' style='font-size: 40px; text-align: center;'>Click here to copy</div>
+    <script>
+    copy.addEventListener('click', () => {
+        getSelection().selectAllChildren(copy);
+        document.execCommand('Copy');
+        getSelection().removeAllRanges();
+    });
+    </script>"></iframe>
</ins><span class="cx"> <div id="description"></div>
</span><span class="cx"> <div id="console"></div>
</span><span class="cx"> <script>
</span><span class="cx"> jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-const copy = document.getElementById("copy");
</del><span class="cx"> const editor = document.getElementById("editor");
</span><span class="cx"> 
</span><span class="cx"> description("Verifies that a callout is shown when the page programmatically triggers paste, and that dismissing the callout prevents the paste from happening. To manually test, tap the text on the bottom, tap the editable area above, and then dismiss the resulting callout menu by scrolling or tapping elsewhere. The text 'Click here to copy' should <strong>not</strong> be pasted, and the callout bar should disappear.");
</span><span class="cx"> 
</span><del>-copy.addEventListener("click", () => {
-    getSelection().selectAllChildren(copy);
-    document.execCommand("Copy");
-    getSelection().removeAllRanges();
-});
-
</del><span class="cx"> editor.addEventListener("paste", event => shouldBeEqualToString("event.clipboardData.getData('text/plain')", "Click here to copy"));
</span><span class="cx"> editor.addEventListener("click", event => {
</span><span class="cx">     getSelection().setPosition(editor);
</span><span class="lines">@@ -59,7 +55,7 @@
</span><span class="cx">     editor.blur();
</span><span class="cx"> });
</span><span class="cx"> 
</span><del>-(async () => {
</del><ins>+addEventListener("load", async () => {
</ins><span class="cx">     if (!window.testRunner)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -66,7 +62,7 @@
</span><span class="cx">     await UIHelper.activateAt(160, 125);
</span><span class="cx">     await triggerPasteMenuAfterTapAt(160, 50, false);
</span><span class="cx">     finishJSTest();
</span><del>-})();
</del><ins>+});
</ins><span class="cx"> </script>
</span><span class="cx"> </body>
</span><span class="cx"> </html>
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardiosdompasterequiresusergestureexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture-expected.txt (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture-expected.txt    2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture-expected.txt       2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> Click here to copy
</span><del>-Click here to copy
</del><ins>+
</ins><span class="cx"> Verifies that no callout is shown when the page programmatically triggers paste outside the scope of user interaction. This test requires WebKitTestRunner.
</span><span class="cx"> 
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardiosdompasterequiresusergesturehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture.html (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture.html    2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture.html       2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -10,12 +10,7 @@
</span><span class="cx">     margin: 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#copy, #editor {
-    text-align: center;
-}
-
</del><span class="cx"> #copy {
</span><del>-    font-size: 40px;
</del><span class="cx">     width: 100%;
</span><span class="cx">     height: 50px;
</span><span class="cx">     border: 1px dashed black;
</span><span class="lines">@@ -25,36 +20,39 @@
</span><span class="cx">     width: 100%;
</span><span class="cx">     height: 100px;
</span><span class="cx">     border: 1px dashed silver;
</span><ins>+    text-align: center;
</ins><span class="cx"> }
</span><span class="cx"> </style>
</span><span class="cx"> </head>
</span><span class="cx"> <body>
</span><span class="cx"> <div id="editor" contenteditable></div>
</span><del>-<div id="copy">Click here to copy</div>
</del><ins>+<iframe id="copy" src="data:text/html,<div id='copy' style='font-size: 40px; text-align: center;'>Click here to copy</div>
+    <script>
+    copy.addEventListener('click', () => {
+        getSelection().selectAllChildren(copy);
+        document.execCommand('Copy');
+        getSelection().removeAllRanges();
+    });
+    </script>"></iframe>
</ins><span class="cx"> <div id="description"></div>
</span><span class="cx"> <div id="console"></div>
</span><span class="cx"> <script>
</span><span class="cx"> jsTestIsAsync = true;
</span><span class="cx"> 
</span><del>-const copy = document.getElementById("copy");
</del><span class="cx"> const editor = document.getElementById("editor");
</span><span class="cx"> 
</span><span class="cx"> description("Verifies that no callout is shown when the page programmatically triggers paste outside the scope of user interaction. This test requires WebKitTestRunner.");
</span><span class="cx"> 
</span><del>-copy.addEventListener("click", () => {
-    getSelection().selectAllChildren(copy);
-    document.execCommand("Copy");
-    getSelection().removeAllRanges();
-});
</del><ins>+addEventListener("load", async () => {
+    UIHelper.activateAt(160, 125).then(() => {
+        editor.focus();
+        waitForPasteMenu().then(finishJSTest);
</ins><span class="cx"> 
</span><del>-UIHelper.activateAt(160, 125).then(() => {
-    editor.focus();
-    waitForPasteMenu().then(finishJSTest);
-
-    UIHelper.ensurePresentationUpdate().then(() => {
-        internals.withUserGesture(() => shouldBe("document.execCommand('Paste')", "true"));
-        shouldBe("document.execCommand('Paste')", "false");
-        shouldBeEqualToString("editor.textContent", "Click here to copy");
</del><ins>+        UIHelper.ensurePresentationUpdate().then(() => {
+            internals.withUserGesture(() => shouldBe("document.execCommand('Paste')", "true"));
+            shouldBe("document.execCommand('Paste')", "false");
+            shouldBeEqualToString("editor.textContent", "Click here to copy");
+        });
</ins><span class="cx">     });
</span><span class="cx"> });
</span><span class="cx"> </script>
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardiosdompastesameoriginexpectedtxtfromrev242316trunkLayoutTestseditingpasteboardiosdompasteconfirmationexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin-expected.txt (from rev 242316, trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation-expected.txt) (0 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin-expected.txt                              (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin-expected.txt 2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Click here to copy
+Click here to copy
+Click here to copy
+Verifies that programmatic paste is allowed when copied data is from the same origin. To manually test, tap the text on the bottom to programmatically copy, and then tap the editable area and check that the text is pasted twice.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS document.queryCommandSupported('Paste') is true
+PASS document.queryCommandEnabled('Paste') is true
+PASS event.clipboardData.getData('text/plain') is "Click here to copy"
+PASS document.execCommand('Paste') is true
+PASS event.clipboardData.getData('text/plain') is "Click here to copy"
+PASS document.execCommand('Paste') is true
+PASS editor.textContent is "Click here to copyClick here to copy"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardiosdompastesameoriginhtmlfromrev242316trunkLayoutTestseditingpasteboardiosdompasteconfirmationhtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin.html (from rev 242316, trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html) (0 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin.html                              (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin.html 2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -0,0 +1,71 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->
+<html>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script src="../../../resources/ui-helper.js"></script>
+<style>
+body {
+    margin: 0;
+}
+
+#copy, #editor {
+    width: 100%;
+    text-align: center;
+}
+
+#copy {
+    height: 50px;
+    border: 1px dashed black;
+    font-size: 40px;
+}
+
+#editor {
+    height: 100px;
+    border: 1px dashed silver;
+}
+</style>
+</head>
+<body>
+<div id="editor" contenteditable></div>
+<div id='copy' style=''>Click here to copy</div>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+jsTestIsAsync = true;
+
+const copy = document.getElementById("copy");
+const editor = document.getElementById("editor");
+
+description("Verifies that programmatic paste is allowed when copied data is from the same origin. To manually test, tap the text on the bottom to programmatically copy, and then tap the editable area and check that the text is pasted <em>twice</em>.");
+
+copy.addEventListener('click', () => {
+    getSelection().selectAllChildren(copy);
+    document.execCommand('Copy');
+    getSelection().removeAllRanges();
+});
+
+editor.addEventListener("paste", event => shouldBeEqualToString("event.clipboardData.getData('text/plain')", "Click here to copy"));
+editor.addEventListener("click", event => {
+    getSelection().setPosition(editor);
+    shouldBe("document.queryCommandSupported('Paste')", "true");
+    shouldBe("document.queryCommandEnabled('Paste')", "true");
+    shouldBe("document.execCommand('Paste')", "true");
+    document.execCommand('InsertParagraph');
+    shouldBe("document.execCommand('Paste')", "true");
+    shouldBeEqualToString("editor.textContent", "Click here to copyClick here to copy");
+    event.preventDefault();
+    editor.blur();
+    finishJSTest();
+});
+
+addEventListener("load", async () => {
+    if (!window.testRunner)
+        return;
+
+    await UIHelper.activateAt(160, 125);
+    await UIHelper.activateAt(160, 50);
+});
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebCore/ChangeLog      2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2019-03-02  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Programmatic paste access should be granted when copying and pasting within the same origin
+        https://bugs.webkit.org/show_bug.cgi?id=195053
+        <rdar://problem/48134710>
+
+        Reviewed by Ryosuke Niwa.
+
+        Plumb the document pasteboard identifier through the client when making a DOM paste access request. See WebKit
+        ChangeLog for more details.
+
+        Test: editing/pasteboard/ios/dom-paste-same-origin.html
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/DOMPasteAccess.h: Renamed from Source/WebCore/dom/DOMPasteAccessPolicy.h.
+
+        Introduce DOMPasteAccessResponse, which is either DeniedForGesture, GrantedForCommand, or GrantedForGesture. In
+        particular, when pasteboard identifiers match, we only grant access for the current paste command, rather than
+        throughout the user gesture.
+
+        * dom/UserGestureIndicator.h:
+        (WebCore::UserGestureToken::didRequestDOMPasteAccess):
+        * loader/EmptyClients.cpp:
+        * page/EditorClient.h:
+        * page/Frame.cpp:
+        (WebCore::Frame::requestDOMPasteAccess):
+
</ins><span class="cx"> 2019-02-27  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Fixed makeString(float) to do shortest-form serialization without first converting to double
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -4950,7 +4950,7 @@
</span><span class="cx">          F48D2A7E2157182600C6752B /* FontAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2A712156DC0A00C6752B /* FontAttributes.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          F48D2AA52159740D00C6752B /* ColorCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2AA32159740D00C6752B /* ColorCocoa.h */; };
</span><span class="cx">          F49786881FF45FA500E060AB /* PasteboardItemInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = F49786871FF45FA500E060AB /* PasteboardItemInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-               F4B422C4220C0568009E1E7D /* DOMPasteAccessPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = F4B422C2220C0000009E1E7D /* DOMPasteAccessPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><ins>+                F4B422C4220C0568009E1E7D /* DOMPasteAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = F4B422C2220C0000009E1E7D /* DOMPasteAccess.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           F4BFB9851E1DDF9B00862C24 /* DumpEditingHistory.js in Copy Scripts */ = {isa = PBXBuildFile; fileRef = F48389831E1DDF2B0076B7EA /* DumpEditingHistory.js */; };
</span><span class="cx">          F4BFB9861E1DDF9B00862C24 /* EditingHistoryUtil.js in Copy Scripts */ = {isa = PBXBuildFile; fileRef = F48389841E1DDF2B0076B7EA /* EditingHistoryUtil.js */; };
</span><span class="cx">          F4D43D662188038B00ECECAC /* SerializedAttachmentData.h in Headers */ = {isa = PBXBuildFile; fileRef = F4D43D64218802E600ECECAC /* SerializedAttachmentData.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -15183,7 +15183,7 @@
</span><span class="cx">          F48D2AA42159740D00C6752B /* ColorCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ColorCocoa.mm; sourceTree = "<group>"; };
</span><span class="cx">          F49786871FF45FA500E060AB /* PasteboardItemInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteboardItemInfo.h; sourceTree = "<group>"; };
</span><span class="cx">          F49E98E421DEE6C1009AE55E /* EditAction.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EditAction.cpp; sourceTree = "<group>"; };
</span><del>-               F4B422C2220C0000009E1E7D /* DOMPasteAccessPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMPasteAccessPolicy.h; sourceTree = "<group>"; };
</del><ins>+                F4B422C2220C0000009E1E7D /* DOMPasteAccess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMPasteAccess.h; sourceTree = "<group>"; };
</ins><span class="cx">           F4D43D64218802E600ECECAC /* SerializedAttachmentData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SerializedAttachmentData.h; sourceTree = "<group>"; };
</span><span class="cx">          F4D9817D2195FBF6008230FC /* ChangeListTypeCommand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChangeListTypeCommand.h; sourceTree = "<group>"; };
</span><span class="cx">          F4D9817E2195FBF6008230FC /* ChangeListTypeCommand.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ChangeListTypeCommand.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -27503,7 +27503,7 @@
</span><span class="cx">                          A8185F3609765765005826D9 /* DOMImplementation.cpp */,
</span><span class="cx">                          A8185F3309765765005826D9 /* DOMImplementation.h */,
</span><span class="cx">                          93EEC1E909C2877700C515D1 /* DOMImplementation.idl */,
</span><del>-                               F4B422C2220C0000009E1E7D /* DOMPasteAccessPolicy.h */,
</del><ins>+                                F4B422C2220C0000009E1E7D /* DOMPasteAccess.h */,
</ins><span class="cx">                           0F4966991DB408C100A274BB /* DOMPoint.h */,
</span><span class="cx">                          0F49669A1DB408C100A274BB /* DOMPoint.idl */,
</span><span class="cx">                          0F4966A21DB4091000A274BB /* DOMPointInit.h */,
</span><span class="lines">@@ -29079,7 +29079,7 @@
</span><span class="cx">                          A9C6E4E40D745E05006442E9 /* DOMMimeType.h in Headers */,
</span><span class="cx">                          A9C6E4E80D745E18006442E9 /* DOMMimeTypeArray.h in Headers */,
</span><span class="cx">                          1ACE53E80A8D18E70022947D /* DOMParser.h in Headers */,
</span><del>-                               F4B422C4220C0568009E1E7D /* DOMPasteAccessPolicy.h in Headers */,
</del><ins>+                                F4B422C4220C0568009E1E7D /* DOMPasteAccess.h in Headers */,
</ins><span class="cx">                           7A54881714E432A1006AE05A /* DOMPatchSupport.h in Headers */,
</span><span class="cx">                          A9C6E4EC0D745E2B006442E9 /* DOMPlugin.h in Headers */,
</span><span class="cx">                          A9C6E4F00D745E38006442E9 /* DOMPluginArray.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoredomDOMPasteAccesshfromrev242316trunkSourceWebCoredomDOMPasteAccessPolicyh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/DOMPasteAccess.h (from rev 242316, trunk/Source/WebCore/dom/DOMPasteAccessPolicy.h) (0 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DOMPasteAccess.h                                (rev 0)
+++ trunk/Source/WebCore/dom/DOMPasteAccess.h   2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+enum class DOMPasteAccessPolicy : uint8_t {
+    NotRequestedYet,
+    Denied,
+    Granted
+};
+
+enum class DOMPasteAccessResponse : uint8_t {
+    DeniedForGesture,
+    GrantedForCommand,
+    GrantedForGesture
+};
+
+} // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::DOMPasteAccessResponse> {
+    using values = EnumValues<
+        WebCore::DOMPasteAccessResponse,
+        WebCore::DOMPasteAccessResponse::DeniedForGesture,
+        WebCore::DOMPasteAccessResponse::GrantedForCommand,
+        WebCore::DOMPasteAccessResponse::GrantedForGesture
+    >;
+};
+
+} // namespace WTF
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDOMPasteAccessPolicyh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/dom/DOMPasteAccessPolicy.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DOMPasteAccessPolicy.h  2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebCore/dom/DOMPasteAccessPolicy.h     2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -1,36 +0,0 @@
</span><del>-/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-namespace WebCore {
-
-enum class DOMPasteAccessPolicy : uint8_t {
-    NotRequestedYet,
-    Denied,
-    Granted
-};
-
-}
</del></span></pre></div>
<a id="trunkSourceWebCoredomUserGestureIndicatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/UserGestureIndicator.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/UserGestureIndicator.h  2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.h     2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><del>-#include "DOMPasteAccessPolicy.h"
</del><ins>+#include "DOMPasteAccess.h"
</ins><span class="cx"> #include <wtf/Function.h>
</span><span class="cx"> #include <wtf/Noncopyable.h>
</span><span class="cx"> #include <wtf/Optional.h>
</span><span class="lines">@@ -65,7 +65,19 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     DOMPasteAccessPolicy domPasteAccessPolicy() const { return m_domPasteAccessPolicy; }
</span><del>-    void didRequestDOMPasteAccess(bool granted) { m_domPasteAccessPolicy = granted ? DOMPasteAccessPolicy::Granted : DOMPasteAccessPolicy::Denied; }
</del><ins>+    void didRequestDOMPasteAccess(DOMPasteAccessResponse response)
+    {
+        switch (response) {
+        case DOMPasteAccessResponse::DeniedForGesture:
+            m_domPasteAccessPolicy = DOMPasteAccessPolicy::Denied;
+            break;
+        case DOMPasteAccessResponse::GrantedForCommand:
+            break;
+        case DOMPasteAccessResponse::GrantedForGesture:
+            m_domPasteAccessPolicy = DOMPasteAccessPolicy::Granted;
+            break;
+        }
+    }
</ins><span class="cx">     void resetDOMPasteAccess() { m_domPasteAccessPolicy = DOMPasteAccessPolicy::NotRequestedYet; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderEmptyClientscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/EmptyClients.cpp     2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp        2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include "ColorChooser.h"
</span><span class="cx"> #include "ContextMenuClient.h"
</span><span class="cx"> #include "CookieJar.h"
</span><ins>+#include "DOMPasteAccess.h"
</ins><span class="cx"> #include "DataListSuggestionPicker.h"
</span><span class="cx"> #include "DatabaseProvider.h"
</span><span class="cx"> #include "DiagnosticLoggingClient.h"
</span><span class="lines">@@ -189,7 +190,7 @@
</span><span class="cx">     void registerRedoStep(UndoStep&) final;
</span><span class="cx">     void clearUndoRedoOperations() final { }
</span><span class="cx"> 
</span><del>-    bool requestDOMPasteAccess() final { return false; }
</del><ins>+    DOMPasteAccessResponse requestDOMPasteAccess(const String&) final { return DOMPasteAccessResponse::DeniedForGesture; }
</ins><span class="cx"> 
</span><span class="cx">     bool canCopyCut(Frame*, bool defaultValue) const final { return defaultValue; }
</span><span class="cx">     bool canPaste(Frame*, bool defaultValue) const final { return defaultValue; }
</span></span></pre></div>
<a id="trunkSourceWebCorepageEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/EditorClient.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/EditorClient.h 2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebCore/page/EditorClient.h    2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -36,6 +36,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+enum class DOMPasteAccessResponse : uint8_t;
+
</ins><span class="cx"> class DocumentFragment;
</span><span class="cx"> class Element;
</span><span class="cx"> class Frame;
</span><span class="lines">@@ -97,7 +99,7 @@
</span><span class="cx">     virtual void requestCandidatesForSelection(const VisibleSelection&) { }
</span><span class="cx">     virtual void handleAcceptedCandidateWithSoftSpaces(TextCheckingResult) { }
</span><span class="cx"> 
</span><del>-    virtual bool requestDOMPasteAccess() = 0;
</del><ins>+    virtual DOMPasteAccessResponse requestDOMPasteAccess(const String& originIdentifier) = 0;
</ins><span class="cx"> 
</span><span class="cx">     // Notify an input method that a composition was voluntarily discarded by WebCore, so that it could clean up too.
</span><span class="cx">     // This function is not called when a composition is closed per a request from an input method.
</span></span></pre></div>
<a id="trunkSourceWebCorepageFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Frame.cpp (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Frame.cpp      2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebCore/page/Frame.cpp 2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -681,9 +681,15 @@
</span><span class="cx">         if (!client)
</span><span class="cx">             return false;
</span><span class="cx"> 
</span><del>-        bool granted = client->requestDOMPasteAccess();
-        gestureToken->didRequestDOMPasteAccess(granted);
-        return granted;
</del><ins>+        auto response = client->requestDOMPasteAccess(m_doc->originIdentifierForPasteboard());
+        gestureToken->didRequestDOMPasteAccess(response);
+        switch (response) {
+        case DOMPasteAccessResponse::GrantedForCommand:
+        case DOMPasteAccessResponse::GrantedForGesture:
+            return true;
+        case DOMPasteAccessResponse::DeniedForGesture:
+            return false;
+        }
</ins><span class="cx">     }
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/ChangeLog       2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -1,3 +1,67 @@
</span><ins>+2019-03-02  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Programmatic paste access should be granted when copying and pasting within the same origin
+        https://bugs.webkit.org/show_bug.cgi?id=195053
+        <rdar://problem/48134710>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add support for automatically granting programmatic pasteboard access when the pasteboard identifier of the
+        document requesting programmatic paste matches the identifier in the custom pasteboard data blob in the
+        UIPasteboard. To do this, we send the pasteboard identifier of the document requesting the DOM paste to the UI
+        process, and check this against the pasteboard identifiers for each item on the platform pasteboard. If all
+        items in the platform pasteboard match the given pasteboard identifier (since we don't support writing multiple
+        pasteboard items via bindings, this should only be a single item), we skip showing the paste callout and
+        immediately invoke the programmatic paste handler.
+
+        * Scripts/webkit/messages.py:
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::requestDOMPasteAccess):
+        * UIProcess/API/gtk/PageClientImpl.h:
+        * UIProcess/API/wpe/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::requestDOMPasteAccess):
+        * UIProcess/API/wpe/PageClientImpl.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::requestDOMPasteAccess):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+
+        Add plumbing to deliver the pasteboard identifier to the client when requesting DOM paste.
+
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::requestDOMPasteAccess):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView cleanupInteraction]):
+        (-[WKContentView resignFirstResponderForWebView]):
+        (-[WKContentView _webTouchEventsRecognized:]):
+        (-[WKContentView _willHideMenu:]):
+        (-[WKContentView pasteForWebView:]):
+        (-[WKContentView _handleDOMPasteRequestWithResult:]):
+        (-[WKContentView _willPerformAction:sender:]):
+        (-[WKContentView _didPerformAction:sender:]):
+        (-[WKContentView handleKeyWebEvent:withCompletionHandler:]):
+        (allPasteboardItemOriginsMatchOrigin):
+        (-[WKContentView _requestDOMPasteAccessWithElementRect:originIdentifier:completionHandler:]):
+        (-[WKContentView _requestDOMPasteAccessWithElementRect:completionHandler:]): Deleted.
+
+        Bail early in the case where all items' pasteboard identifiers (read via custom pasteboard data) match. When
+        this happens, we only grant access for the current paste command, rather than granting access for the user
+        gesture token.
+
+        * UIProcess/mac/PageClientImplMac.h:
+        * UIProcess/win/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::requestDOMPasteAccess):
+        * UIProcess/win/PageClientImpl.h:
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::requestDOMPasteAccess):
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::requestDOMPasteAccess):
+        * WebProcess/WebPage/WebPage.h:
+
</ins><span class="cx"> 2019-02-27  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Fixed makeString(float) to do shortest-form serialization without first converting to double
</span></span></pre></div>
<a id="trunkSourceWebKitScriptswebkitmessagespy"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Scripts/webkit/messages.py   2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py      2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -398,6 +398,7 @@
</span><span class="cx">         'String': ['<wtf/text/WTFString.h>'],
</span><span class="cx">         'PAL::SessionID': ['<pal/SessionID.h>'],
</span><span class="cx">         'WebCore::AutoplayEventFlags': ['<WebCore/AutoplayEvent.h>'],
</span><ins>+        'WebCore::DOMPasteAccessResponse': ['<WebCore/DOMPasteAccess.h>'],
</ins><span class="cx">         'WebCore::DragHandlingMethod': ['<WebCore/DragActions.h>'],
</span><span class="cx">         'WebCore::ExceptionDetails': ['<WebCore/JSDOMExceptionHandling.h>'],
</span><span class="cx">         'WebCore::FileChooserSettings': ['<WebCore/FileChooser.h>'],
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIgtkPageClientImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp    2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> #include "WebProcessPool.h"
</span><span class="cx"> #include <WebCore/CairoUtilities.h>
</span><span class="cx"> #include <WebCore/Cursor.h>
</span><ins>+#include <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> #include <WebCore/EventNames.h>
</span><span class="cx"> #include <WebCore/GtkUtilities.h>
</span><span class="cx"> #include <WebCore/NotImplemented.h>
</span><span class="lines">@@ -524,9 +525,9 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void PageClientImpl::requestDOMPasteAccess(const IntRect&, CompletionHandler<void(bool)>&& completionHandler)
</del><ins>+void PageClientImpl::requestDOMPasteAccess(const IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    completionHandler(false);
</del><ins>+    completionHandler(WebCore::DOMPasteAccessResponse::DeniedForGesture);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIgtkPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h   2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h      2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -36,6 +36,10 @@
</span><span class="cx"> #include <gtk/gtk.h>
</span><span class="cx"> #include <memory>
</span><span class="cx"> 
</span><ins>+namespace WebCore {
+enum class DOMPasteAccessPolicy : uint8_t;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class DrawingAreaProxy;
</span><span class="lines">@@ -150,7 +154,7 @@
</span><span class="cx"> 
</span><span class="cx">     void didFinishProcessingAllPendingMouseEvents() final { }
</span><span class="cx"> 
</span><del>-    void requestDOMPasteAccess(const WebCore::IntRect&, CompletionHandler<void(bool)>&&) final;
</del><ins>+    void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO) && USE(GSTREAMER)
</span><span class="cx">     bool decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) override;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIwpePageClientImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp 2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp    2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include "WebContextMenuProxy.h"
</span><span class="cx"> #include "WebContextMenuProxyWPE.h"
</span><span class="cx"> #include <WebCore/ActivityState.h>
</span><ins>+#include <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> #include <WebCore/NotImplemented.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -399,9 +400,9 @@
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(FULLSCREEN_API)
</span><span class="cx"> 
</span><del>-void PageClientImpl::requestDOMPasteAccess(const WebCore::IntRect&, CompletionHandler<void(bool)>&& completionHandler)
</del><ins>+void PageClientImpl::requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    completionHandler(false);
</del><ins>+    completionHandler(WebCore::DOMPasteAccessResponse::DeniedForGesture);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIwpePageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h   2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h      2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -34,6 +34,10 @@
</span><span class="cx"> class View;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+namespace WebCore {
+enum class DOMPasteAccessResponse : uint8_t;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class ScrollGestureController;
</span><span class="lines">@@ -146,7 +150,7 @@
</span><span class="cx">     void didFinishProcessingAllPendingMouseEvents() final { }
</span><span class="cx"> 
</span><span class="cx">     IPC::Attachment hostFileDescriptor() final;
</span><del>-    void requestDOMPasteAccess(const WebCore::IntRect&, CompletionHandler<void(bool)>&&) final;
</del><ins>+    void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
</ins><span class="cx"> 
</span><span class="cx">     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/PageClient.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/PageClient.h       2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/PageClient.h  2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -86,6 +86,7 @@
</span><span class="cx"> enum class ScrollbarStyle : uint8_t;
</span><span class="cx"> enum class TextIndicatorWindowLifetime : uint8_t;
</span><span class="cx"> enum class TextIndicatorWindowDismissalAnimation : uint8_t;
</span><ins>+enum class DOMPasteAccessResponse : uint8_t;
</ins><span class="cx"> 
</span><span class="cx"> struct DictionaryPopupInfo;
</span><span class="cx"> struct Highlight;
</span><span class="lines">@@ -95,13 +96,11 @@
</span><span class="cx"> 
</span><span class="cx"> template <typename> class RectEdges;
</span><span class="cx"> using FloatBoxExtent = RectEdges<float>;
</span><del>-}
</del><span class="cx"> 
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><del>-namespace WebCore {
</del><span class="cx"> struct DragItem;
</span><ins>+#endif
</ins><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="lines">@@ -465,7 +464,7 @@
</span><span class="cx">     virtual void didChangeDragCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) = 0;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    virtual void requestDOMPasteAccess(const WebCore::IntRect& elementRect, CompletionHandler<void(bool)>&&) = 0;
</del><ins>+    virtual void requestDOMPasteAccess(const WebCore::IntRect& elementRect, const String& originIdentifier, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) = 0;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(ATTACHMENT_ELEMENT)
</span><span class="cx">     virtual void didInsertAttachment(API::Attachment&, const String& source) { }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -131,6 +131,7 @@
</span><span class="cx"> #include "WebsiteDataStore.h"
</span><span class="cx"> #include <WebCore/AdClickAttribution.h>
</span><span class="cx"> #include <WebCore/BitmapImage.h>
</span><ins>+#include <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> #include <WebCore/DeprecatedGlobalSettings.h>
</span><span class="cx"> #include <WebCore/DiagnosticLoggingClient.h>
</span><span class="cx"> #include <WebCore/DiagnosticLoggingKeys.h>
</span><span class="lines">@@ -5528,9 +5529,9 @@
</span><span class="cx">     m_needsPlainTextQuirk = needsPlainTextQuirk;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::requestDOMPasteAccess(const WebCore::IntRect& elementRect, CompletionHandler<void(bool)>&& completionHandler)
</del><ins>+void WebPageProxy::requestDOMPasteAccess(const WebCore::IntRect& elementRect, const String& originIdentifier, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    m_pageClient->requestDOMPasteAccess(elementRect, WTFMove(completionHandler));
</del><ins>+    m_pageClient->requestDOMPasteAccess(elementRect, originIdentifier, WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // BackForwardList
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -182,6 +182,7 @@
</span><span class="cx"> enum SelectionDirection : uint8_t;
</span><span class="cx"> 
</span><span class="cx"> enum class AutoplayEvent : uint8_t;
</span><ins>+enum class DOMPasteAccessResponse : uint8_t;
</ins><span class="cx"> enum class LockBackForwardList : bool;
</span><span class="cx"> enum class HasInsecureContent : bool;
</span><span class="cx"> enum class NotificationDirection : uint8_t;
</span><span class="lines">@@ -1669,7 +1670,7 @@
</span><span class="cx">     void setNeedsHiddenContentEditableQuirk(bool);
</span><span class="cx">     void setNeedsPlainTextQuirk(bool);
</span><span class="cx"> 
</span><del>-    void requestDOMPasteAccess(const WebCore::IntRect&, CompletionHandler<void(bool)>&&);
</del><ins>+    void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&);
</ins><span class="cx"> 
</span><span class="cx">     // Back/Forward list management
</span><span class="cx">     void backForwardAddItem(BackForwardListItemState&&);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in   2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in      2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -251,7 +251,7 @@
</span><span class="cx">     SetHasHadSelectionChangesFromUserInteraction(bool hasHadUserSelectionChanges)
</span><span class="cx">     SetNeedsHiddenContentEditableQuirk(bool needsHiddenContentEditableQuirk)
</span><span class="cx">     SetNeedsPlainTextQuirk(bool needsPlainTextQuirk)
</span><del>-    RequestDOMPasteAccess(WebCore::IntRect elementRect) -> (bool granted) Delayed
</del><ins>+    RequestDOMPasteAccess(WebCore::IntRect elementRect, String originIdentifier) -> (enum:uint8_t WebCore::DOMPasteAccessResponse response) Delayed
</ins><span class="cx"> 
</span><span class="cx">     # Find messages
</span><span class="cx">     DidCountStringMatches(String string, uint32_t matchCount)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h    2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h       2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> OBJC_CLASS WKEditorUndoTarget;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+enum class DOMPasteAccessResponse : uint8_t;
</ins><span class="cx"> struct PromisedAttachmentInfo;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -224,7 +225,7 @@
</span><span class="cx">     void requestPasswordForQuickLookDocument(const String& fileName, WTF::Function<void(const String&)>&&) override;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    void requestDOMPasteAccess(const WebCore::IntRect& elementRect, CompletionHandler<void(bool)>&&) final;
</del><ins>+    void requestDOMPasteAccess(const WebCore::IntRect& elementRect, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(DATA_INTERACTION)
</span><span class="cx">     void didPerformDragOperation(bool handled) override;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm   2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm      2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> #import "WebEditCommandProxy.h"
</span><span class="cx"> #import "WebProcessProxy.h"
</span><span class="cx"> #import "_WKDownloadInternal.h"
</span><ins>+#import <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> #import <WebCore/DictionaryLookup.h>
</span><span class="cx"> #import <WebCore/NotImplemented.h>
</span><span class="cx"> #import <WebCore/PlatformScreen.h>
</span><span class="lines">@@ -837,9 +838,9 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void PageClientImpl::requestDOMPasteAccess(const WebCore::IntRect& elementRect, CompletionHandler<void(bool)>&& completionHandler)
</del><ins>+void PageClientImpl::requestDOMPasteAccess(const WebCore::IntRect& elementRect, const String& originIdentifier, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    [m_contentView _requestDOMPasteAccessWithElementRect:elementRect completionHandler:WTFMove(completionHandler)];
</del><ins>+    [m_contentView _requestDOMPasteAccessWithElementRect:elementRect originIdentifier:originIdentifier completionHandler:WTFMove(completionHandler)];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if HAVE(PENCILKIT)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h     2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h        2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -71,14 +71,13 @@
</span><span class="cx"> class SelectionRect;
</span><span class="cx"> struct PromisedAttachmentInfo;
</span><span class="cx"> struct ShareDataWithParsedURL;
</span><ins>+enum class DOMPasteAccessResponse : uint8_t;
</ins><span class="cx"> enum class RouteSharingPolicy : uint8_t;
</span><del>-}
</del><span class="cx"> 
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><del>-namespace WebCore {
</del><span class="cx"> struct DragItem;
</span><ins>+#endif
</ins><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> class InputViewUpdateDeferrer;
</span><span class="lines">@@ -318,7 +317,7 @@
</span><span class="cx">     BOOL _focusRequiresStrongPasswordAssistance;
</span><span class="cx"> 
</span><span class="cx">     BOOL _hasSetUpInteractions;
</span><del>-    CompletionHandler<void(bool)> _domPasteRequestHandler;
</del><ins>+    CompletionHandler<void(WebCore::DOMPasteAccessResponse)> _domPasteRequestHandler;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(DATA_INTERACTION)
</span><span class="cx">     WebKit::DragDropInteractionState _dragDropInteractionState;
</span><span class="lines">@@ -440,7 +439,7 @@
</span><span class="cx"> - (void)_accessibilityClearSelection;
</span><span class="cx"> - (WKFormInputSession *)_formInputSession;
</span><span class="cx"> 
</span><del>-- (void)_requestDOMPasteAccessWithElementRect:(const WebCore::IntRect&)elementRect completionHandler:(CompletionHandler<void(bool)>&&)completionHandler;
</del><ins>+- (void)_requestDOMPasteAccessWithElementRect:(const WebCore::IntRect&)elementRect originIdentifier:(const String&)originIdentifier completionHandler:(CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&)completionHandler;
</ins><span class="cx"> 
</span><span class="cx"> @property (nonatomic, readonly) WebKit::InteractionInformationAtPosition currentPositionInformation;
</span><span class="cx"> - (void)doAfterPositionInformationUpdate:(void (^)(WebKit::InteractionInformationAtPosition))action forRequest:(WebKit::InteractionInformationRequest)request;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm    2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm       2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -77,6 +77,7 @@
</span><span class="cx"> #import <CoreText/CTFontDescriptor.h>
</span><span class="cx"> #import <MobileCoreServices/UTCoreTypes.h>
</span><span class="cx"> #import <WebCore/Color.h>
</span><ins>+#import <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> #import <WebCore/DataDetection.h>
</span><span class="cx"> #import <WebCore/FloatQuad.h>
</span><span class="cx"> #import <WebCore/FontAttributeChanges.h>
</span><span class="lines">@@ -890,7 +891,7 @@
</span><span class="cx"> #if ENABLE(POINTER_EVENTS)
</span><span class="cx">     [self _resetPanningPreventionFlags];
</span><span class="cx"> #endif
</span><del>-    [self _handleDOMPasteRequestWithResult:NO];
</del><ins>+    [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_removeDefaultGestureRecognizers
</span><span class="lines">@@ -1178,7 +1179,7 @@
</span><span class="cx">     bool superDidResign = [super resignFirstResponder];
</span><span class="cx"> 
</span><span class="cx">     if (superDidResign) {
</span><del>-        [self _handleDOMPasteRequestWithResult:NO];
</del><ins>+        [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture];
</ins><span class="cx">         _page->activityStateDidChange(WebCore::ActivityState::IsFocused);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1214,7 +1215,7 @@
</span><span class="cx"> 
</span><span class="cx">     _lastInteractionLocation = lastTouchEvent->locationInDocumentCoordinates;
</span><span class="cx">     if (lastTouchEvent->type == UIWebTouchEventTouchBegin) {
</span><del>-        [self _handleDOMPasteRequestWithResult:NO];
</del><ins>+        [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture];
</ins><span class="cx">         _layerTreeTransactionIdAtLastTouchStart = downcast<WebKit::RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).lastCommittedLayerTreeTransactionID();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2898,7 +2899,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_willHideMenu:(NSNotification *)notification
</span><span class="cx"> {
</span><del>-    [self _handleDOMPasteRequestWithResult:NO];
</del><ins>+    [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_didHideMenu:(NSNotification *)notification
</span><span class="lines">@@ -2926,7 +2927,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)pasteForWebView:(id)sender
</span><span class="cx"> {
</span><del>-    if (sender == UIMenuController.sharedMenuController && [self _handleDOMPasteRequestWithResult:YES])
</del><ins>+    if (sender == UIMenuController.sharedMenuController && [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::GrantedForGesture])
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     _page->executeEditCommand("paste"_s);
</span><span class="lines">@@ -3058,11 +3059,11 @@
</span><span class="cx">     _page->storeSelectionForAccessibility(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (BOOL)_handleDOMPasteRequestWithResult:(BOOL)allowPaste
</del><ins>+- (BOOL)_handleDOMPasteRequestWithResult:(WebCore::DOMPasteAccessResponse)response
</ins><span class="cx"> {
</span><span class="cx">     if (auto pasteHandler = WTFMove(_domPasteRequestHandler)) {
</span><span class="cx">         [self hideGlobalMenuController];
</span><del>-        pasteHandler(allowPaste);
</del><ins>+        pasteHandler(response);
</ins><span class="cx">         return YES;
</span><span class="cx">     }
</span><span class="cx">     return NO;
</span><span class="lines">@@ -3071,13 +3072,13 @@
</span><span class="cx"> - (void)_willPerformAction:(SEL)action sender:(id)sender
</span><span class="cx"> {
</span><span class="cx">     if (action != @selector(paste:))
</span><del>-        [self _handleDOMPasteRequestWithResult:NO];
</del><ins>+        [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_didPerformAction:(SEL)action sender:(id)sender
</span><span class="cx"> {
</span><span class="cx">     if (action == @selector(paste:))
</span><del>-        [self _handleDOMPasteRequestWithResult:NO];
</del><ins>+        [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // UIWKInteractionViewProtocol
</span><span class="lines">@@ -4295,7 +4296,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)handleKeyWebEvent:(::WebEvent *)theEvent withCompletionHandler:(void (^)(::WebEvent *theEvent, BOOL wasHandled))completionHandler
</span><span class="cx"> {
</span><del>-    [self _handleDOMPasteRequestWithResult:NO];
</del><ins>+    [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture];
</ins><span class="cx"> 
</span><span class="cx">     _keyWebEventHandler = makeBlockPtr(completionHandler);
</span><span class="cx">     _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent));
</span><span class="lines">@@ -5035,13 +5036,43 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_requestDOMPasteAccessWithElementRect:(const WebCore::IntRect&)elementRect completionHandler:(CompletionHandler<void(bool)>&&)completionHandler
</del><ins>+static BOOL allPasteboardItemOriginsMatchOrigin(UIPasteboard *pasteboard, const String& originIdentifier)
</ins><span class="cx"> {
</span><ins>+    if (originIdentifier.isEmpty())
+        return NO;
+
+    auto *indices = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [pasteboard numberOfItems])];
+    auto *allCustomData = [pasteboard dataForPasteboardType:@(WebCore::PasteboardCustomData::cocoaType()) inItemSet:indices];
+    if (!allCustomData.count)
+        return NO;
+
+    BOOL foundAtLeastOneMatchingIdentifier = NO;
+    for (NSData *data in allCustomData) {
+        if (!data.length)
+            continue;
+
+        auto buffer = WebCore::SharedBuffer::create(data);
+        if (WebCore::PasteboardCustomData::fromSharedBuffer(buffer.get()).origin != originIdentifier)
+            return NO;
+
+        foundAtLeastOneMatchingIdentifier = YES;
+    }
+
+    return foundAtLeastOneMatchingIdentifier;
+}
+
+- (void)_requestDOMPasteAccessWithElementRect:(const WebCore::IntRect&)elementRect originIdentifier:(const String&)originIdentifier completionHandler:(CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&)completionHandler
+{
</ins><span class="cx">     if (auto existingCompletionHandler = std::exchange(_domPasteRequestHandler, WTFMove(completionHandler))) {
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><del>-        existingCompletionHandler(false);
</del><ins>+        existingCompletionHandler(WebCore::DOMPasteAccessResponse::DeniedForGesture);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (allPasteboardItemOriginsMatchOrigin(UIPasteboard.generalPasteboard, originIdentifier)) {
+        [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::GrantedForCommand];
+        return;
+    }
+
</ins><span class="cx">     WebCore::IntRect menuControllerRect = elementRect;
</span><span class="cx"> 
</span><span class="cx">     const CGFloat maximumElementWidth = 300;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacPageClientImplMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h    2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h       2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include "CorrectionPanel.h"
</span><span class="cx"> #include "PageClientImplCocoa.h"
</span><span class="cx"> #include "WebFullScreenManagerProxy.h"
</span><ins>+#include <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> #include <wtf/CompletionHandler.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> 
</span><span class="lines">@@ -214,7 +215,7 @@
</span><span class="cx">     void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
</span><span class="cx">     void didRemoveNavigationGestureSnapshot() override;
</span><span class="cx"> 
</span><del>-    void requestDOMPasteAccess(const WebCore::IntRect&, CompletionHandler<void(bool)>&& completion) final { completion(false); }
</del><ins>+    void requestDOMPasteAccess(const WebCore::IntRect&, const String& originIdentifier, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&& completion) final { completion(WebCore::DOMPasteAccessResponse::DeniedForGesture); }
</ins><span class="cx"> 
</span><span class="cx">     NSView *activeView() const;
</span><span class="cx">     NSWindow *activeWindow() const;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcesswinPageClientImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/win/PageClientImpl.cpp (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/win/PageClientImpl.cpp     2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/win/PageClientImpl.cpp        2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include "WebPageProxy.h"
</span><span class="cx"> #include "WebPopupMenuProxyWin.h"
</span><span class="cx"> #include "WebView.h"
</span><ins>+#include <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> using namespace WebCore;
</span><span class="lines">@@ -367,9 +368,9 @@
</span><span class="cx">     return m_view.window();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::requestDOMPasteAccess(const IntRect&, CompletionHandler<void(bool)>&& completionHandler)
</del><ins>+void PageClientImpl::requestDOMPasteAccess(const IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    completionHandler(false);
</del><ins>+    completionHandler(WebCore::DOMPasteAccessResponse::DeniedForGesture);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcesswinPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/win/PageClientImpl.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/win/PageClientImpl.h       2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/UIProcess/win/PageClientImpl.h  2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -34,6 +34,10 @@
</span><span class="cx"> #include "WebPageProxy.h"
</span><span class="cx"> #include <WebCore/IntSize.h>
</span><span class="cx"> 
</span><ins>+namespace WebCore {
+enum class DOMPasteAccessResponse : uint8_t;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class DrawingAreaProxy;
</span><span class="lines">@@ -144,7 +148,7 @@
</span><span class="cx"> 
</span><span class="cx">     void didFinishProcessingAllPendingMouseEvents() final { }
</span><span class="cx"> 
</span><del>-    void requestDOMPasteAccess(const WebCore::IntRect&, CompletionHandler<void(bool)>&&) final;
</del><ins>+    void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
</ins><span class="cx"> 
</span><span class="cx">     // Members of PageClientImpl class
</span><span class="cx">     DefaultUndoController m_undoController;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebEditorClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp        2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp   2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> #include "WebProcess.h"
</span><span class="cx"> #include "WebUndoStep.h"
</span><span class="cx"> #include <WebCore/ArchiveResource.h>
</span><ins>+#include <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> #include <WebCore/DocumentFragment.h>
</span><span class="cx"> #include <WebCore/FocusController.h>
</span><span class="cx"> #include <WebCore/Frame.h>
</span><span class="lines">@@ -354,9 +355,9 @@
</span><span class="cx">     m_page->sendSync(Messages::WebPageProxy::ExecuteUndoRedo(UndoOrRedo::Redo), Messages::WebPageProxy::ExecuteUndoRedo::Reply());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool WebEditorClient::requestDOMPasteAccess()
</del><ins>+WebCore::DOMPasteAccessResponse WebEditorClient::requestDOMPasteAccess(const String& originIdentifier)
</ins><span class="cx"> {
</span><del>-    return m_page->requestDOMPasteAccess();
</del><ins>+    return m_page->requestDOMPasteAccess(originIdentifier);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(WIN)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h  2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h     2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -28,6 +28,10 @@
</span><span class="cx"> #include <WebCore/EditorClient.h>
</span><span class="cx"> #include <WebCore/TextCheckerClient.h>
</span><span class="cx"> 
</span><ins>+namespace WebCore {
+enum class DOMPasteAccessResponse : uint8_t;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class WebPage;
</span><span class="lines">@@ -88,7 +92,7 @@
</span><span class="cx">     void registerRedoStep(WebCore::UndoStep&) final;
</span><span class="cx">     void clearUndoRedoOperations() final;
</span><span class="cx"> 
</span><del>-    bool requestDOMPasteAccess() final;
</del><ins>+    WebCore::DOMPasteAccessResponse requestDOMPasteAccess(const String& originIdentifier) final;
</ins><span class="cx"> 
</span><span class="cx">     bool canCopyCut(WebCore::Frame*, bool defaultValue) const final;
</span><span class="cx">     bool canPaste(WebCore::Frame*, bool defaultValue) const final;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -139,6 +139,7 @@
</span><span class="cx"> #include <WebCore/Chrome.h>
</span><span class="cx"> #include <WebCore/CommonVM.h>
</span><span class="cx"> #include <WebCore/ContextMenuController.h>
</span><ins>+#include <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> #include <WebCore/DataTransfer.h>
</span><span class="cx"> #include <WebCore/DatabaseManager.h>
</span><span class="cx"> #include <WebCore/DeprecatedGlobalSettings.h>
</span><span class="lines">@@ -6440,13 +6441,11 @@
</span><span class="cx">     callback(wasGranted);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool WebPage::requestDOMPasteAccess()
</del><ins>+WebCore::DOMPasteAccessResponse WebPage::requestDOMPasteAccess(const String& originIdentifier)
</ins><span class="cx"> {
</span><del>-    bool granted = false;
-    if (!sendSyncWithDelayedReply(Messages::WebPageProxy::RequestDOMPasteAccess(rectForElementAtInteractionLocation()), Messages::WebPageProxy::RequestDOMPasteAccess::Reply(granted)))
-        return false;
-
-    return granted;
</del><ins>+    auto response = WebCore::DOMPasteAccessResponse::DeniedForGesture;
+    sendSyncWithDelayedReply(Messages::WebPageProxy::RequestDOMPasteAccess(rectForElementAtInteractionLocation(), originIdentifier), Messages::WebPageProxy::RequestDOMPasteAccess::Reply(response));
+    return response;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::simulateDeviceOrientationChange(double alpha, double beta, double gamma)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -171,6 +171,7 @@
</span><span class="cx"> class VisiblePosition;
</span><span class="cx"> 
</span><span class="cx"> enum SyntheticClickType : int8_t;
</span><ins>+enum class DOMPasteAccessResponse : uint8_t;
</ins><span class="cx"> enum class DragHandlingMethod : uint8_t;
</span><span class="cx"> enum class ShouldTreatAsContinuingLoad : bool;
</span><span class="cx"> enum class TextIndicatorPresentationTransition : uint8_t;
</span><span class="lines">@@ -1144,7 +1145,7 @@
</span><span class="cx">         return sendSync(WTFMove(message), WTFMove(reply), m_pageID, Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool requestDOMPasteAccess();
</del><ins>+    WebCore::DOMPasteAccessResponse requestDOMPasteAccess(const String& originIdentifier);
</ins><span class="cx">     WebCore::IntRect rectForElementAtInteractionLocation() const;
</span><span class="cx"> 
</span><span class="cx">     const Optional<WebCore::Color>& backgroundColor() const { return m_backgroundColor; }
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/ChangeLog  2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog     2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2019-03-02  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Programmatic paste access should be granted when copying and pasting within the same origin
+        https://bugs.webkit.org/show_bug.cgi?id=195053
+        <rdar://problem/48134710>
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebCoreSupport/WebEditorClient.h:
+
</ins><span class="cx"> 2019-03-01  Tim Horton  <timothy_horton@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove unused code in WebKitLegacy
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h   2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h      2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx">  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><ins>+#import <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> #import <WebCore/EditorClient.h>
</span><span class="cx"> #import <WebCore/TextCheckerClient.h>
</span><span class="cx"> #import <WebCore/VisibleSelection.h>
</span><span class="lines">@@ -80,7 +81,7 @@
</span><span class="cx">     void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) final;
</span><span class="cx"> 
</span><span class="cx">     void setInsertionPasteboard(const String&) final;
</span><del>-    bool requestDOMPasteAccess() final { return false; }
</del><ins>+    WebCore::DOMPasteAccessResponse requestDOMPasteAccess(const String&) final { return WebCore::DOMPasteAccessResponse::DeniedForGesture; }
</ins><span class="cx"> 
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx">     void uppercaseWord() final;
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/ChangeLog (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/ChangeLog  2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKitLegacy/win/ChangeLog     2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2019-03-02  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Programmatic paste access should be granted when copying and pasting within the same origin
+        https://bugs.webkit.org/show_bug.cgi?id=195053
+        <rdar://problem/48134710>
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebCoreSupport/WebEditorClient.h:
+
</ins><span class="cx"> 2019-02-20  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Finish removing String::format
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.h (242316 => 242317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.h   2019-03-02 20:54:59 UTC (rev 242316)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.h      2019-03-02 21:50:43 UTC (rev 242317)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><span class="cx"> #include "WebKit.h"
</span><ins>+#include <WebCore/DOMPasteAccess.h>
</ins><span class="cx"> #include <WebCore/EditorClient.h>
</span><span class="cx"> #include <WebCore/TextCheckerClient.h>
</span><span class="cx"> 
</span><span class="lines">@@ -114,7 +115,7 @@
</span><span class="cx">     void requestCheckingOfString(WebCore::TextCheckingRequest&, const WebCore::VisibleSelection&) final { }
</span><span class="cx">     bool performTwoStepDrop(WebCore::DocumentFragment&, WebCore::Range&, bool) final { return false; }
</span><span class="cx"> 
</span><del>-    bool requestDOMPasteAccess() final { return false; }
</del><ins>+    WebCore::DOMPasteAccessResponse requestDOMPasteAccess(const String&) final { return WebCore::DOMPasteAccessResponse::DeniedForGesture; }
</ins><span class="cx"> 
</span><span class="cx">     WebCore::TextCheckerClient* textChecker() final { return this; }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>