<!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>[196598] 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/196598">196598</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-02-15 13:38:25 -0800 (Mon, 15 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Refine SimulatedMouseEvent to support Event.isTrusted
https://bugs.webkit.org/show_bug.cgi?id=154133
&lt;rdar://problem/24616246&gt;

Reviewed by Darin Adler.

Source/WebCore:

This patch extracts everything related to create/dispatch SimulatedMouseEvent from MouseEvent.h/cpp
and EventDispatcher.h/cpp, and produces SimulateClick.h/cpp which will handle simulated click solely.
After that, we hide the SimulatedMouseEvent and only expose simulateClick to be called. The reason is
that we both want to tell whether the call sites are from user agent/bindings and keep the
SimulatedMouseEvent intact.

Also, this patch separate Element::dispatchSimulatedClick into two: one for the user agent, and another
for the bindings. Therefore, HTMLElement.click will be treated as untrusted.

Some of the changes in this patch referred Blink <a href="http://trac.webkit.org/projects/webkit/changeset/200401">r200401</a>:
https://codereview.chromium.org/1285793004

Modified test:
LayoutTests/imported/blink/fast/events/event-trusted.html

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/Element.cpp:
(WebCore::Element::dispatchSimulatedClick):
(WebCore::Element::dispatchSimulatedClickForBindings):
* dom/Element.h:
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchSimulatedClick): Deleted.
* dom/EventDispatcher.h:
* dom/MouseEvent.cpp:
(WebCore::SimulatedMouseEvent::create): Deleted.
(WebCore::SimulatedMouseEvent::~SimulatedMouseEvent): Deleted.
(WebCore::SimulatedMouseEvent::SimulatedMouseEvent): Deleted.
* dom/MouseEvent.h:
* dom/SimulatedClick.cpp: Added.
(WebCore::simulateMouseEvent):
(WebCore::simulateClick):
* dom/SimulatedClick.h: Added.
* html/HTMLElement.cpp:
(WebCore::HTMLElement::click):

LayoutTests:

* imported/blink/fast/events/event-trusted-expected.txt:
* imported/blink/fast/events/event-trusted.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedblinkfasteventseventtrustedexpectedtxt">trunk/LayoutTests/imported/blink/fast/events/event-trusted-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedblinkfasteventseventtrustedhtml">trunk/LayoutTests/imported/blink/fast/events/event-trusted.html</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</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="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementh">trunk/Source/WebCore/dom/Element.h</a></li>
<li><a href="#trunkSourceWebCoredomEventDispatchercpp">trunk/Source/WebCore/dom/EventDispatcher.cpp</a></li>
<li><a href="#trunkSourceWebCoredomEventDispatcherh">trunk/Source/WebCore/dom/EventDispatcher.h</a></li>
<li><a href="#trunkSourceWebCoredomMouseEventcpp">trunk/Source/WebCore/dom/MouseEvent.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMouseEventh">trunk/Source/WebCore/dom/MouseEvent.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementcpp">trunk/Source/WebCore/html/HTMLElement.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoredomSimulatedClickcpp">trunk/Source/WebCore/dom/SimulatedClick.cpp</a></li>
<li><a href="#trunkSourceWebCoredomSimulatedClickh">trunk/Source/WebCore/dom/SimulatedClick.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/LayoutTests/ChangeLog        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-02-15  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Refine SimulatedMouseEvent to support Event.isTrusted
+        https://bugs.webkit.org/show_bug.cgi?id=154133
+        &lt;rdar://problem/24616246&gt;
+
+        Reviewed by Darin Adler.
+
+        * imported/blink/fast/events/event-trusted-expected.txt:
+        * imported/blink/fast/events/event-trusted.html:
+
</ins><span class="cx"> 2016-02-15  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Marking animations/animation-delay-changed.html as flaky on ios-simulator
</span></span></pre></div>
<a id="trunkLayoutTestsimportedblinkfasteventseventtrustedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/blink/fast/events/event-trusted-expected.txt (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/blink/fast/events/event-trusted-expected.txt        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/LayoutTests/imported/blink/fast/events/event-trusted-expected.txt        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -8,6 +8,7 @@
</span><span class="cx"> PASS originalEvent.isTrusted is true
</span><span class="cx"> PASS redispatched is true
</span><span class="cx"> PASS originalEvent.isTrusted is false
</span><ins>+PASS originalEvent.isTrusted is false
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsimportedblinkfasteventseventtrustedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/blink/fast/events/event-trusted.html (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/blink/fast/events/event-trusted.html        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/LayoutTests/imported/blink/fast/events/event-trusted.html        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -36,6 +36,12 @@
</span><span class="cx">     element.dispatchEvent(originalEvent);
</span><span class="cx">     shouldBeTrue(&quot;redispatched&quot;);
</span><span class="cx">     shouldBeFalse(&quot;originalEvent.isTrusted&quot;);
</span><ins>+
+    originalEvent = null;
+    element.removeEventListener('click', redispatch);
+    element.addEventListener('click', originalDispatch);
+    element.click();
+    shouldBeFalse(&quot;originalEvent.isTrusted&quot;);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -1510,6 +1510,7 @@
</span><span class="cx">     dom/SecurityOriginPolicy.cpp
</span><span class="cx">     dom/SelectorQuery.cpp
</span><span class="cx">     dom/ShadowRoot.cpp
</span><ins>+    dom/SimulatedClick.cpp
</ins><span class="cx">     dom/SlotAssignment.cpp
</span><span class="cx">     dom/SpaceSplitString.cpp
</span><span class="cx">     dom/StaticNodeList.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/Source/WebCore/ChangeLog        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2016-02-15  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        Refine SimulatedMouseEvent to support Event.isTrusted
+        https://bugs.webkit.org/show_bug.cgi?id=154133
+        &lt;rdar://problem/24616246&gt;
+
+        Reviewed by Darin Adler.
+
+        This patch extracts everything related to create/dispatch SimulatedMouseEvent from MouseEvent.h/cpp
+        and EventDispatcher.h/cpp, and produces SimulateClick.h/cpp which will handle simulated click solely.
+        After that, we hide the SimulatedMouseEvent and only expose simulateClick to be called. The reason is
+        that we both want to tell whether the call sites are from user agent/bindings and keep the
+        SimulatedMouseEvent intact.
+
+        Also, this patch separate Element::dispatchSimulatedClick into two: one for the user agent, and another
+        for the bindings. Therefore, HTMLElement.click will be treated as untrusted.
+
+        Some of the changes in this patch referred Blink r200401:
+        https://codereview.chromium.org/1285793004
+
+        Modified test:
+        LayoutTests/imported/blink/fast/events/event-trusted.html
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Element.cpp:
+        (WebCore::Element::dispatchSimulatedClick):
+        (WebCore::Element::dispatchSimulatedClickForBindings):
+        * dom/Element.h:
+        * dom/EventDispatcher.cpp:
+        (WebCore::EventDispatcher::dispatchSimulatedClick): Deleted.
+        * dom/EventDispatcher.h:
+        * dom/MouseEvent.cpp:
+        (WebCore::SimulatedMouseEvent::create): Deleted.
+        (WebCore::SimulatedMouseEvent::~SimulatedMouseEvent): Deleted.
+        (WebCore::SimulatedMouseEvent::SimulatedMouseEvent): Deleted.
+        * dom/MouseEvent.h:
+        * dom/SimulatedClick.cpp: Added.
+        (WebCore::simulateMouseEvent):
+        (WebCore::simulateClick):
+        * dom/SimulatedClick.h: Added.
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::click):
+
</ins><span class="cx"> 2016-02-15  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Web Workers have no access to console for debugging
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -2311,6 +2311,8 @@
</span><span class="cx">                 53EF766C16531994004CBE49 /* SettingsMacros.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 53EF766A16530A61004CBE49 /* SettingsMacros.h */; };
</span><span class="cx">                 550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
</span><span class="cx">                 550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; };
+                572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */; };
</ins><span class="cx">                 580371611A66F00A00BAF519 /* ClipRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5803715F1A66F00A00BAF519 /* ClipRect.cpp */; };
</span><span class="cx">                 580371621A66F00A00BAF519 /* ClipRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 580371601A66F00A00BAF519 /* ClipRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 580371641A66F1D300BAF519 /* LayerFragment.h in Headers */ = {isa = PBXBuildFile; fileRef = 580371631A66F1D300BAF519 /* LayerFragment.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -9849,6 +9851,8 @@
</span><span class="cx">                 550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = &quot;&lt;group&gt;&quot;; tabWidth = 8; usesTabs = 0; };
</span><span class="cx">                 550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = &quot;&lt;group&gt;&quot;; tabWidth = 8; usesTabs = 0; };
</span><span class="cx">                 55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 5803715F1A66F00A00BAF519 /* ClipRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClipRect.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 580371601A66F00A00BAF519 /* ClipRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipRect.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 580371631A66F1D300BAF519 /* LayerFragment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerFragment.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -24355,6 +24359,8 @@
</span><span class="cx">                                 A6D169611346B49B000EB770 /* ShadowRoot.cpp */,
</span><span class="cx">                                 A6D169631346B4C1000EB770 /* ShadowRoot.h */,
</span><span class="cx">                                 9B19B67E1B964E5200348745 /* ShadowRoot.idl */,
</span><ins>+                                572A7F201C6E5719009C6149 /* SimulatedClick.h */,
+                                572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */,
</ins><span class="cx">                                 31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */,
</span><span class="cx">                                 9B532EA11BA928570038A827 /* SlotAssignment.cpp */,
</span><span class="cx">                                 9B532EA21BA928570038A827 /* SlotAssignment.h */,
</span><span class="lines">@@ -28062,6 +28068,7 @@
</span><span class="cx">                                 197B180C1506353200E4ADA8 /* SVGRenderingContext.h in Headers */,
</span><span class="cx">                                 B2227AA00D00BF220071B782 /* SVGRenderingIntent.h in Headers */,
</span><span class="cx">                                 BC2274790E8366E200E7F975 /* SVGRenderStyle.h in Headers */,
</span><ins>+                                572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */,
</ins><span class="cx">                                 BC22747B0E8366E200E7F975 /* SVGRenderStyleDefs.h in Headers */,
</span><span class="cx">                                 436708F212D9CA4B00044234 /* SVGRenderSupport.h in Headers */,
</span><span class="cx">                                 436708F412D9CA4B00044234 /* SVGRenderTreeAsText.h in Headers */,
</span><span class="lines">@@ -31435,6 +31442,7 @@
</span><span class="cx">                                 7E8FADC4199A95B100714968 /* SubresourceLoaderCocoa.mm in Sources */,
</span><span class="cx">                                 E1FF8F5F1807442100132674 /* SubtleCrypto.cpp in Sources */,
</span><span class="cx">                                 93B2D8180F9920EE006AE6B2 /* SuddenTermination.mm in Sources */,
</span><ins>+                                572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */,
</ins><span class="cx">                                 087558C513B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp in Sources */,
</span><span class="cx">                                 62C1217C11AB9E77003C462C /* SuspendableTimer.cpp in Sources */,
</span><span class="cx">                                 B22279730D00BF220071B782 /* SVGAElement.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/Source/WebCore/dom/Element.cpp        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -77,6 +77,7 @@
</span><span class="cx"> #include &quot;ScrollLatchingState.h&quot;
</span><span class="cx"> #include &quot;SelectorQuery.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><ins>+#include &quot;SimulatedClick.h&quot;
</ins><span class="cx"> #include &quot;StyleProperties.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><span class="cx"> #include &quot;StyleTreeResolver.h&quot;
</span><span class="lines">@@ -312,9 +313,14 @@
</span><span class="cx"> 
</span><span class="cx"> void Element::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions eventOptions, SimulatedClickVisualOptions visualOptions)
</span><span class="cx"> {
</span><del>-    EventDispatcher::dispatchSimulatedClick(this, underlyingEvent, eventOptions, visualOptions);
</del><ins>+    simulateClick(*this, underlyingEvent, eventOptions, visualOptions, SimulatedClickCreationOptions::FromUserAgent);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Element::dispatchSimulatedClickForBindings(Event* underlyingEvent)
+{
+    simulateClick(*this, underlyingEvent, SendNoEvents, DoNotShowPressedLook, SimulatedClickCreationOptions::FromBindings);
+}
+
</ins><span class="cx"> Ref&lt;Node&gt; Element::cloneNodeInternal(Document&amp; targetDocument, CloningOperation type)
</span><span class="cx"> {
</span><span class="cx">     switch (type) {
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.h (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.h        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/Source/WebCore/dom/Element.h        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -459,6 +459,7 @@
</span><span class="cx">     bool dispatchWheelEvent(const PlatformWheelEvent&amp;);
</span><span class="cx">     bool dispatchKeyEvent(const PlatformKeyboardEvent&amp;);
</span><span class="cx">     void dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook);
</span><ins>+    void dispatchSimulatedClickForBindings(Event* underlyingEvent);
</ins><span class="cx">     void dispatchFocusInEvent(const AtomicString&amp; eventType, RefPtr&lt;Element&gt;&amp;&amp; oldFocusedElement);
</span><span class="cx">     void dispatchFocusOutEvent(const AtomicString&amp; eventType, RefPtr&lt;Element&gt;&amp;&amp; newFocusedElement);
</span><span class="cx">     virtual void dispatchFocusEvent(RefPtr&lt;Element&gt;&amp;&amp; oldFocusedElement, FocusDirection);
</span></span></pre></div>
<a id="trunkSourceWebCoredomEventDispatchercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/EventDispatcher.cpp        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -125,31 +125,6 @@
</span><span class="cx">     ScopedEventQueue::singleton().enqueueEvent(event);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void EventDispatcher::dispatchSimulatedClick(Element* element, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions visualOptions)
-{
-    if (element-&gt;isDisabledFormControl())
-        return;
-
-    static NeverDestroyed&lt;HashSet&lt;Element*&gt;&gt; elementsDispatchingSimulatedClicks;
-    if (!elementsDispatchingSimulatedClicks.get().add(element).isNewEntry)
-        return;
-
-    if (mouseEventOptions == SendMouseOverUpDownEvents)
-        dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mouseoverEvent, element-&gt;document().defaultView(), underlyingEvent, element));
-
-    if (mouseEventOptions != SendNoEvents)
-        dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mousedownEvent, element-&gt;document().defaultView(), underlyingEvent, element));
-    element-&gt;setActive(true, visualOptions == ShowPressedLook);
-    if (mouseEventOptions != SendNoEvents)
-        dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mouseupEvent, element-&gt;document().defaultView(), underlyingEvent, element));
-    element-&gt;setActive(false);
-
-    // always send click
-    dispatchEvent(element, SimulatedMouseEvent::create(eventNames().clickEvent, element-&gt;document().defaultView(), underlyingEvent, element));
-
-    elementsDispatchingSimulatedClicks.get().remove(element);
-}
-
</del><span class="cx"> static void callDefaultEventHandlersInTheBubblingOrder(Event&amp; event, const EventPath&amp; path)
</span><span class="cx"> {
</span><span class="cx">     if (path.isEmpty())
</span></span></pre></div>
<a id="trunkSourceWebCoredomEventDispatcherh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/EventDispatcher.h (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/EventDispatcher.h        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/Source/WebCore/dom/EventDispatcher.h        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -39,7 +39,6 @@
</span><span class="cx"> 
</span><span class="cx"> bool dispatchEvent(Node*, Event&amp;);
</span><span class="cx"> void dispatchScopedEvent(Node&amp;, Event&amp;);
</span><del>-void dispatchSimulatedClick(Element*, Event* underlyingEvent, SimulatedClickMouseEventOptions, SimulatedClickVisualOptions);
</del><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomMouseEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MouseEvent.cpp (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MouseEvent.cpp        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/Source/WebCore/dom/MouseEvent.cpp        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -251,38 +251,4 @@
</span><span class="cx">     return WTFMove(clonedMouseEvent);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref&lt;SimulatedMouseEvent&gt; SimulatedMouseEvent::create(const AtomicString&amp; eventType, AbstractView* view, PassRefPtr&lt;Event&gt; underlyingEvent, Element* target)
-{
-    return adoptRef(*new SimulatedMouseEvent(eventType, view, underlyingEvent, target));
-}
-
-SimulatedMouseEvent::~SimulatedMouseEvent()
-{
-}
-
-SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString&amp; eventType, AbstractView* view, PassRefPtr&lt;Event&gt; underlyingEvent, Element* target)
-    : MouseEvent(eventType, true, true, underlyingEvent ? underlyingEvent-&gt;timeStamp() : currentTime(), view, 0, 0, 0, 0, 0,
-#if ENABLE(POINTER_LOCK)
-                 0, 0,
-#endif
-                 false, false, false, false, 0, 0, 0, 0, true)
-{
-    if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {
-        m_ctrlKey = keyStateEvent-&gt;ctrlKey();
-        m_altKey = keyStateEvent-&gt;altKey();
-        m_shiftKey = keyStateEvent-&gt;shiftKey();
-        m_metaKey = keyStateEvent-&gt;metaKey();
-    }
-    setUnderlyingEvent(underlyingEvent.get());
-
-    if (is&lt;MouseEvent&gt;(this-&gt;underlyingEvent())) {
-        MouseEvent&amp; mouseEvent = downcast&lt;MouseEvent&gt;(*this-&gt;underlyingEvent());
-        m_screenLocation = mouseEvent.screenLocation();
-        initCoordinates(mouseEvent.clientLocation());
-    } else if (target) {
-        m_screenLocation = target-&gt;screenRect().center();
-        initCoordinates(LayoutPoint(target-&gt;clientRect().center()));
-    }
-}
-
</del><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoredomMouseEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MouseEvent.h (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MouseEvent.h        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/Source/WebCore/dom/MouseEvent.h        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -32,9 +32,9 @@
</span><span class="cx"> class PlatformMouseEvent;
</span><span class="cx"> 
</span><span class="cx"> struct MouseEventInit : public MouseRelatedEventInit {
</span><del>-    int clientX {0};
-    int clientY {0};
-    unsigned short button {0};
</del><ins>+    int clientX { 0 };
+    int clientY { 0 };
+    unsigned short button { 0 };
</ins><span class="cx">     RefPtr&lt;EventTarget&gt; relatedTarget;
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -129,15 +129,6 @@
</span><span class="cx">     RefPtr&lt;DataTransfer&gt; m_dataTransfer;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-class SimulatedMouseEvent final : public MouseEvent {
-public:
-    static Ref&lt;SimulatedMouseEvent&gt; create(const AtomicString&amp; eventType, AbstractView*, PassRefPtr&lt;Event&gt; underlyingEvent, Element* target);
-    virtual ~SimulatedMouseEvent();
-
-private:
-    SimulatedMouseEvent(const AtomicString&amp; eventType, AbstractView*, PassRefPtr&lt;Event&gt; underlyingEvent, Element* target);
-};
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> SPECIALIZE_TYPE_TRAITS_EVENT(MouseEvent)
</span></span></pre></div>
<a id="trunkSourceWebCoredomSimulatedClickcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/SimulatedClick.cpp (0 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/SimulatedClick.cpp                                (rev 0)
+++ trunk/Source/WebCore/dom/SimulatedClick.cpp        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -0,0 +1,105 @@
</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. ``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
+ * 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;SimulatedClick.h&quot;
+
+#include &quot;DataTransfer.h&quot;
+#include &quot;Element.h&quot;
+#include &quot;EventDispatcher.h&quot;
+#include &quot;MouseEvent.h&quot;
+#include &lt;wtf/CurrentTime.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
+
+namespace WebCore {
+
+class SimulatedMouseEvent final : public MouseEvent {
+public:
+    static Ref&lt;SimulatedMouseEvent&gt; create(const AtomicString&amp; eventType, AbstractView* view, RefPtr&lt;Event&gt;&amp;&amp; underlyingEvent, Element&amp; target)
+    {
+        return adoptRef(*new SimulatedMouseEvent(eventType, view, WTFMove(underlyingEvent), target));
+    }
+
+private:
+    SimulatedMouseEvent(const AtomicString&amp; eventType, AbstractView* view, RefPtr&lt;Event&gt;&amp;&amp; underlyingEvent, Element&amp; target)
+        : MouseEvent(eventType, true, true, underlyingEvent ? underlyingEvent-&gt;timeStamp() : currentTime(), view, 0, 0, 0, 0, 0,
+#if ENABLE(POINTER_LOCK)
+                     0, 0,
+#endif
+                     false, false, false, false, 0, 0, 0, 0, true)
+    {
+        if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {
+            m_ctrlKey = keyStateEvent-&gt;ctrlKey();
+            m_altKey = keyStateEvent-&gt;altKey();
+            m_shiftKey = keyStateEvent-&gt;shiftKey();
+            m_metaKey = keyStateEvent-&gt;metaKey();
+        }
+        setUnderlyingEvent(underlyingEvent.get());
+
+        if (is&lt;MouseEvent&gt;(this-&gt;underlyingEvent())) {
+            MouseEvent&amp; mouseEvent = downcast&lt;MouseEvent&gt;(*this-&gt;underlyingEvent());
+            m_screenLocation = mouseEvent.screenLocation();
+            initCoordinates(mouseEvent.clientLocation());
+        } else {
+            m_screenLocation = target.screenRect().center();
+            initCoordinates(LayoutPoint(target.clientRect().center()));
+        }
+    }
+
+};
+
+static void simulateMouseEvent(const AtomicString&amp; eventType, Element&amp; element, Event* underlyingEvent, SimulatedClickCreationOptions creationOptions)
+{
+    auto event = SimulatedMouseEvent::create(eventType, element.document().defaultView(), underlyingEvent, element);
+    if (creationOptions == SimulatedClickCreationOptions::FromBindings)
+        event.get().setUntrusted();
+    EventDispatcher::dispatchEvent(&amp;element, event.get());
+}
+
+void simulateClick(Element&amp; element, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions visualOptions, SimulatedClickCreationOptions creationOptions)
+{
+    if (element.isDisabledFormControl())
+        return;
+
+    static NeverDestroyed&lt;HashSet&lt;Element*&gt;&gt; elementsDispatchingSimulatedClicks;
+    if (!elementsDispatchingSimulatedClicks.get().add(&amp;element).isNewEntry)
+        return;
+
+    if (mouseEventOptions == SendMouseOverUpDownEvents)
+        simulateMouseEvent(eventNames().mouseoverEvent, element, underlyingEvent, creationOptions);
+
+    if (mouseEventOptions != SendNoEvents)
+        simulateMouseEvent(eventNames().mousedownEvent, element, underlyingEvent, creationOptions);
+    element.setActive(true, visualOptions == ShowPressedLook);
+    if (mouseEventOptions != SendNoEvents)
+        simulateMouseEvent(eventNames().mouseupEvent, element, underlyingEvent, creationOptions);
+    element.setActive(false);
+
+    simulateMouseEvent(eventNames().clickEvent, element, underlyingEvent, creationOptions);
+
+    elementsDispatchingSimulatedClicks.get().remove(&amp;element);
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoredomSimulatedClickh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/SimulatedClick.h (0 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/SimulatedClick.h                                (rev 0)
+++ trunk/Source/WebCore/dom/SimulatedClick.h        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -0,0 +1,45 @@
</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. ``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
+ * 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.
+ */
+
+#ifndef SimulatedClick_h
+#define SimulatedClick_h
+
+#include &quot;SimulatedClickOptions.h&quot;
+
+namespace WebCore {
+
+class Element;
+class Event;
+
+enum class SimulatedClickCreationOptions {
+    FromBindings,
+    FromUserAgent
+};
+
+void simulateClick(Element&amp;, Event* underlyingEvent, SimulatedClickMouseEventOptions, SimulatedClickVisualOptions, SimulatedClickCreationOptions);
+
+} // namespace WebCore
+
+#endif /* SimulatedClick_h */
</ins></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.cpp (196597 => 196598)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.cpp        2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/Source/WebCore/html/HTMLElement.cpp        2016-02-15 21:38:25 UTC (rev 196598)
</span><span class="lines">@@ -809,7 +809,7 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLElement::click()
</span><span class="cx"> {
</span><del>-    dispatchSimulatedClick(nullptr, SendNoEvents, DoNotShowPressedLook);
</del><ins>+    dispatchSimulatedClickForBindings(nullptr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLElement::accessKeyAction(bool sendMouseEvents)
</span></span></pre>
</div>
</div>

</body>
</html>