Diff
Modified: trunk/LayoutTests/ChangeLog (196597 => 196598)
--- trunk/LayoutTests/ChangeLog 2016-02-15 21:37:10 UTC (rev 196597)
+++ trunk/LayoutTests/ChangeLog 2016-02-15 21:38:25 UTC (rev 196598)
@@ -1,3 +1,14 @@
+2016-02-15 Jiewen Tan <[email protected]>
+
+ Refine SimulatedMouseEvent to support Event.isTrusted
+ https://bugs.webkit.org/show_bug.cgi?id=154133
+ <rdar://problem/24616246>
+
+ Reviewed by Darin Adler.
+
+ * imported/blink/fast/events/event-trusted-expected.txt:
+ * imported/blink/fast/events/event-trusted.html:
+
2016-02-15 Ryan Haddad <[email protected]>
Marking animations/animation-delay-changed.html as flaky on ios-simulator
Modified: trunk/LayoutTests/imported/blink/fast/events/event-trusted-expected.txt (196597 => 196598)
--- 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)
@@ -8,6 +8,7 @@
PASS originalEvent.isTrusted is true
PASS redispatched is true
PASS originalEvent.isTrusted is false
+PASS originalEvent.isTrusted is false
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/imported/blink/fast/events/event-trusted.html (196597 => 196598)
--- 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)
@@ -36,6 +36,12 @@
element.dispatchEvent(originalEvent);
shouldBeTrue("redispatched");
shouldBeFalse("originalEvent.isTrusted");
+
+ originalEvent = null;
+ element.removeEventListener('click', redispatch);
+ element.addEventListener('click', originalDispatch);
+ element.click();
+ shouldBeFalse("originalEvent.isTrusted");
}
</script>
Modified: trunk/Source/WebCore/CMakeLists.txt (196597 => 196598)
--- 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)
@@ -1510,6 +1510,7 @@
dom/SecurityOriginPolicy.cpp
dom/SelectorQuery.cpp
dom/ShadowRoot.cpp
+ dom/SimulatedClick.cpp
dom/SlotAssignment.cpp
dom/SpaceSplitString.cpp
dom/StaticNodeList.cpp
Modified: trunk/Source/WebCore/ChangeLog (196597 => 196598)
--- 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)
@@ -1,3 +1,47 @@
+2016-02-15 Jiewen Tan <[email protected]>
+
+ Refine SimulatedMouseEvent to support Event.isTrusted
+ https://bugs.webkit.org/show_bug.cgi?id=154133
+ <rdar://problem/24616246>
+
+ 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):
+
2016-02-15 Joseph Pecoraro <[email protected]>
Web Inspector: Web Workers have no access to console for debugging
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (196597 => 196598)
--- 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)
@@ -2311,6 +2311,8 @@
53EF766C16531994004CBE49 /* SettingsMacros.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 53EF766A16530A61004CBE49 /* SettingsMacros.h */; };
550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; };
+ 572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */; };
580371611A66F00A00BAF519 /* ClipRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5803715F1A66F00A00BAF519 /* ClipRect.cpp */; };
580371621A66F00A00BAF519 /* ClipRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 580371601A66F00A00BAF519 /* ClipRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
580371641A66F1D300BAF519 /* LayerFragment.h in Headers */ = {isa = PBXBuildFile; fileRef = 580371631A66F1D300BAF519 /* LayerFragment.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9849,6 +9851,8 @@
550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; };
+ 572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = "<group>"; };
+ 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = "<group>"; };
5803715F1A66F00A00BAF519 /* ClipRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClipRect.cpp; sourceTree = "<group>"; };
580371601A66F00A00BAF519 /* ClipRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipRect.h; sourceTree = "<group>"; };
580371631A66F1D300BAF519 /* LayerFragment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerFragment.h; sourceTree = "<group>"; };
@@ -24355,6 +24359,8 @@
A6D169611346B49B000EB770 /* ShadowRoot.cpp */,
A6D169631346B4C1000EB770 /* ShadowRoot.h */,
9B19B67E1B964E5200348745 /* ShadowRoot.idl */,
+ 572A7F201C6E5719009C6149 /* SimulatedClick.h */,
+ 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */,
31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */,
9B532EA11BA928570038A827 /* SlotAssignment.cpp */,
9B532EA21BA928570038A827 /* SlotAssignment.h */,
@@ -28062,6 +28068,7 @@
197B180C1506353200E4ADA8 /* SVGRenderingContext.h in Headers */,
B2227AA00D00BF220071B782 /* SVGRenderingIntent.h in Headers */,
BC2274790E8366E200E7F975 /* SVGRenderStyle.h in Headers */,
+ 572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */,
BC22747B0E8366E200E7F975 /* SVGRenderStyleDefs.h in Headers */,
436708F212D9CA4B00044234 /* SVGRenderSupport.h in Headers */,
436708F412D9CA4B00044234 /* SVGRenderTreeAsText.h in Headers */,
@@ -31435,6 +31442,7 @@
7E8FADC4199A95B100714968 /* SubresourceLoaderCocoa.mm in Sources */,
E1FF8F5F1807442100132674 /* SubtleCrypto.cpp in Sources */,
93B2D8180F9920EE006AE6B2 /* SuddenTermination.mm in Sources */,
+ 572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */,
087558C513B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp in Sources */,
62C1217C11AB9E77003C462C /* SuspendableTimer.cpp in Sources */,
B22279730D00BF220071B782 /* SVGAElement.cpp in Sources */,
Modified: trunk/Source/WebCore/dom/Element.cpp (196597 => 196598)
--- 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)
@@ -77,6 +77,7 @@
#include "ScrollLatchingState.h"
#include "SelectorQuery.h"
#include "Settings.h"
+#include "SimulatedClick.h"
#include "StyleProperties.h"
#include "StyleResolver.h"
#include "StyleTreeResolver.h"
@@ -312,9 +313,14 @@
void Element::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions eventOptions, SimulatedClickVisualOptions visualOptions)
{
- EventDispatcher::dispatchSimulatedClick(this, underlyingEvent, eventOptions, visualOptions);
+ simulateClick(*this, underlyingEvent, eventOptions, visualOptions, SimulatedClickCreationOptions::FromUserAgent);
}
+void Element::dispatchSimulatedClickForBindings(Event* underlyingEvent)
+{
+ simulateClick(*this, underlyingEvent, SendNoEvents, DoNotShowPressedLook, SimulatedClickCreationOptions::FromBindings);
+}
+
Ref<Node> Element::cloneNodeInternal(Document& targetDocument, CloningOperation type)
{
switch (type) {
Modified: trunk/Source/WebCore/dom/Element.h (196597 => 196598)
--- 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)
@@ -459,6 +459,7 @@
bool dispatchWheelEvent(const PlatformWheelEvent&);
bool dispatchKeyEvent(const PlatformKeyboardEvent&);
void dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook);
+ void dispatchSimulatedClickForBindings(Event* underlyingEvent);
void dispatchFocusInEvent(const AtomicString& eventType, RefPtr<Element>&& oldFocusedElement);
void dispatchFocusOutEvent(const AtomicString& eventType, RefPtr<Element>&& newFocusedElement);
virtual void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection);
Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (196597 => 196598)
--- 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)
@@ -125,31 +125,6 @@
ScopedEventQueue::singleton().enqueueEvent(event);
}
-void EventDispatcher::dispatchSimulatedClick(Element* element, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions visualOptions)
-{
- if (element->isDisabledFormControl())
- return;
-
- static NeverDestroyed<HashSet<Element*>> elementsDispatchingSimulatedClicks;
- if (!elementsDispatchingSimulatedClicks.get().add(element).isNewEntry)
- return;
-
- if (mouseEventOptions == SendMouseOverUpDownEvents)
- dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mouseoverEvent, element->document().defaultView(), underlyingEvent, element));
-
- if (mouseEventOptions != SendNoEvents)
- dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mousedownEvent, element->document().defaultView(), underlyingEvent, element));
- element->setActive(true, visualOptions == ShowPressedLook);
- if (mouseEventOptions != SendNoEvents)
- dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mouseupEvent, element->document().defaultView(), underlyingEvent, element));
- element->setActive(false);
-
- // always send click
- dispatchEvent(element, SimulatedMouseEvent::create(eventNames().clickEvent, element->document().defaultView(), underlyingEvent, element));
-
- elementsDispatchingSimulatedClicks.get().remove(element);
-}
-
static void callDefaultEventHandlersInTheBubblingOrder(Event& event, const EventPath& path)
{
if (path.isEmpty())
Modified: trunk/Source/WebCore/dom/EventDispatcher.h (196597 => 196598)
--- 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)
@@ -39,7 +39,6 @@
bool dispatchEvent(Node*, Event&);
void dispatchScopedEvent(Node&, Event&);
-void dispatchSimulatedClick(Element*, Event* underlyingEvent, SimulatedClickMouseEventOptions, SimulatedClickVisualOptions);
}
Modified: trunk/Source/WebCore/dom/MouseEvent.cpp (196597 => 196598)
--- 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)
@@ -251,38 +251,4 @@
return WTFMove(clonedMouseEvent);
}
-Ref<SimulatedMouseEvent> SimulatedMouseEvent::create(const AtomicString& eventType, AbstractView* view, PassRefPtr<Event> underlyingEvent, Element* target)
-{
- return adoptRef(*new SimulatedMouseEvent(eventType, view, underlyingEvent, target));
-}
-
-SimulatedMouseEvent::~SimulatedMouseEvent()
-{
-}
-
-SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, AbstractView* view, PassRefPtr<Event> underlyingEvent, Element* target)
- : MouseEvent(eventType, true, true, underlyingEvent ? underlyingEvent->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->ctrlKey();
- m_altKey = keyStateEvent->altKey();
- m_shiftKey = keyStateEvent->shiftKey();
- m_metaKey = keyStateEvent->metaKey();
- }
- setUnderlyingEvent(underlyingEvent.get());
-
- if (is<MouseEvent>(this->underlyingEvent())) {
- MouseEvent& mouseEvent = downcast<MouseEvent>(*this->underlyingEvent());
- m_screenLocation = mouseEvent.screenLocation();
- initCoordinates(mouseEvent.clientLocation());
- } else if (target) {
- m_screenLocation = target->screenRect().center();
- initCoordinates(LayoutPoint(target->clientRect().center()));
- }
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/MouseEvent.h (196597 => 196598)
--- 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)
@@ -32,9 +32,9 @@
class PlatformMouseEvent;
struct MouseEventInit : public MouseRelatedEventInit {
- int clientX {0};
- int clientY {0};
- unsigned short button {0};
+ int clientX { 0 };
+ int clientY { 0 };
+ unsigned short button { 0 };
RefPtr<EventTarget> relatedTarget;
};
@@ -129,15 +129,6 @@
RefPtr<DataTransfer> m_dataTransfer;
};
-class SimulatedMouseEvent final : public MouseEvent {
-public:
- static Ref<SimulatedMouseEvent> create(const AtomicString& eventType, AbstractView*, PassRefPtr<Event> underlyingEvent, Element* target);
- virtual ~SimulatedMouseEvent();
-
-private:
- SimulatedMouseEvent(const AtomicString& eventType, AbstractView*, PassRefPtr<Event> underlyingEvent, Element* target);
-};
-
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_EVENT(MouseEvent)
Added: trunk/Source/WebCore/dom/SimulatedClick.cpp (0 => 196598)
--- trunk/Source/WebCore/dom/SimulatedClick.cpp (rev 0)
+++ trunk/Source/WebCore/dom/SimulatedClick.cpp 2016-02-15 21:38:25 UTC (rev 196598)
@@ -0,0 +1,105 @@
+/*
+ * 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 "config.h"
+#include "SimulatedClick.h"
+
+#include "DataTransfer.h"
+#include "Element.h"
+#include "EventDispatcher.h"
+#include "MouseEvent.h"
+#include <wtf/CurrentTime.h>
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+class SimulatedMouseEvent final : public MouseEvent {
+public:
+ static Ref<SimulatedMouseEvent> create(const AtomicString& eventType, AbstractView* view, RefPtr<Event>&& underlyingEvent, Element& target)
+ {
+ return adoptRef(*new SimulatedMouseEvent(eventType, view, WTFMove(underlyingEvent), target));
+ }
+
+private:
+ SimulatedMouseEvent(const AtomicString& eventType, AbstractView* view, RefPtr<Event>&& underlyingEvent, Element& target)
+ : MouseEvent(eventType, true, true, underlyingEvent ? underlyingEvent->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->ctrlKey();
+ m_altKey = keyStateEvent->altKey();
+ m_shiftKey = keyStateEvent->shiftKey();
+ m_metaKey = keyStateEvent->metaKey();
+ }
+ setUnderlyingEvent(underlyingEvent.get());
+
+ if (is<MouseEvent>(this->underlyingEvent())) {
+ MouseEvent& mouseEvent = downcast<MouseEvent>(*this->underlyingEvent());
+ m_screenLocation = mouseEvent.screenLocation();
+ initCoordinates(mouseEvent.clientLocation());
+ } else {
+ m_screenLocation = target.screenRect().center();
+ initCoordinates(LayoutPoint(target.clientRect().center()));
+ }
+ }
+
+};
+
+static void simulateMouseEvent(const AtomicString& eventType, Element& element, Event* underlyingEvent, SimulatedClickCreationOptions creationOptions)
+{
+ auto event = SimulatedMouseEvent::create(eventType, element.document().defaultView(), underlyingEvent, element);
+ if (creationOptions == SimulatedClickCreationOptions::FromBindings)
+ event.get().setUntrusted();
+ EventDispatcher::dispatchEvent(&element, event.get());
+}
+
+void simulateClick(Element& element, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions visualOptions, SimulatedClickCreationOptions creationOptions)
+{
+ if (element.isDisabledFormControl())
+ return;
+
+ static NeverDestroyed<HashSet<Element*>> elementsDispatchingSimulatedClicks;
+ if (!elementsDispatchingSimulatedClicks.get().add(&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(&element);
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/dom/SimulatedClick.h (0 => 196598)
--- trunk/Source/WebCore/dom/SimulatedClick.h (rev 0)
+++ trunk/Source/WebCore/dom/SimulatedClick.h 2016-02-15 21:38:25 UTC (rev 196598)
@@ -0,0 +1,45 @@
+/*
+ * 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 "SimulatedClickOptions.h"
+
+namespace WebCore {
+
+class Element;
+class Event;
+
+enum class SimulatedClickCreationOptions {
+ FromBindings,
+ FromUserAgent
+};
+
+void simulateClick(Element&, Event* underlyingEvent, SimulatedClickMouseEventOptions, SimulatedClickVisualOptions, SimulatedClickCreationOptions);
+
+} // namespace WebCore
+
+#endif /* SimulatedClick_h */
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (196597 => 196598)
--- 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)
@@ -809,7 +809,7 @@
void HTMLElement::click()
{
- dispatchSimulatedClick(nullptr, SendNoEvents, DoNotShowPressedLook);
+ dispatchSimulatedClickForBindings(nullptr);
}
void HTMLElement::accessKeyAction(bool sendMouseEvents)