Changeset 196598 in webkit
- Timestamp:
- Feb 15, 2016 1:38:25 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r196595 r196598 1 2016-02-15 Jiewen Tan <jiewen_tan@apple.com> 2 3 Refine SimulatedMouseEvent to support Event.isTrusted 4 https://bugs.webkit.org/show_bug.cgi?id=154133 5 <rdar://problem/24616246> 6 7 Reviewed by Darin Adler. 8 9 * imported/blink/fast/events/event-trusted-expected.txt: 10 * imported/blink/fast/events/event-trusted.html: 11 1 12 2016-02-15 Ryan Haddad <ryanhaddad@apple.com> 2 13 -
trunk/LayoutTests/imported/blink/fast/events/event-trusted-expected.txt
r196520 r196598 9 9 PASS redispatched is true 10 10 PASS originalEvent.isTrusted is false 11 PASS originalEvent.isTrusted is false 11 12 PASS successfullyParsed is true 12 13 -
trunk/LayoutTests/imported/blink/fast/events/event-trusted.html
r196520 r196598 37 37 shouldBeTrue("redispatched"); 38 38 shouldBeFalse("originalEvent.isTrusted"); 39 40 originalEvent = null; 41 element.removeEventListener('click', redispatch); 42 element.addEventListener('click', originalDispatch); 43 element.click(); 44 shouldBeFalse("originalEvent.isTrusted"); 39 45 } 40 46 -
trunk/Source/WebCore/CMakeLists.txt
r196594 r196598 1511 1511 dom/SelectorQuery.cpp 1512 1512 dom/ShadowRoot.cpp 1513 dom/SimulatedClick.cpp 1513 1514 dom/SlotAssignment.cpp 1514 1515 dom/SpaceSplitString.cpp -
trunk/Source/WebCore/ChangeLog
r196594 r196598 1 2016-02-15 Jiewen Tan <jiewen_tan@apple.com> 2 3 Refine SimulatedMouseEvent to support Event.isTrusted 4 https://bugs.webkit.org/show_bug.cgi?id=154133 5 <rdar://problem/24616246> 6 7 Reviewed by Darin Adler. 8 9 This patch extracts everything related to create/dispatch SimulatedMouseEvent from MouseEvent.h/cpp 10 and EventDispatcher.h/cpp, and produces SimulateClick.h/cpp which will handle simulated click solely. 11 After that, we hide the SimulatedMouseEvent and only expose simulateClick to be called. The reason is 12 that we both want to tell whether the call sites are from user agent/bindings and keep the 13 SimulatedMouseEvent intact. 14 15 Also, this patch separate Element::dispatchSimulatedClick into two: one for the user agent, and another 16 for the bindings. Therefore, HTMLElement.click will be treated as untrusted. 17 18 Some of the changes in this patch referred Blink r200401: 19 https://codereview.chromium.org/1285793004 20 21 Modified test: 22 LayoutTests/imported/blink/fast/events/event-trusted.html 23 24 * CMakeLists.txt: 25 * WebCore.xcodeproj/project.pbxproj: 26 * dom/Element.cpp: 27 (WebCore::Element::dispatchSimulatedClick): 28 (WebCore::Element::dispatchSimulatedClickForBindings): 29 * dom/Element.h: 30 * dom/EventDispatcher.cpp: 31 (WebCore::EventDispatcher::dispatchSimulatedClick): Deleted. 32 * dom/EventDispatcher.h: 33 * dom/MouseEvent.cpp: 34 (WebCore::SimulatedMouseEvent::create): Deleted. 35 (WebCore::SimulatedMouseEvent::~SimulatedMouseEvent): Deleted. 36 (WebCore::SimulatedMouseEvent::SimulatedMouseEvent): Deleted. 37 * dom/MouseEvent.h: 38 * dom/SimulatedClick.cpp: Added. 39 (WebCore::simulateMouseEvent): 40 (WebCore::simulateClick): 41 * dom/SimulatedClick.h: Added. 42 * html/HTMLElement.cpp: 43 (WebCore::HTMLElement::click): 44 1 45 2016-02-15 Joseph Pecoraro <pecoraro@apple.com> 2 46 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r196594 r196598 2312 2312 550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; }; 2313 2313 550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2314 572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; }; 2315 572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */; }; 2314 2316 580371611A66F00A00BAF519 /* ClipRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5803715F1A66F00A00BAF519 /* ClipRect.cpp */; }; 2315 2317 580371621A66F00A00BAF519 /* ClipRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 580371601A66F00A00BAF519 /* ClipRect.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 9850 9852 550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 9851 9853 55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; }; 9854 572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = "<group>"; }; 9855 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = "<group>"; }; 9852 9856 5803715F1A66F00A00BAF519 /* ClipRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClipRect.cpp; sourceTree = "<group>"; }; 9853 9857 580371601A66F00A00BAF519 /* ClipRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipRect.h; sourceTree = "<group>"; }; … … 24356 24360 A6D169631346B4C1000EB770 /* ShadowRoot.h */, 24357 24361 9B19B67E1B964E5200348745 /* ShadowRoot.idl */, 24362 572A7F201C6E5719009C6149 /* SimulatedClick.h */, 24363 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */, 24358 24364 31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */, 24359 24365 9B532EA11BA928570038A827 /* SlotAssignment.cpp */, … … 28063 28069 B2227AA00D00BF220071B782 /* SVGRenderingIntent.h in Headers */, 28064 28070 BC2274790E8366E200E7F975 /* SVGRenderStyle.h in Headers */, 28071 572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */, 28065 28072 BC22747B0E8366E200E7F975 /* SVGRenderStyleDefs.h in Headers */, 28066 28073 436708F212D9CA4B00044234 /* SVGRenderSupport.h in Headers */, … … 31436 31443 E1FF8F5F1807442100132674 /* SubtleCrypto.cpp in Sources */, 31437 31444 93B2D8180F9920EE006AE6B2 /* SuddenTermination.mm in Sources */, 31445 572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */, 31438 31446 087558C513B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp in Sources */, 31439 31447 62C1217C11AB9E77003C462C /* SuspendableTimer.cpp in Sources */, -
trunk/Source/WebCore/dom/Element.cpp
r196560 r196598 78 78 #include "SelectorQuery.h" 79 79 #include "Settings.h" 80 #include "SimulatedClick.h" 80 81 #include "StyleProperties.h" 81 82 #include "StyleResolver.h" … … 313 314 void Element::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions eventOptions, SimulatedClickVisualOptions visualOptions) 314 315 { 315 EventDispatcher::dispatchSimulatedClick(this, underlyingEvent, eventOptions, visualOptions); 316 simulateClick(*this, underlyingEvent, eventOptions, visualOptions, SimulatedClickCreationOptions::FromUserAgent); 317 } 318 319 void Element::dispatchSimulatedClickForBindings(Event* underlyingEvent) 320 { 321 simulateClick(*this, underlyingEvent, SendNoEvents, DoNotShowPressedLook, SimulatedClickCreationOptions::FromBindings); 316 322 } 317 323 -
trunk/Source/WebCore/dom/Element.h
r196430 r196598 460 460 bool dispatchKeyEvent(const PlatformKeyboardEvent&); 461 461 void dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook); 462 void dispatchSimulatedClickForBindings(Event* underlyingEvent); 462 463 void dispatchFocusInEvent(const AtomicString& eventType, RefPtr<Element>&& oldFocusedElement); 463 464 void dispatchFocusOutEvent(const AtomicString& eventType, RefPtr<Element>&& newFocusedElement); -
trunk/Source/WebCore/dom/EventDispatcher.cpp
r196009 r196598 126 126 } 127 127 128 void EventDispatcher::dispatchSimulatedClick(Element* element, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions visualOptions)129 {130 if (element->isDisabledFormControl())131 return;132 133 static NeverDestroyed<HashSet<Element*>> elementsDispatchingSimulatedClicks;134 if (!elementsDispatchingSimulatedClicks.get().add(element).isNewEntry)135 return;136 137 if (mouseEventOptions == SendMouseOverUpDownEvents)138 dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mouseoverEvent, element->document().defaultView(), underlyingEvent, element));139 140 if (mouseEventOptions != SendNoEvents)141 dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mousedownEvent, element->document().defaultView(), underlyingEvent, element));142 element->setActive(true, visualOptions == ShowPressedLook);143 if (mouseEventOptions != SendNoEvents)144 dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mouseupEvent, element->document().defaultView(), underlyingEvent, element));145 element->setActive(false);146 147 // always send click148 dispatchEvent(element, SimulatedMouseEvent::create(eventNames().clickEvent, element->document().defaultView(), underlyingEvent, element));149 150 elementsDispatchingSimulatedClicks.get().remove(element);151 }152 153 128 static void callDefaultEventHandlersInTheBubblingOrder(Event& event, const EventPath& path) 154 129 { -
trunk/Source/WebCore/dom/EventDispatcher.h
r195927 r196598 40 40 bool dispatchEvent(Node*, Event&); 41 41 void dispatchScopedEvent(Node&, Event&); 42 void dispatchSimulatedClick(Element*, Event* underlyingEvent, SimulatedClickMouseEventOptions, SimulatedClickVisualOptions);43 42 44 43 } -
trunk/Source/WebCore/dom/MouseEvent.cpp
r196400 r196598 252 252 } 253 253 254 Ref<SimulatedMouseEvent> SimulatedMouseEvent::create(const AtomicString& eventType, AbstractView* view, PassRefPtr<Event> underlyingEvent, Element* target)255 {256 return adoptRef(*new SimulatedMouseEvent(eventType, view, underlyingEvent, target));257 }258 259 SimulatedMouseEvent::~SimulatedMouseEvent()260 {261 }262 263 SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, AbstractView* view, PassRefPtr<Event> underlyingEvent, Element* target)264 : MouseEvent(eventType, true, true, underlyingEvent ? underlyingEvent->timeStamp() : currentTime(), view, 0, 0, 0, 0, 0,265 #if ENABLE(POINTER_LOCK)266 0, 0,267 #endif268 false, false, false, false, 0, 0, 0, 0, true)269 {270 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {271 m_ctrlKey = keyStateEvent->ctrlKey();272 m_altKey = keyStateEvent->altKey();273 m_shiftKey = keyStateEvent->shiftKey();274 m_metaKey = keyStateEvent->metaKey();275 }276 setUnderlyingEvent(underlyingEvent.get());277 278 if (is<MouseEvent>(this->underlyingEvent())) {279 MouseEvent& mouseEvent = downcast<MouseEvent>(*this->underlyingEvent());280 m_screenLocation = mouseEvent.screenLocation();281 initCoordinates(mouseEvent.clientLocation());282 } else if (target) {283 m_screenLocation = target->screenRect().center();284 initCoordinates(LayoutPoint(target->clientRect().center()));285 }286 }287 288 254 } // namespace WebCore -
trunk/Source/WebCore/dom/MouseEvent.h
r196400 r196598 33 33 34 34 struct MouseEventInit : public MouseRelatedEventInit { 35 int clientX { 0};36 int clientY { 0};37 unsigned short button { 0};35 int clientX { 0 }; 36 int clientY { 0 }; 37 unsigned short button { 0 }; 38 38 RefPtr<EventTarget> relatedTarget; 39 39 }; … … 130 130 }; 131 131 132 class SimulatedMouseEvent final : public MouseEvent {133 public:134 static Ref<SimulatedMouseEvent> create(const AtomicString& eventType, AbstractView*, PassRefPtr<Event> underlyingEvent, Element* target);135 virtual ~SimulatedMouseEvent();136 137 private:138 SimulatedMouseEvent(const AtomicString& eventType, AbstractView*, PassRefPtr<Event> underlyingEvent, Element* target);139 };140 141 132 } // namespace WebCore 142 133 -
trunk/Source/WebCore/html/HTMLElement.cpp
r196123 r196598 810 810 void HTMLElement::click() 811 811 { 812 dispatchSimulatedClick (nullptr, SendNoEvents, DoNotShowPressedLook);812 dispatchSimulatedClickForBindings(nullptr); 813 813 } 814 814
Note: See TracChangeset
for help on using the changeset viewer.