haikuwebkit/Source/WebCore/dom/MouseEventInit.idl

37 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

Update WheelEvent / MouseEvent to stop using legacy [ConstructorTemplate=Event] https://bugs.webkit.org/show_bug.cgi?id=163254 Reviewed by Darin Adler. Source/WebCore: Update WheelEvent / MouseEvent to stop using legacy [ConstructorTemplate=Event] and use a regular constructor instead, as in the specification: - https://www.w3.org/TR/uievents/#interface-mouseevent - https://www.w3.org/TR/uievents/#interface-wheelevent * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GenerateDictionaryHeader): Fix our broken dependency tracking when it comes to dictionaries. * dom/MouseEvent.cpp: (WebCore::MouseEvent::create): (WebCore::MouseEvent::MouseEvent): * dom/MouseEvent.h: * dom/MouseEvent.idl: * dom/MouseEventInit.h: Added. * dom/MouseEventInit.idl: Added. * dom/MouseRelatedEvent.cpp: (WebCore::MouseRelatedEvent::MouseRelatedEvent): * dom/MouseRelatedEvent.h: * dom/UIEventWithKeyState.h: (WebCore::UIEventWithKeyState::UIEventWithKeyState): * dom/WheelEvent.cpp: (WebCore::WheelEvent::WheelEvent): * dom/WheelEvent.h: * dom/WheelEvent.idl: LayoutTests: Update existing tests now that: - Exception messages are now slightly different in some cases. - We now throw when an invalid relatedTarget type is passed in the dictionary. * fast/events/constructors/mouse-event-constructor.html: * fast/events/constructors/wheel-event-constructor.html: * platform/mac/fast/events/constructors/mouse-event-constructor-expected.txt: * platform/mac/fast/events/constructors/wheel-event-constructor-expected.txt: Canonical link: https://commits.webkit.org/181089@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207041 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-11 04:43:26 +00:00
/*
* 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.
*/
// https://w3c.github.io/uievents/#idl-mouseeventinit
Update WheelEvent / MouseEvent to stop using legacy [ConstructorTemplate=Event] https://bugs.webkit.org/show_bug.cgi?id=163254 Reviewed by Darin Adler. Source/WebCore: Update WheelEvent / MouseEvent to stop using legacy [ConstructorTemplate=Event] and use a regular constructor instead, as in the specification: - https://www.w3.org/TR/uievents/#interface-mouseevent - https://www.w3.org/TR/uievents/#interface-wheelevent * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GenerateDictionaryHeader): Fix our broken dependency tracking when it comes to dictionaries. * dom/MouseEvent.cpp: (WebCore::MouseEvent::create): (WebCore::MouseEvent::MouseEvent): * dom/MouseEvent.h: * dom/MouseEvent.idl: * dom/MouseEventInit.h: Added. * dom/MouseEventInit.idl: Added. * dom/MouseRelatedEvent.cpp: (WebCore::MouseRelatedEvent::MouseRelatedEvent): * dom/MouseRelatedEvent.h: * dom/UIEventWithKeyState.h: (WebCore::UIEventWithKeyState::UIEventWithKeyState): * dom/WheelEvent.cpp: (WebCore::WheelEvent::WheelEvent): * dom/WheelEvent.h: * dom/WheelEvent.idl: LayoutTests: Update existing tests now that: - Exception messages are now slightly different in some cases. - We now throw when an invalid relatedTarget type is passed in the dictionary. * fast/events/constructors/mouse-event-constructor.html: * fast/events/constructors/wheel-event-constructor.html: * platform/mac/fast/events/constructors/mouse-event-constructor-expected.txt: * platform/mac/fast/events/constructors/wheel-event-constructor-expected.txt: Canonical link: https://commits.webkit.org/181089@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207041 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-11 04:43:26 +00:00
dictionary MouseEventInit : EventModifierInit {
long screenX = 0;
long screenY = 0;
long clientX = 0;
long clientY = 0;
[Pointer Events] Add support for chorded button interactions https://bugs.webkit.org/show_bug.cgi?id=198462 Reviewed by Dean Jackson. LayoutTests/imported/w3c: Mark the progression for web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover.html which proves the correct implementation of the chorded button interactions section of the Pointer Events spec. To do that, we also had to make use of the "button" parameter used in WPT tests action sequences, which allows the test to indicate which mouse button is pressed. Finally, there is now a change in the pointerevent_pointermove_on_chorded_mouse_button.html results, another source change is required to get this test to fully pass. * web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt: * web-platform-tests/pointerevents/pointerevent_pointermove_on_chorded_mouse_button-expected.txt: * web-platform-tests/resources/testdriver-vendor.js: (dispatchMouseActions): Source/WebCore: Pointer events differ from mouse events in that pressing a button on a mouse and then pressing a second button would yield two "mousedown" events but a single "pointerdown" event, for the first time we're transitioning from a state where no button is pressed at all, and then a "pointermove" event to indicate an additional button has been pressed. This is what the Pointer Events specification calls "chorded button interactions". See https://w3c.github.io/pointerevents/#chorded-button-interactions for the full details. To implement this, we no longer directly call PointerEvent::create() from Element::dispatchMouseEvent() but instead call the new PointerCaptureController::pointerEventForMouseEvent() which implements the required logic to determine for "mousedown" and "mouseup" mouse events, if we're transitioning from or to a state where no button is pressed at all. While that basic change is pretty small, a wider change was required to report the correct value for a PointerEvents' "button" property which should return "-1" when there is no change in pressed button state compared to any previous pointer event. Up until now, MouseEvent.button was an "unsigned short", as specified up to and including DOM Level 2 Events. But the UI Events spec says that property is a "short", and PointerEvent is the only interface where a "-1" value is used. This required some changes throughout our codebase since we used a "-1" value to specify that no button was pressed when dealing with NSEvent input and going through PlatformMouseEvent and eventually MouseEvent. So now we change the various NoButton enum values to be "-2" and use that value, which is not going to be used for any mouse button, as the value reflected as "0" through MouseEvent.button, as specified by UI Events. Furthermore, we identified another issue: MouseEvent.buttons would always return 0 in DRT and WKTR. We rely upon that value in PointerCaptureController::pointerEventForMouseEvent() and so we had to make that work for the relevant WPT test, web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover.html, to pass and show a correct implementation of chorded button interactions. The details of the work required for this is in Tools/ChangeLog. * dom/Element.cpp: (WebCore::Element::dispatchMouseEvent): * dom/MouseEvent.cpp: (WebCore::MouseEvent::create): (WebCore::MouseEvent::MouseEvent): (WebCore::MouseEvent::initMouseEvent): (WebCore::MouseEvent::initMouseEventQuirk): * dom/MouseEvent.h: (WebCore::MouseEvent::button const): * dom/MouseEvent.idl: * dom/MouseEventInit.h: * dom/MouseEventInit.idl: * dom/PointerEvent.cpp: (WebCore::PointerEvent::create): (WebCore::PointerEvent::PointerEvent): * dom/PointerEvent.h: * loader/NavigationAction.h: * page/PointerCaptureController.cpp: (WebCore::PointerCaptureController::pointerEventForMouseEvent): * page/PointerCaptureController.h: * platform/PlatformMouseEvent.h: Source/WebKit: Update to use -2 instead of -1 for NoButton. * Shared/API/c/WKEvent.h: * Shared/WebEvent.h: Source/WebKitLegacy/mac: Update -[DOMMouseEvent button] to be a "short" and update the noButton value from -1 to -2. * DOM/DOMMouseEvent.h: * DOM/DOMMouseEvent.mm: (-[DOMMouseEvent button]): * WebView/WebPDFView.mm: (-[WebPDFView PDFViewWillClickOnLink:withURL:]): Tools: Until now, MouseEvent.buttons would always return 0 when used within DRT and WKTR as [NSEvent pressedMouseButtons], used by PlatformMouseEventBuilder to set the m_buttons value eventually used to set MouseEvent.buttons, not account for the NSEvent created through the eventSender JS object in tests. To fix this, we now track the pressed mouse buttons within DRT and WKTR as mouseDown() and mouseUp() are called, and swizzle [NSEvent pressedMouseButtons] to return that value. In the case of DRT, one test would fail when swizzling this method in the case where the target view for the event would be the DRTMockScroller, a subclass of NSScroller. So we only swizzle when the target view is *not* an NSScroller or a subclass. Finally, we change the NoMouseButton enum value from -1 to -2 to adjust to MouseEvent.button now being a "short". * DumpRenderTree/mac/EventSendingController.mm: (swizzledEventPressedMouseButtons): (-[EventSendingController mouseDown:withModifiers:]): (-[EventSendingController mouseUp:withModifiers:]): (-[EventSendingController mouseMoveToX:Y:]): * TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm: * WebKitTestRunner/EventSenderProxy.h: (WTR::EventSenderProxy::mouseButtonsCurrentlyDown const): * WebKitTestRunner/mac/EventSenderProxy.mm: (WTR::swizzledEventPressedMouseButtons): (WTR::EventSenderProxy::mouseDown): (WTR::EventSenderProxy::mouseUp): (WTR::EventSenderProxy::mouseMoveTo): LayoutTests: Update some tests and their expectations due to MouseEvent.buttons now returning the correct value in DRT and WKTR and MouseEvent.button now being a "short" instead of an "unsigned short". * fast/events/constructors/mouse-event-constructor-expected.txt: * fast/events/constructors/mouse-event-constructor.html: Update the test to test the boundary values for "short" instead of "unsigned short" as well as the new "magic" value of -2 for no button, which ends up being reported as 0. * fast/events/constructors/wheel-event-constructor-expected.txt: * fast/events/constructors/wheel-event-constructor.html: Update the test to test the boundary values for "short" instead of "unsigned short" as well as the new "magic" value of -2 for no button, which ends up being reported as 0. * fast/events/fire-mousedown-while-pressing-mouse-button.html: Rewrite this test to always use MouseEvent.buttons and adjust the bitmask expectations which were way off. * platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt: * platform/mac-highsierra/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt: * platform/mac-highsierra-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_mouse_capture_change_hover-expected.txt: This test fails differently in WK1 and WK2 and will be addressed in a future patch. Canonical link: https://commits.webkit.org/212560@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246103 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-06-05 08:41:30 +00:00
short button = 0;
[Mac] Add support for MouseEvent.buttons https://bugs.webkit.org/show_bug.cgi?id=178214 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: Rebaseline test now that more checks are passing. * web-platform-tests/dom/events/Event-subclasses-constructors-expected.txt: Source/WebCore: Add support for MouseEvent.buttons on Mac as per: - https://www.w3.org/TR/uievents/#ref-for-dom-mouseevent-buttons-1 This is supported by Firefox and Chrome already. No new tests, rebaselined existing test. * dom/Element.cpp: (WebCore::Element::dispatchMouseEvent): * dom/MouseEvent.cpp: (WebCore::MouseEvent::create): (WebCore::MouseEvent::MouseEvent): * dom/MouseEvent.h: (WebCore::MouseEvent::buttons const): * dom/MouseEvent.idl: * dom/MouseEventInit.h: * dom/MouseEventInit.idl: * dom/SimulatedClick.cpp: * dom/WheelEvent.cpp: * page/EventHandler.cpp: (WebCore::EventHandler::dispatchDragEvent): * platform/PlatformMouseEvent.h: (WebCore::PlatformMouseEvent::buttons const): * platform/mac/PlatformEventFactoryMac.mm: (WebCore::currentlyPressedMouseButtons): (WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder): Source/WebKit: * Shared/WebEvent.h: (WebKit::WebMouseEvent::buttons const): * Shared/WebEventConversion.cpp: (WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent): * Shared/WebMouseEvent.cpp: (WebKit::WebMouseEvent::WebMouseEvent): (WebKit::WebMouseEvent::encode const): (WebKit::WebMouseEvent::decode): * Shared/mac/WebEventFactory.mm: (WebKit::currentlyPressedMouseButtons): (WebKit::WebEventFactory::createWebMouseEvent): * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::showContextMenuAtPoint): * WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::createWebEvent const): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::navigateToPDFLinkWithSimulatedClick): (WebKit::WebPage::simulateMouseDown): (WebKit::WebPage::simulateMouseUp): (WebKit::WebPage::simulateMouseMotion): Source/WebKitLegacy/mac: * WebView/WebPDFView.mm: (-[WebPDFView PDFViewWillClickOnLink:withURL:]): Canonical link: https://commits.webkit.org/194481@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223264 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-13 00:24:21 +00:00
unsigned short buttons = 0;
Update WheelEvent / MouseEvent to stop using legacy [ConstructorTemplate=Event] https://bugs.webkit.org/show_bug.cgi?id=163254 Reviewed by Darin Adler. Source/WebCore: Update WheelEvent / MouseEvent to stop using legacy [ConstructorTemplate=Event] and use a regular constructor instead, as in the specification: - https://www.w3.org/TR/uievents/#interface-mouseevent - https://www.w3.org/TR/uievents/#interface-wheelevent * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GenerateDictionaryHeader): Fix our broken dependency tracking when it comes to dictionaries. * dom/MouseEvent.cpp: (WebCore::MouseEvent::create): (WebCore::MouseEvent::MouseEvent): * dom/MouseEvent.h: * dom/MouseEvent.idl: * dom/MouseEventInit.h: Added. * dom/MouseEventInit.idl: Added. * dom/MouseRelatedEvent.cpp: (WebCore::MouseRelatedEvent::MouseRelatedEvent): * dom/MouseRelatedEvent.h: * dom/UIEventWithKeyState.h: (WebCore::UIEventWithKeyState::UIEventWithKeyState): * dom/WheelEvent.cpp: (WebCore::WheelEvent::WheelEvent): * dom/WheelEvent.h: * dom/WheelEvent.idl: LayoutTests: Update existing tests now that: - Exception messages are now slightly different in some cases. - We now throw when an invalid relatedTarget type is passed in the dictionary. * fast/events/constructors/mouse-event-constructor.html: * fast/events/constructors/wheel-event-constructor.html: * platform/mac/fast/events/constructors/mouse-event-constructor-expected.txt: * platform/mac/fast/events/constructors/wheel-event-constructor-expected.txt: Canonical link: https://commits.webkit.org/181089@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207041 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-11 04:43:26 +00:00
EventTarget? relatedTarget = null;
};