<!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>[198092] 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/198092">198092</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2016-03-13 21:43:58 -0700 (Sun, 13 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement unprivileged execCommand("copy") and execCommand("cut")
<rdar://problem/24354406>
https://bugs.webkit.org/show_bug.cgi?id=146336
Reviewed by Dean Jackson.
Source/WebCore:
Test: editing/execCommand/clipboard-access-with-user-gesture.html
* WebCore.xcodeproj/project.pbxproj:
Add new files.
* editing/ClipboardAccessPolicy.h:
Added.
* editing/EditorCommand.cpp:
(WebCore::defaultValueForSupportedCopyCut):
(WebCore::supportedCopyCut):
Match other browsers and allow the copy and cut commands
to be executed when there is a user gesture.
* page/Settings.h:
Add include of ClipboardAccessPolicy.h.
* page/Settings.in:
Add new setting for ClipboardAccessPolicy
LayoutTests:
* editing/execCommand/clipboard-access-with-user-gesture-expected.txt: Added.
* editing/execCommand/clipboard-access-with-user-gesture.html: Added.
Add test for using execCommand("copy") and execCommand("cut") during a user gesture.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</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="#trunkSourceWebCoreeditingEditorCommandcpp">trunk/Source/WebCore/editing/EditorCommand.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSettingsh">trunk/Source/WebCore/page/Settings.h</a></li>
<li><a href="#trunkSourceWebCorepageSettingsin">trunk/Source/WebCore/page/Settings.in</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestseditingexecCommandclipboardaccesswithusergestureexpectedtxt">trunk/LayoutTests/editing/execCommand/clipboard-access-with-user-gesture-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingexecCommandclipboardaccesswithusergesturehtml">trunk/LayoutTests/editing/execCommand/clipboard-access-with-user-gesture.html</a></li>
<li><a href="#trunkSourceWebCoreeditingClipboardAccessPolicyh">trunk/Source/WebCore/editing/ClipboardAccessPolicy.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (198091 => 198092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-14 03:58:26 UTC (rev 198091)
+++ trunk/LayoutTests/ChangeLog        2016-03-14 04:43:58 UTC (rev 198092)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-03-13 Sam Weinig <sam@webkit.org>
+
+ Implement unprivileged execCommand("copy") and execCommand("cut")
+ <rdar://problem/24354406>
+ https://bugs.webkit.org/show_bug.cgi?id=146336
+
+ Reviewed by Dean Jackson.
+
+ * editing/execCommand/clipboard-access-with-user-gesture-expected.txt: Added.
+ * editing/execCommand/clipboard-access-with-user-gesture.html: Added.
+ Add test for using execCommand("copy") and execCommand("cut") during a user gesture.
+
</ins><span class="cx"> 2016-03-13 Dean Jackson <dino@apple.com>
</span><span class="cx">
</span><span class="cx"> DRT should enable WebGL by default on Mac
</span></span></pre></div>
<a id="trunkLayoutTestseditingexecCommandclipboardaccesswithusergestureexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/execCommand/clipboard-access-with-user-gesture-expected.txt (0 => 198092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/execCommand/clipboard-access-with-user-gesture-expected.txt         (rev 0)
+++ trunk/LayoutTests/editing/execCommand/clipboard-access-with-user-gesture-expected.txt        2016-03-14 04:43:58 UTC (rev 198092)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+This test checks that JavaScript programs can execute copy and paste commands, but only during a user gesture.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Testing copying an editableParagraph range without a user gesture.
+PASS document.queryCommandEnabled('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.queryCommandSupported('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.execCommand('copy') is false
+PASS eventSeen['copy'] is false
+
+Testing copying an editableParagraph caret without a user gesture.
+PASS document.queryCommandEnabled('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.queryCommandSupported('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.execCommand('copy') is false
+PASS eventSeen['copy'] is false
+
+Testing copying an non-editable range without a user gesture.
+PASS document.queryCommandEnabled('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.queryCommandSupported('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.execCommand('copy') is false
+PASS eventSeen['copy'] is false
+
+Testing copying an non-editable caret without a user gesture.
+PASS document.queryCommandEnabled('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.queryCommandSupported('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.execCommand('copy') is false
+PASS eventSeen['copy'] is false
+
+Testing copying an editable plaint-text range without a user gesture.
+PASS document.queryCommandEnabled('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.queryCommandSupported('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.execCommand('copy') is false
+PASS eventSeen['copy'] is false
+
+Testing copying an editable plaint-text caret without a user gesture.
+PASS document.queryCommandEnabled('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.queryCommandSupported('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.execCommand('copy') is false
+PASS eventSeen['copy'] is false
+
+Testing copying when there is no selection without a user gesture.
+PASS document.queryCommandEnabled('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.queryCommandSupported('copy') is false
+PASS eventSeen['copy'] is false
+PASS document.execCommand('copy') is false
+PASS eventSeen['copy'] is false
+
+Testing cutting an editableParagraph range without a user gesture.
+PASS document.queryCommandEnabled('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.queryCommandSupported('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.execCommand('cut') is false
+PASS eventSeen['cut'] is false
+
+Testing cutting an editableParagraph caret without a user gesture.
+PASS document.queryCommandEnabled('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.queryCommandSupported('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.execCommand('cut') is false
+PASS eventSeen['cut'] is false
+
+Testing cutting an non-editable range without a user gesture.
+PASS document.queryCommandEnabled('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.queryCommandSupported('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.execCommand('cut') is false
+PASS eventSeen['cut'] is false
+
+Testing cutting an non-editable caret without a user gesture.
+PASS document.queryCommandEnabled('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.queryCommandSupported('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.execCommand('cut') is false
+PASS eventSeen['cut'] is false
+
+Testing cutting an editable plaint-text range without a user gesture.
+PASS document.queryCommandEnabled('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.queryCommandSupported('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.execCommand('cut') is false
+PASS eventSeen['cut'] is false
+
+Testing cutting an editable plaint-text caret without a user gesture.
+PASS document.queryCommandEnabled('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.queryCommandSupported('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.execCommand('cut') is false
+PASS eventSeen['cut'] is false
+
+Testing cutting when there is no selection without a user gesture.
+PASS document.queryCommandEnabled('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.queryCommandSupported('cut') is false
+PASS eventSeen['cut'] is false
+PASS document.execCommand('cut') is false
+PASS eventSeen['cut'] is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestseditingexecCommandclipboardaccesswithusergesturehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/execCommand/clipboard-access-with-user-gesture.html (0 => 198092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/execCommand/clipboard-access-with-user-gesture.html         (rev 0)
+++ trunk/LayoutTests/editing/execCommand/clipboard-access-with-user-gesture.html        2016-03-14 04:43:58 UTC (rev 198092)
</span><span class="lines">@@ -0,0 +1,275 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+description("This test checks that JavaScript programs can execute copy and paste commands, but only during a user gesture.");
+
+// Override the test runner default befavior of allowing all keyboard access, and act more like
+// a browser.
+if (window.testRunner)
+ window.testRunner.setJavaScriptCanAccessClipboard(false);
+
+function clearSelectionContainer()
+{
+ var container = document.getElementById('container');
+ if (container)
+ container.remove();
+}
+
+function resetSelectionContainer()
+{
+ clearSelectionContainer();
+
+ var container = document.createElement("div");
+ container.id = "container";
+
+ var nonEditableParagraph = document.createElement("p");
+ nonEditableParagraph.id = "nonEditableParagraph";
+ nonEditableParagraph.appendChild(document.createTextNode("x"));
+ container.appendChild(nonEditableParagraph);
+
+ var editableParagraph = document.createElement("p");
+ editableParagraph.id = "editableParagraph";
+ editableParagraph.appendChild(document.createTextNode("x"));
+ editableParagraph.setAttribute("contentEditable", "true");
+ container.appendChild(editableParagraph);
+
+ var editablePlainTextParagraph = document.createElement("p");
+ editablePlainTextParagraph.id = "editablePlainTextParagraph";
+ editablePlainTextParagraph.appendChild(document.createTextNode("x"));
+ editablePlainTextParagraph.setAttribute("contentEditable", "plaintext-only");
+ container.appendChild(editablePlainTextParagraph);
+
+ document.body.appendChild(container);
+}
+
+function makeSelection(elementId, selectionStart, selectionEnd)
+{
+ resetSelectionContainer();
+
+ var selection = window.getSelection();
+ selection.removeAllRanges();
+
+ var element = document.getElementById(elementId);
+
+ var range = document.createRange();
+ range.setStart(element.firstChild, selectionStart);
+ range.setEnd(element.firstChild, selectionEnd);
+ selection.addRange(range);
+}
+
+var eventSeen = {
+ "copy": false,
+ "cut": false,
+ "beforecopy": false,
+ "beforecut": false
+}
+
+function resetSeenFlags()
+{
+ eventSeen.copy = false;
+ eventSeen.cut = false;
+ eventSeen.beforecopy = false;
+ eventSeen.beforecut = false;
+}
+
+document.body.oncopy = function(event)
+{
+ eventSeen["copy"] = true;
+}
+
+document.body.oncut = function()
+{
+ eventSeen["cut"] = true;
+}
+
+document.body.onbeforecopy = function()
+{
+ eventSeen["beforecopy"] = true;
+}
+
+document.body.onbeforecut = function()
+{
+ eventSeen["beforecut"] = true;
+}
+
+function test(command, enabledExpected, supportedExpected, executedExpected)
+{
+ resetSeenFlags();
+ shouldBe("document.queryCommandEnabled('" + command +"')", "" + enabledExpected);
+ shouldBeFalse("eventSeen['" + command +"']");
+
+ resetSeenFlags();
+ shouldBe("document.queryCommandSupported('" + command +"')", "" + supportedExpected);
+ shouldBeFalse("eventSeen['" + command +"']");
+
+ resetSeenFlags();
+ shouldBe("document.execCommand('" + command +"')", "" + executedExpected);
+ shouldBe("eventSeen['" + command +"']", "" + executedExpected);
+}
+
+function header(msg)
+{
+ debug("");
+ debug(msg);
+}
+
+var buttonForCopy = document.createElement("button");
+buttonForCopy.id = "copyButton";
+buttonForCopy.textContent = "Copy";
+buttonForCopy.onclick = function()
+{
+ header("Testing copying an editableParagraph range in a user gesture.")
+ makeSelection("editableParagraph", 0, 1);
+ test("copy", true, true, true);
+
+ header("Testing copying an editableParagraph caret in a user gesture.")
+ makeSelection("editableParagraph", 0, 0);
+ test("copy", false, true, true);
+
+ header("Testing copying an non-editable range in a user gesture.")
+ makeSelection("nonEditableParagraph", 0, 1);
+ test("copy", true, true, true);
+
+ header("Testing copying an non-editable caret in a user gesture.")
+ makeSelection("nonEditableParagraph", 0, 0);
+ test("copy", false, true, true);
+
+ header("Testing copying an editable plaint-text range in a user gesture.")
+ makeSelection("editablePlainTextParagraph", 0, 1);
+ test("copy", true, true, true);
+
+ header("Testing copying an editable plaint-text caret in a user gesture.")
+ makeSelection("editablePlainTextParagraph", 0, 0);
+ test("copy", false, true, true);
+
+ header("Testing copying when there is no selection in a user gesture.")
+ window.getSelection().removeAllRanges();
+ test("copy", false, true, true);
+
+ clearSelectionContainer();
+}
+document.body.appendChild(buttonForCopy);
+
+var buttonForCut = document.createElement("button");
+buttonForCut.id = "cutButton";
+buttonForCut.textContent = "Cut";
+buttonForCut.onclick = function()
+{
+ header("Testing cutting an editableParagraph range in a user gesture.")
+ makeSelection("editableParagraph", 0, 1);
+ test("cut", true, true, true);
+
+ header("Testing cutting an editableParagraph caret in a user gesture.")
+ makeSelection("editableParagraph", 0, 0);
+ test("cut", false, true, true);
+
+ header("Testing cutting an non-editable range in a user gesture.")
+ makeSelection("nonEditableParagraph", 0, 1);
+ test("cut", false, true, true);
+
+ header("Testing cutting an non-editable caret in a user gesture.")
+ makeSelection("nonEditableParagraph", 0, 0);
+ test("cut", false, true, true);
+
+ header("Testing cutting an editable plaint-text range in a user gesture.")
+ makeSelection("editablePlainTextParagraph", 0, 1);
+ test("cut", true, true, true);
+
+ header("Testing cutting an editable plaint-text caret in a user gesture.")
+ makeSelection("editablePlainTextParagraph", 0, 0);
+ test("cut", false, true, true);
+
+ header("Testing cutting when there is no selection in a user gesture.")
+ window.getSelection().removeAllRanges();
+ test("cut", false, true, true);
+
+ clearSelectionContainer();
+}
+document.body.appendChild(buttonForCut);
+
+// First test copy/cut without user gestures.
+header("Testing copying an editableParagraph range without a user gesture.")
+makeSelection("editableParagraph", 0, 1);
+test("copy", false, false, false);
+
+header("Testing copying an editableParagraph caret without a user gesture.")
+makeSelection("editableParagraph", 0, 0);
+test("copy", false, false, false);
+
+header("Testing copying an non-editable range without a user gesture.")
+makeSelection("nonEditableParagraph", 0, 1);
+test("copy", false, false, false);
+
+header("Testing copying an non-editable caret without a user gesture.")
+makeSelection("nonEditableParagraph", 0, 0);
+test("copy", false, false, false);
+
+header("Testing copying an editable plaint-text range without a user gesture.")
+makeSelection("editablePlainTextParagraph", 0, 1);
+test("copy", false, false, false);
+
+header("Testing copying an editable plaint-text caret without a user gesture.")
+makeSelection("editablePlainTextParagraph", 0, 0);
+test("copy", false, false, false);
+
+header("Testing copying when there is no selection without a user gesture.")
+window.getSelection().removeAllRanges();
+test("copy", false, false, false);
+
+clearSelectionContainer();
+
+header("Testing cutting an editableParagraph range without a user gesture.")
+makeSelection("editableParagraph", 0, 1);
+test("cut", false, false, false);
+
+header("Testing cutting an editableParagraph caret without a user gesture.")
+makeSelection("editableParagraph", 0, 0);
+test("cut", false, false, false);
+
+header("Testing cutting an non-editable range without a user gesture.")
+makeSelection("nonEditableParagraph", 0, 1);
+test("cut", false, false, false);
+
+header("Testing cutting an non-editable caret without a user gesture.")
+makeSelection("nonEditableParagraph", 0, 0);
+test("cut", false, false, false);
+
+header("Testing cutting an editable plaint-text range without a user gesture.")
+makeSelection("editablePlainTextParagraph", 0, 1);
+test("cut", false, false, false);
+
+header("Testing cutting an editable plaint-text caret without a user gesture.")
+makeSelection("editablePlainTextParagraph", 0, 0);
+test("cut", false, false, false);
+
+header("Testing cutting when there is no selection without a user gesture.")
+window.getSelection().removeAllRanges();
+test("cut", false, false, false);
+
+clearSelectionContainer();
+
+// Then test copy/cut with user gestures.
+if (window.testRunner) {
+ function clickButton(button)
+ {
+ eventSender.mouseMoveTo(button.offsetLeft + button.offsetWidth / 2, button.offsetTop + button.offsetHeight / 2);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+
+ clickButton(buttonForCopy);
+ clickButton(buttonForCut);
+
+ buttonForCopy.remove();
+ buttonForCut.remove();
+}
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198091 => 198092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-14 03:58:26 UTC (rev 198091)
+++ trunk/Source/WebCore/ChangeLog        2016-03-14 04:43:58 UTC (rev 198092)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-03-13 Sam Weinig <sam@webkit.org>
+
+ Implement unprivileged execCommand("copy") and execCommand("cut")
+ <rdar://problem/24354406>
+ https://bugs.webkit.org/show_bug.cgi?id=146336
+
+ Reviewed by Dean Jackson.
+
+ Test: editing/execCommand/clipboard-access-with-user-gesture.html
+
+ * WebCore.xcodeproj/project.pbxproj:
+ Add new files.
+
+ * editing/ClipboardAccessPolicy.h:
+ Added.
+
+ * editing/EditorCommand.cpp:
+ (WebCore::defaultValueForSupportedCopyCut):
+ (WebCore::supportedCopyCut):
+ Match other browsers and allow the copy and cut commands
+ to be executed when there is a user gesture.
+
+ * page/Settings.h:
+ Add include of ClipboardAccessPolicy.h.
+
+ * page/Settings.in:
+ Add new setting for ClipboardAccessPolicy
+
</ins><span class="cx"> 2016-03-13 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> REGRESSION (r190840): crash inside details element's slotNameFunction
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (198091 => 198092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-03-14 03:58:26 UTC (rev 198091)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-03-14 04:43:58 UTC (rev 198092)
</span><span class="lines">@@ -2733,6 +2733,7 @@
</span><span class="cx">                 7C33F35A1B4A044800502CAF /* JSCharacterDataCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C33F3581B4A044800502CAF /* JSCharacterDataCustom.cpp */; };
</span><span class="cx">                 7C33F35E1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C33F35C1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp */; };
</span><span class="cx">                 7C33F3621B4A050400502CAF /* JSDocumentFragmentCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C33F3601B4A050400502CAF /* JSDocumentFragmentCustom.cpp */; };
</span><ins>+                7C3A91E61C963B8800D1A7E3 /* ClipboardAccessPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3A91E51C963B8800D1A7E3 /* ClipboardAccessPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 7C3B79711908757B00B47A2D /* UserMessageHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3B796F1908757B00B47A2D /* UserMessageHandler.cpp */; };
</span><span class="cx">                 7C3B79721908757B00B47A2D /* UserMessageHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3B79701908757B00B47A2D /* UserMessageHandler.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 7C3E510A18DF8F3500C112F7 /* HTMLConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3E510818DF8F3500C112F7 /* HTMLConverter.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -10369,6 +10370,7 @@
</span><span class="cx">                 7C33F3581B4A044800502CAF /* JSCharacterDataCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCharacterDataCustom.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C33F35C1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentTypeCustom.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C33F3601B4A050400502CAF /* JSDocumentFragmentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentFragmentCustom.cpp; sourceTree = "<group>"; };
</span><ins>+                7C3A91E51C963B8800D1A7E3 /* ClipboardAccessPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipboardAccessPolicy.h; sourceTree = "<group>"; };
</ins><span class="cx">                 7C3B796F1908757B00B47A2D /* UserMessageHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMessageHandler.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C3B79701908757B00B47A2D /* UserMessageHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMessageHandler.h; sourceTree = "<group>"; };
</span><span class="cx">                 7C3E510818DF8F3500C112F7 /* HTMLConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLConverter.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -18844,6 +18846,7 @@
</span><span class="cx">                                 93309D8A099E64910056E581 /* ApplyStyleCommand.h */,
</span><span class="cx">                                 93309D8B099E64910056E581 /* BreakBlockquoteCommand.cpp */,
</span><span class="cx">                                 93309D8C099E64910056E581 /* BreakBlockquoteCommand.h */,
</span><ins>+                                7C3A91E51C963B8800D1A7E3 /* ClipboardAccessPolicy.h */,
</ins><span class="cx">                                 93309D8D099E64910056E581 /* CompositeEditCommand.cpp */,
</span><span class="cx">                                 93309D8E099E64910056E581 /* CompositeEditCommand.h */,
</span><span class="cx">                                 D0B0556709C6700100307E43 /* CreateLinkCommand.cpp */,
</span><span class="lines">@@ -26499,6 +26502,7 @@
</span><span class="cx">                                 BC46C1FB0C0DDC8F0020CFC3 /* JSCSSCharsetRule.h in Headers */,
</span><span class="cx">                                 409EBDC316B7F3A600CBA3FC /* JSCSSFontFaceLoadEvent.h in Headers */,
</span><span class="cx">                                 BC46C1FD0C0DDC8F0020CFC3 /* JSCSSFontFaceRule.h in Headers */,
</span><ins>+                                7C3A91E61C963B8800D1A7E3 /* ClipboardAccessPolicy.h in Headers */,
</ins><span class="cx">                                 BC46C1FF0C0DDC8F0020CFC3 /* JSCSSImportRule.h in Headers */,
</span><span class="cx">                                 316FE0720E6CCBEE00BF6088 /* JSCSSKeyframeRule.h in Headers */,
</span><span class="cx">                                 316FE0740E6CCBEE00BF6088 /* JSCSSKeyframesRule.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingClipboardAccessPolicyh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/editing/ClipboardAccessPolicy.h (0 => 198092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ClipboardAccessPolicy.h         (rev 0)
+++ trunk/Source/WebCore/editing/ClipboardAccessPolicy.h        2016-03-14 04:43:58 UTC (rev 198092)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 ClipboardAccessPolicy {
+ Allow,
+ Deny,
+ RequiresUserGesture
+};
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/EditorCommand.cpp (198091 => 198092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/EditorCommand.cpp        2016-03-14 03:58:26 UTC (rev 198091)
+++ trunk/Source/WebCore/editing/EditorCommand.cpp        2016-03-14 04:43:58 UTC (rev 198092)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> #include "StyleProperties.h"
</span><span class="cx"> #include "TypingCommand.h"
</span><span class="cx"> #include "UnlinkCommand.h"
</span><ins>+#include "UserGestureIndicator.h"
</ins><span class="cx"> #include "UserTypingGestureIndicator.h"
</span><span class="cx"> #include "htmlediting.h"
</span><span class="cx"> #include "markup.h"
</span><span class="lines">@@ -1157,12 +1158,31 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static bool defaultValueForSupportedCopyCut(Frame& frame)
+{
+ auto& settings = frame.settings();
+ if (settings.javaScriptCanAccessClipboard())
+ return true;
+
+ switch (settings.clipboardAccessPolicy()) {
+ case ClipboardAccessPolicy::Allow:
+ return true;
+ case ClipboardAccessPolicy::Deny:
+ return false;
+ case ClipboardAccessPolicy::RequiresUserGesture:
+ return UserGestureIndicator::processingUserGesture();
+ }
+
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
</ins><span class="cx"> static bool supportedCopyCut(Frame* frame)
</span><span class="cx"> {
</span><span class="cx"> if (!frame)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- bool defaultValue = frame->settings().javaScriptCanAccessClipboard();
</del><ins>+ bool defaultValue = defaultValueForSupportedCopyCut(*frame);
</ins><span class="cx">
</span><span class="cx"> EditorClient* client = frame->editor().client();
</span><span class="cx"> return client ? client->canCopyCut(frame, defaultValue) : defaultValue;
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.h (198091 => 198092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.h        2016-03-14 03:58:26 UTC (rev 198091)
+++ trunk/Source/WebCore/page/Settings.h        2016-03-14 04:43:58 UTC (rev 198092)
</span><span class="lines">@@ -27,13 +27,14 @@
</span><span class="cx"> #ifndef Settings_h
</span><span class="cx"> #define Settings_h
</span><span class="cx">
</span><ins>+#include "ClipboardAccessPolicy.h"
</ins><span class="cx"> #include "EditingBehaviorTypes.h"
</span><span class="cx"> #include "IntSize.h"
</span><del>-#include "URL.h"
</del><span class="cx"> #include "SecurityOrigin.h"
</span><span class="cx"> #include "SettingsMacros.h"
</span><span class="cx"> #include "TextFlags.h"
</span><span class="cx"> #include "Timer.h"
</span><ins>+#include "URL.h"
</ins><span class="cx"> #include <chrono>
</span><span class="cx"> #include <runtime/RuntimeFlags.h>
</span><span class="cx"> #include <unicode/uscript.h>
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.in (198091 => 198092)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.in        2016-03-14 03:58:26 UTC (rev 198091)
+++ trunk/Source/WebCore/page/Settings.in        2016-03-14 04:43:58 UTC (rev 198092)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> javaScriptCanAccessClipboard initial=false
</span><span class="cx"> shouldPrintBackgrounds initial=false
</span><span class="cx"> usesDashboardBackwardCompatibilityMode initial=false, conditional=DASHBOARD_SUPPORT
</span><ins>+clipboardAccessPolicy type=ClipboardAccessPolicy, initial=ClipboardAccessPolicy::RequiresUserGesture
</ins><span class="cx">
</span><span class="cx"> textAreasAreResizable initial=false, setNeedsStyleRecalcInAllFrames=1
</span><span class="cx"> authorAndUserStylesEnabled initial=true, setNeedsStyleRecalcInAllFrames=1
</span></span></pre>
</div>
</div>
</body>
</html>