haikuwebkit/LayoutTests/pointerevents/mouse/pointerdown-prevent-default...

38 lines
1.1 KiB
HTML
Raw Permalink Normal View History

Support Pointer Events on macOS https://bugs.webkit.org/show_bug.cgi?id=195008 <rdar://problem/47454419> Patch by Antoine Quint <graouts@apple.com> on 2019-02-27 Reviewed by Dean Jackson. Source/JavaScriptCore: * Configurations/FeatureDefines.xcconfig: Source/WebCore: We now dispatch relevant pointer events as we prepare to dispatch mouse events. In most cases, this means we dispatch a pointer event of the same type, with "mouse" being substituted by "pointer", and with the same properties with the exception that if preventDefault() is called for a "pointerdown" event, the matching "mousedown" will not be dispatched, and the same behavior also extends to "pointerup". Tests: pointerevents/mouse/over-enter-out-leave.html pointerevents/mouse/pointer-capture.html pointerevents/mouse/pointer-event-basic-properties.html pointerevents/mouse/pointer-events-before-mouse-events.html pointerevents/mouse/pointerdown-prevent-default.html * Configurations/FeatureDefines.xcconfig: * dom/Document.cpp: All of the touch-action related members and functions should be iOS-specific since the touch-action property does not have any effect on macOS. (WebCore::Document::invalidateRenderingDependentRegions): (WebCore::Document::nodeWillBeRemoved): (WebCore::Document::updateTouchActionElements): * dom/Document.h: * dom/Element.cpp: (WebCore::Element::dispatchMouseEvent): Dispatch a pointer event matching the mouse event that is about to be dispatched. If preventDefault() is called in the event handler for either "pointerdown" or "pointerup", do not proceed with dispatching the mouse event. * dom/PointerEvent.cpp: (WebCore::pointerEventType): (WebCore::PointerEvent::create): * dom/PointerEvent.h: * page/EventHandler.cpp: Check both the pointer and mouse events to see if we need to dispatch "enter" and "leave" events. (WebCore::hierarchyHasCapturingEventListeners): (WebCore::EventHandler::updateMouseEventTargetNode): * page/PointerCaptureController.cpp: Fix a build error which only happened on macOS. (WebCore::PointerCaptureController::PointerCaptureController): Create the CapturingData for the unique mouse pointer. (WebCore::PointerCaptureController::hasPointerCapture): The code did not match the spec cited in the comment, only the pending target override needs to be considered to determine whether a given element has pointer capture enabled. (WebCore::PointerCaptureController::dispatchEvent): Dispatch the provided pointer event, accounting for pointer capture if it is set. * page/PointerLockController.cpp: Fix a build error which only happened on macOS. * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::resolveElement): Code related to touch-action is only relevant to iOS. Source/WebCore/PAL: * Configurations/FeatureDefines.xcconfig: Source/WebKit: * Configurations/FeatureDefines.xcconfig: Source/WebKitLegacy/mac: Add a WebKitLegacy API to enable and disable the Pointer Events runtime feature. * Configurations/FeatureDefines.xcconfig: * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences pointerEventsEnabled]): (-[WebPreferences setPointerEventsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Tools: * DumpRenderTree/mac/DumpRenderTree.mm: (enableExperimentalFeatures): Enable the PointerEvents runtime feature in DumpRenderTree such that tests targeting WK1 may test the Pointer Events feature. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: * platform/mac-wk1/TestExpectations: Mark select tests as failures due to webkit.org/b/195008. * platform/mac/TestExpectations: Enable the new mouse-based tests. * pointerevents/mouse/over-enter-out-leave-expected.txt: Added. * pointerevents/mouse/over-enter-out-leave.html: Added. * pointerevents/mouse/pointer-capture-expected.txt: Added. * pointerevents/mouse/pointer-capture.html: Added. * pointerevents/mouse/pointer-event-basic-properties-expected.txt: Added. * pointerevents/mouse/pointer-event-basic-properties.html: Added. * pointerevents/mouse/pointer-events-before-mouse-events-expected.txt: Added. * pointerevents/mouse/pointer-events-before-mouse-events.html: Added. * pointerevents/mouse/pointerdown-prevent-default-expected.txt: Added. * pointerevents/mouse/pointerdown-prevent-default.html: Added. * pointerevents/utils.js: (prototype.clear): Canonical link: https://commits.webkit.org/209453@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242137 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-27 19:02:03 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
</head>
<body>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../utils.js"></script>
<script>
'use strict';
target_test((target, test) => {
const eventTracker = new EventTracker(target, ["pointerdown", "mousedown"]);
// Press the mouse once without calling preventDefault().
eventSender.mouseMoveTo(50, 50);
eventSender.mouseDown();
eventSender.mouseUp();
// Press it again and call preventDefault().
target.addEventListener("pointerdown", event => event.preventDefault());
eventSender.mouseMoveTo(50, 50);
eventSender.mouseDown();
eventSender.mouseUp();
eventTracker.assertMatchesEvents([
{ type: "pointerdown", x: 50, y: 50 },
{ type: "mousedown", x: 50, y: 50 },
{ type: "pointerdown", x: 50, y: 50 },
]);
test.done();
}, `Testing that calling preventDefault() when handling a "pointerdown" event does not dispatch a "mousedown" event.`);
</script>
</body>
</html>