Diff
Modified: trunk/LayoutTests/ChangeLog (277771 => 277772)
--- trunk/LayoutTests/ChangeLog 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/LayoutTests/ChangeLog 2021-05-20 02:26:07 UTC (rev 277772)
@@ -1,3 +1,16 @@
+2021-05-19 Devin Rousso <[email protected]>
+
+ Add a way to create `"wheel"` events from gesture/touch events
+ https://bugs.webkit.org/show_bug.cgi?id=225788
+ <rdar://problem/76714308>
+
+ Reviewed by Simon Fraser.
+
+ * fast/events/gesture/wheel-from-gesture.html: Added.
+ * fast/events/gesture/wheel-from-gesture-expected.txt: Added.
+
+ * TestExpectations:
+
2021-05-19 Alex Christensen <[email protected]>
Add support for Navigation Timing Level 2
Modified: trunk/LayoutTests/TestExpectations (277771 => 277772)
--- trunk/LayoutTests/TestExpectations 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/LayoutTests/TestExpectations 2021-05-20 02:26:07 UTC (rev 277772)
@@ -53,6 +53,7 @@
fast/device-orientation [ Skip ]
http/tests/device-orientation [ Skip ]
fast/events/cursors [ Skip ]
+fast/events/gesture [ Skip ]
fast/events/ios [ Skip ]
fast/events/watchos [ Skip ]
fast/events/pointer/ios [ Skip ]
Added: trunk/LayoutTests/fast/events/gesture/wheel-from-gesture-expected.txt (0 => 277772)
--- trunk/LayoutTests/fast/events/gesture/wheel-from-gesture-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/gesture/wheel-from-gesture-expected.txt 2021-05-20 02:26:07 UTC (rev 277772)
@@ -0,0 +1,57 @@
+Tests wheel event dispatching for gesture events.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test that wheel events are not dispatched if gesture events are not preventDefault.
+
+Dispatching 'gesturestart'...
+Handling 'gesturestart' event at (59, 59)...
+Handling 'wheel' event at (59, 59)...
+PASS event.ctrlKey is true
+PASS event.deltaY is within 0.01 of -1
+
+Dispatching 'gesturechange'...
+Handling 'gesturechange' event at (59, 59)...
+Handling 'wheel' event at (59, 59)...
+PASS event.ctrlKey is true
+PASS event.deltaY is within 0.01 of -2
+
+Dispatching 'gesturechange'...
+Handling 'gesturechange' event at (59, 59)...
+Handling 'wheel' event at (59, 59)...
+PASS event.ctrlKey is true
+PASS event.deltaY is within 0.01 of -3
+
+Dispatching 'gestureend'...
+Handling 'gestureend' event at (59, 59)...
+Handling 'wheel' event at (59, 59)...
+PASS event.ctrlKey is true
+PASS event.deltaY is within 0.01 of -4
+
+Test that wheel events are not dispatched if gesture events are preventDefault.
+
+Dispatching 'gesturestart'...
+Handling 'gesturestart' event at (59, 59)...
+Calling `preventDefault`...
+PASS didDispatchWheel is false
+
+Dispatching 'gesturechange'...
+Handling 'gesturechange' event at (59, 59)...
+Calling `preventDefault`...
+PASS didDispatchWheel is false
+
+Dispatching 'gesturechange'...
+Handling 'gesturechange' event at (59, 59)...
+Calling `preventDefault`...
+PASS didDispatchWheel is false
+
+Dispatching 'gestureend'...
+Handling 'gestureend' event at (59, 59)...
+Calling `preventDefault`...
+PASS didDispatchWheel is false
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/events/gesture/wheel-from-gesture.html (0 => 277772)
--- trunk/LayoutTests/fast/events/gesture/wheel-from-gesture.html (rev 0)
+++ trunk/LayoutTests/fast/events/gesture/wheel-from-gesture.html 2021-05-20 02:26:07 UTC (rev 277772)
@@ -0,0 +1,117 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#target {
+ border: 1px solid;
+ width: 100px;
+ height: 100px;
+}
+</style>
+<script src=""
+<script>
+var didDispatchWheel = false;
+
+jsTestIsAsync = true;
+
+function dispatchAndHandleGestureEvent(eventToWaitFor, scale, shouldPreventDefault) {
+ debug("");
+
+ return new Promise((resolve, reject) => {
+ function wheelHandler(event) {
+ debug(`Handling 'wheel' event at (${event.pageX}, ${event.pageY})...`);
+
+ shouldBeTrue("event.ctrlKey");
+ shouldBeCloseTo("event.deltaY", scale * -100, 0.01);
+
+ if (!shouldPreventDefault)
+ handled();
+ }
+
+ function gestureHandler(event) {
+ debug(`Handling '${event.type}' event at (${event.pageX}, ${event.pageY})...`);
+
+ if (!shouldPreventDefault)
+ return;
+
+ debug("Calling `preventDefault`...");
+ event.preventDefault();
+
+ if (event.type === eventToWaitFor) {
+ didDispatchWheel = false;
+ // Give time for a `"wheel"` event to be dispatched so failures can be found.
+ setTimeout(() => {
+ shouldBeFalse("didDispatchWheel");
+ handled();
+ });
+ }
+ }
+
+ function handled() {
+ target.removeEventListener("wheel", wheelHandler);
+ target.removeEventListener("gesturestart", gestureHandler);
+ target.removeEventListener("gesturechange", gestureHandler);
+ target.removeEventListener("gestureend", gestureHandler);
+ resolve();
+ }
+
+ target.addEventListener("wheel", wheelHandler, {once: true});
+
+ // Add listeners for each phase just in case multiple are dispatched (which would be wrong).
+ target.addEventListener("gesturestart", gestureHandler, {once: true});
+ target.addEventListener("gesturechange", gestureHandler, {once: true});
+ target.addEventListener("gestureend", gestureHandler, {once: true});
+
+ debug(`Dispatching '${eventToWaitFor}'...`);
+ switch (eventToWaitFor) {
+ case "gesturestart":
+ eventSender.scaleGestureStart(scale);
+ break;
+ case "gesturechange":
+ eventSender.scaleGestureChange(scale);
+ break;
+ case "gestureend":
+ eventSender.scaleGestureEnd(scale);
+ break;
+ }
+ });
+}
+
+async function runTest() {
+ if (!window.eventSender) {
+ debug("FAIL: This test requires window.eventSender.");
+ return;
+ }
+
+ eventSender.mouseMoveTo(target.offsetLeft + (target.offsetWidth / 2), target.offsetTop + (target.offsetHeight / 2));
+
+ debug("Test that wheel events are not dispatched if gesture events are not preventDefault.");
+ await dispatchAndHandleGestureEvent("gesturestart", 0.01, false);
+ await dispatchAndHandleGestureEvent("gesturechange", 0.02, false);
+ await dispatchAndHandleGestureEvent("gesturechange", 0.03, false);
+ await dispatchAndHandleGestureEvent("gestureend", 0.04, false);
+
+ debug("");
+
+ debug("Test that wheel events are not dispatched if gesture events are preventDefault.");
+ await dispatchAndHandleGestureEvent("gesturestart", 0.01, true);
+ await dispatchAndHandleGestureEvent("gesturechange", 0.02, true);
+ await dispatchAndHandleGestureEvent("gesturechange", 0.03, true);
+ await dispatchAndHandleGestureEvent("gestureend", 0.04, true);
+
+ debug("");
+ finishJSTest();
+}
+</script>
+</head>
+<body>
+<div id="target"></div>
+<div id="console"></div>
+<script>
+description("Tests wheel event dispatching for gesture events.");
+
+runTest();
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (277771 => 277772)
--- trunk/Source/WebCore/ChangeLog 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Source/WebCore/ChangeLog 2021-05-20 02:26:07 UTC (rev 277772)
@@ -1,3 +1,20 @@
+2021-05-19 Devin Rousso <[email protected]>
+
+ Add a way to create `"wheel"` events from gesture/touch events
+ https://bugs.webkit.org/show_bug.cgi?id=225788
+ <rdar://problem/76714308>
+
+ Reviewed by Simon Fraser.
+
+ Test: fast/events/gesture/wheel-from-gesture.html
+
+ Other browsers have taken the approach of dispatching `"wheel"` events with `ctrlKey` and
+ `deltaY` when handling multi-touch pinch-to-zoom gestures. Add helper functions to do this.
+
+ * platform/PlatformWheelEvent.h:
+ * platform/PlatformWheelEvent.cpp:
+ (WebCore::PlatformWheelEvent::createFromGesture): Added.
+
2021-05-19 Chris Dumez <[email protected]>
Introduce SQLiteStatement::columnBlobView()
Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.cpp (277771 => 277772)
--- trunk/Source/WebCore/platform/PlatformWheelEvent.cpp 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.cpp 2021-05-20 02:26:07 UTC (rev 277772)
@@ -26,12 +26,65 @@
#include "config.h"
#include "PlatformWheelEvent.h"
+#include "Scrollbar.h"
#include <wtf/text/TextStream.h>
+#if ENABLE(MAC_GESTURE_EVENTS)
+#include "PlatformGestureEventMac.h"
+#endif
+
namespace WebCore {
+#if ENABLE(MAC_GESTURE_EVENTS)
+
+PlatformWheelEvent PlatformWheelEvent::createFromGesture(const PlatformGestureEvent& platformGestureEvent, double deltaY)
+{
+ // This tries to match as much of the behavior of `WebKit::WebEventFactory::createWebWheelEvent` as
+ // possible assuming `-[NSEvent hasPreciseScrollingDeltas]` and no `-[NSEvent _scrollCount]`.
+
+ double deltaX = 0;
+ double wheelTicksX = 0;
+ double wheelTicksY = deltaY / static_cast<float>(Scrollbar::pixelsPerLineStep());
+ bool shiftKey = platformGestureEvent.modifiers().contains(PlatformEvent::Modifier::ShiftKey);
+ bool ctrlKey = true;
+ bool altKey = platformGestureEvent.modifiers().contains(PlatformEvent::Modifier::AltKey);
+ bool metaKey = platformGestureEvent.modifiers().contains(PlatformEvent::Modifier::MetaKey);
+ PlatformWheelEvent platformWheelEvent(platformGestureEvent.pos(), platformGestureEvent.globalPosition(), deltaX, deltaY, wheelTicksX, wheelTicksY, ScrollByPixelWheelEvent, shiftKey, ctrlKey, altKey, metaKey);
+
+ // PlatformEvent
+ platformWheelEvent.m_timestamp = platformGestureEvent.timestamp();
+
+ // PlatformWheelEvent
+ platformWheelEvent.m_hasPreciseScrollingDeltas = true;
+
#if ENABLE(KINETIC_SCROLLING)
+ switch (platformGestureEvent.type()) {
+ case PlatformEvent::GestureStart:
+ platformWheelEvent.m_phase = PlatformWheelEventPhase::Began;
+ break;
+ case PlatformEvent::GestureChange:
+ platformWheelEvent.m_phase = PlatformWheelEventPhase::Changed;
+ break;
+ case PlatformEvent::GestureEnd:
+ platformWheelEvent.m_phase = PlatformWheelEventPhase::Ended;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+#endif // ENABLE(KINETIC_SCROLLING)
+#if PLATFORM(COCOA)
+ platformWheelEvent.m_unacceleratedScrollingDeltaY = deltaY;
+#endif // PLATFORM(COCOA)
+
+ return platformWheelEvent;
+}
+
+#endif // ENABLE(MAC_GESTURE_EVENTS)
+
+#if ENABLE(KINETIC_SCROLLING)
+
TextStream& operator<<(TextStream& ts, PlatformWheelEventPhase phase)
{
switch (phase) {
Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.h (277771 => 277772)
--- trunk/Source/WebCore/platform/PlatformWheelEvent.h 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.h 2021-05-20 02:26:07 UTC (rev 277772)
@@ -36,6 +36,8 @@
namespace WebCore {
+class PlatformGestureEvent;
+
enum class WheelEventProcessingSteps : uint8_t {
ScrollingThread = 1 << 0,
MainThreadForScrolling = 1 << 1,
@@ -106,6 +108,10 @@
{
}
+#if ENABLE(MAC_GESTURE_EVENTS)
+ static PlatformWheelEvent createFromGesture(const PlatformGestureEvent&, double deltaY);
+#endif
+
PlatformWheelEvent copySwappingDirection() const
{
PlatformWheelEvent copy = *this;
Modified: trunk/Tools/ChangeLog (277771 => 277772)
--- trunk/Tools/ChangeLog 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/ChangeLog 2021-05-20 02:26:07 UTC (rev 277772)
@@ -1,3 +1,48 @@
+2021-05-19 Devin Rousso <[email protected]>
+
+ Add a way to create `"wheel"` events from gesture/touch events
+ https://bugs.webkit.org/show_bug.cgi?id=225788
+ <rdar://problem/76714308>
+
+ Reviewed by Simon Fraser.
+
+ * WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl:
+ * WebKitTestRunner/InjectedBundle/EventSendingController.h:
+ * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
+ (WTR::EventSendingController::scaleGestureStart): Added.
+ (WTR::EventSendingController::scaleGestureChange): Added.
+ (WTR::EventSendingController::scaleGestureEnd): Added.
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
+ * WebKitTestRunner/EventSenderProxy.h:
+ * WebKitTestRunner/mac/EventSenderProxy.mm:
+ (EventSenderCGGesturePhaseFromNSEventPhase):
+ (-[EventSenderSyntheticEvent initPressureEventAtLocation:globalLocation:stage:pressure:stageTransition:phase:time:eventNumber:window:]):
+ (-[EventSenderSyntheticEvent initMagnifyEventAtLocation:globalLocation:magnification:phase:time:eventNumber:window:]): Added.
+ (-[EventSenderSyntheticEvent magnification]): Added.
+ (WTR::EventSenderProxy::mouseDown):
+ (WTR::EventSenderProxy::mouseUp):
+ (WTR::EventSenderProxy::sendMouseDownToStartPressureEvents):
+ (WTR::EventSenderProxy::beginPressureEvent):
+ (WTR::EventSenderProxy::pressureChangeEvent):
+ (WTR::EventSenderProxy::mouseForceClick):
+ (WTR::EventSenderProxy::startAndCancelMouseForceClick):
+ (WTR::EventSenderProxy::mouseMoveTo):
+ (WTR::EventSenderProxy::scaleGestureStart): Added.
+ (WTR::EventSenderProxy::scaleGestureChange): Added.
+ (WTR::EventSenderProxy::scaleGestureEnd): Added.
+ Allow tests to synthesize scale (a.k.a. magnify) gesture events.
+
+ * WebKitTestRunner/InjectedBundle/ios/EventSenderProxyIOS.mm:
+ (WTR::EventSenderProxy::EventSenderProxy):
+ Drive-by: Rename `eventNumber` to `m_eventNumber` since it's a member variable.
+
+ * DumpRenderTree/Scripts/generate-derived-sources.sh:
+ * DumpRenderTree/DerivedSources.make:
+ * WebKitTestRunner/Scripts/generate-derived-sources.sh:
+ * WebKitTestRunner/DerivedSources.make:
+ Make sure to pass all feature flags when generating JS files from IDL files.
+
2021-05-19 Wenson Hsieh <[email protected]>
Unreviewed, try to fix the internal build after r277740
Modified: trunk/Tools/DumpRenderTree/DerivedSources.make (277771 => 277772)
--- trunk/Tools/DumpRenderTree/DerivedSources.make 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/DumpRenderTree/DerivedSources.make 2021-05-20 02:26:07 UTC (rev 277772)
@@ -21,8 +21,25 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
+PERL = perl
RUBY = ruby
+ifneq ($(SDKROOT),)
+ SDK_FLAGS = -isysroot $(SDKROOT)
+endif
+
+ifeq ($(USE_LLVM_TARGET_TRIPLES_FOR_CLANG),YES)
+ WK_CURRENT_ARCH = $(word 1, $(ARCHS))
+ TARGET_TRIPLE_FLAGS = -target $(WK_CURRENT_ARCH)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(LLVM_TARGET_TRIPLE_OS_VERSION)$(LLVM_TARGET_TRIPLE_SUFFIX)
+endif
+
+FRAMEWORK_FLAGS := $(shell echo $(BUILT_PRODUCTS_DIR) $(FRAMEWORK_SEARCH_PATHS) $(SYSTEM_FRAMEWORK_SEARCH_PATHS) | $(PERL) -e 'print "-F " . join(" -F ", split(" ", <>));')
+HEADER_FLAGS := $(shell echo $(BUILT_PRODUCTS_DIR) $(HEADER_SEARCH_PATHS) $(SYSTEM_HEADER_SEARCH_PATHS) | $(PERL) -e 'print "-I" . join(" -I", split(" ", <>));')
+FEATURE_AND_PLATFORM_DEFINES := $(shell $(CC) -std=gnu++1z -x c++ -E -P -dM $(SDK_FLAGS) $(TARGET_TRIPLE_FLAGS) $(FRAMEWORK_FLAGS) $(HEADER_FLAGS) -include "wtf/Platform.h" /dev/null | $(PERL) -ne "print if s/\#define ((HAVE_|USE_|ENABLE_|WTF_PLATFORM_)\w+) 1/\1/")
+
+# FIXME: This should list Platform.h and all the things it includes. Could do that by using the -MD flag in the CC line above.
+FEATURE_AND_PLATFORM_DEFINE_DEPENDENCIES = $(DumpRenderTree)/DerivedSources.make
+
UISCRIPTCONTEXT_DIR = $(DumpRenderTree)/../TestRunnerShared/UIScriptContext/Bindings
DUMPRENDERTREE_PREFERENCES_TEMPLATES_DIR = $(DumpRenderTree)/Scripts/PreferencesTemplates
@@ -46,9 +63,9 @@
.PHONY : all
-JS%.h JS%.cpp : %.idl $(SCRIPTS) $(IDL_ATTRIBUTES_FILE)
+JS%.h JS%.cpp : %.idl $(SCRIPTS) $(IDL_ATTRIBUTES_FILE) $(FEATURE_AND_PLATFORM_DEFINE_DEPENDENCIES)
@echo Generating bindings for $*...
- @perl -I $(WebCoreScripts) -I $(UISCRIPTCONTEXT_DIR) -I $(DumpRenderTree)/Bindings $(WebCoreScripts)/generate-bindings.pl --defines "" --include $(UISCRIPTCONTEXT_DIR) --outputDir . --generator DumpRenderTree --idlAttributesFile $(IDL_ATTRIBUTES_FILE) $<
+ $(PERL) -I $(WebCoreScripts) -I $(UISCRIPTCONTEXT_DIR) -I $(DumpRenderTree)/Bindings $(WebCoreScripts)/generate-bindings.pl --defines "$(FEATURE_AND_PLATFORM_DEFINES)" --include $(UISCRIPTCONTEXT_DIR) --outputDir . --generator DumpRenderTree --idlAttributesFile $(IDL_ATTRIBUTES_FILE) $<
all : \
$(UICONTEXT_INTERFACES:%=JS%.h) \
Modified: trunk/Tools/DumpRenderTree/Scripts/generate-derived-sources.sh (277771 => 277772)
--- trunk/Tools/DumpRenderTree/Scripts/generate-derived-sources.sh 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/DumpRenderTree/Scripts/generate-derived-sources.sh 2021-05-20 02:26:07 UTC (rev 277772)
@@ -15,5 +15,5 @@
fi
if [ "${ACTION}" = "build" -o "${ACTION}" = "install" -o "${ACTION}" = "installhdrs" ]; then
- make -f "${DumpRenderTree}/DerivedSources.make" -j `/usr/sbin/sysctl -n hw.activecpu` "${ARGS[@]}"
+ make -f "${DumpRenderTree}/DerivedSources.make" -j `/usr/sbin/sysctl -n hw.activecpu` SDKROOT="${SDKROOT}" "${ARGS[@]}"
fi
Modified: trunk/Tools/WebKitTestRunner/DerivedSources-input.xcfilelist (277771 => 277772)
--- trunk/Tools/WebKitTestRunner/DerivedSources-input.xcfilelist 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/WebKitTestRunner/DerivedSources-input.xcfilelist 2021-05-20 02:26:07 UTC (rev 277772)
@@ -5,6 +5,7 @@
$(BUILT_PRODUCTS_DIR)/usr/local/include/wtf/Scripts/Preferences/WebPreferencesExperimental.yaml
$(BUILT_PRODUCTS_DIR)/usr/local/include/wtf/Scripts/Preferences/WebPreferencesInternal.yaml
$(PROJECT_DIR)/../TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
+$(PROJECT_DIR)/DerivedSources.make
$(PROJECT_DIR)/InjectedBundle/Bindings/AccessibilityController.idl
$(PROJECT_DIR)/InjectedBundle/Bindings/AccessibilityTextMarker.idl
$(PROJECT_DIR)/InjectedBundle/Bindings/AccessibilityTextMarkerRange.idl
Modified: trunk/Tools/WebKitTestRunner/DerivedSources.make (277771 => 277772)
--- trunk/Tools/WebKitTestRunner/DerivedSources.make 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/WebKitTestRunner/DerivedSources.make 2021-05-20 02:26:07 UTC (rev 277772)
@@ -26,8 +26,25 @@
$(WebKitTestRunner)/../TestRunnerShared/UIScriptContext/Bindings \
#
+PERL = perl
RUBY = ruby
+ifneq ($(SDKROOT),)
+ SDK_FLAGS = -isysroot $(SDKROOT)
+endif
+
+ifeq ($(USE_LLVM_TARGET_TRIPLES_FOR_CLANG),YES)
+ WK_CURRENT_ARCH = $(word 1, $(ARCHS))
+ TARGET_TRIPLE_FLAGS = -target $(WK_CURRENT_ARCH)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(LLVM_TARGET_TRIPLE_OS_VERSION)$(LLVM_TARGET_TRIPLE_SUFFIX)
+endif
+
+FRAMEWORK_FLAGS := $(shell echo $(BUILT_PRODUCTS_DIR) $(FRAMEWORK_SEARCH_PATHS) $(SYSTEM_FRAMEWORK_SEARCH_PATHS) | $(PERL) -e 'print "-F " . join(" -F ", split(" ", <>));')
+HEADER_FLAGS := $(shell echo $(BUILT_PRODUCTS_DIR) $(HEADER_SEARCH_PATHS) $(SYSTEM_HEADER_SEARCH_PATHS) | $(PERL) -e 'print "-I" . join(" -I", split(" ", <>));')
+FEATURE_AND_PLATFORM_DEFINES := $(shell $(CC) -std=gnu++1z -x c++ -E -P -dM $(SDK_FLAGS) $(TARGET_TRIPLE_FLAGS) $(FRAMEWORK_FLAGS) $(HEADER_FLAGS) -include "wtf/Platform.h" /dev/null | $(PERL) -ne "print if s/\#define ((HAVE_|USE_|ENABLE_|WTF_PLATFORM_)\w+) 1/\1/")
+
+# FIXME: This should list Platform.h and all the things it includes. Could do that by using the -MD flag in the CC line above.
+FEATURE_AND_PLATFORM_DEFINE_DEPENDENCIES = $(WebKitTestRunner)/DerivedSources.make
+
WEB_PREFERENCES = \
${WTF_BUILD_SCRIPTS_DIR}/Preferences/WebPreferences.yaml \
${WTF_BUILD_SCRIPTS_DIR}/Preferences/WebPreferencesDebug.yaml \
@@ -73,9 +90,9 @@
.PHONY : all
-JS%.h JS%.cpp : %.idl $(SCRIPTS) $(IDL_ATTRIBUTES_FILE)
+JS%.h JS%.cpp : %.idl $(SCRIPTS) $(IDL_ATTRIBUTES_FILE) $(FEATURE_AND_PLATFORM_DEFINE_DEPENDENCIES)
@echo Generating bindings for $*...
- @perl -I $(WebCoreScripts) -I $(WebKitTestRunner)/InjectedBundle/Bindings -I $(WebKitTestRunner)/UIScriptContext/Bindings $(WebCoreScripts)/generate-bindings.pl --defines "" --include InjectedBundle/Bindings --include UIScriptContext/Bindings --outputDir . --generator TestRunner --idlAttributesFile $(IDL_ATTRIBUTES_FILE) $<
+ $(PERL) -I $(WebCoreScripts) -I $(WebKitTestRunner)/InjectedBundle/Bindings -I $(WebKitTestRunner)/UIScriptContext/Bindings $(WebCoreScripts)/generate-bindings.pl --defines "$(FEATURE_AND_PLATFORM_DEFINES)" --include InjectedBundle/Bindings --include UIScriptContext/Bindings --outputDir . --generator TestRunner --idlAttributesFile $(IDL_ATTRIBUTES_FILE) $<
all : \
$(INJECTED_BUNDLE_INTERFACES:%=JS%.h) \
Modified: trunk/Tools/WebKitTestRunner/EventSenderProxy.h (277771 => 277772)
--- trunk/Tools/WebKitTestRunner/EventSenderProxy.h 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/WebKitTestRunner/EventSenderProxy.h 2021-05-20 02:26:07 UTC (rev 277772)
@@ -87,6 +87,13 @@
void cancelTouchPoint(int index);
#endif
+#if ENABLE(MAC_GESTURE_EVENTS)
+ // Gesture events.
+ void scaleGestureStart(double scale);
+ void scaleGestureChange(double scale);
+ void scaleGestureEnd(double scale);
+#endif
+
private:
TestController* m_testController;
@@ -121,7 +128,7 @@
WKEventMouseButton m_clickButton { kWKEventMouseButtonNoButton };
unsigned m_mouseButtonsCurrentlyDown { 0 };
#if PLATFORM(COCOA)
- int eventNumber { 0 };
+ int m_eventNumber { 0 };
#endif
#if PLATFORM(WPE)
uint32_t m_buttonState { 0 };
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl (277771 => 277772)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl 2021-05-20 02:26:07 UTC (rev 277772)
@@ -71,5 +71,12 @@
undefined releaseTouchPoint(long index);
undefined cancelTouchPoint(long index);
#endif
+
+#if defined(ENABLE_MAC_GESTURE_EVENTS) && ENABLE_MAC_GESTURE_EVENTS
+ // Gesture events.
+ undefined scaleGestureStart(double scale);
+ undefined scaleGestureChange(double scale);
+ undefined scaleGestureEnd(double scale);
+#endif
};
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp (277771 => 277772)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp 2021-05-20 02:26:07 UTC (rev 277772)
@@ -618,6 +618,34 @@
#endif
+#if ENABLE(MAC_GESTURE_EVENTS)
+
+void EventSendingController::scaleGestureStart(double scale)
+{
+ auto body = adoptWK(WKMutableDictionaryCreate());
+ setValue(body, "SubMessage", "ScaleGestureStart");
+ setValue(body, "Scale", scale);
+ postSynchronousPageMessage("EventSender", body);
+}
+
+void EventSendingController::scaleGestureChange(double scale)
+{
+ auto body = adoptWK(WKMutableDictionaryCreate());
+ setValue(body, "SubMessage", "ScaleGestureChange");
+ setValue(body, "Scale", scale);
+ postSynchronousPageMessage("EventSender", body);
+}
+
+void EventSendingController::scaleGestureEnd(double scale)
+{
+ auto body = adoptWK(WKMutableDictionaryCreate());
+ setValue(body, "SubMessage", "ScaleGestureEnd");
+ setValue(body, "Scale", scale);
+ postSynchronousPageMessage("EventSender", body);
+}
+
+#endif // ENABLE(MAC_GESTURE_EVENTS)
+
// Object Creation
void EventSendingController::makeWindowObject(JSContextRef context)
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h (277771 => 277772)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h 2021-05-20 02:26:07 UTC (rev 277772)
@@ -89,6 +89,12 @@
void cancelTouchPoint(int index);
#endif
+#if ENABLE(MAC_GESTURE_EVENTS)
+ void scaleGestureStart(double scale);
+ void scaleGestureChange(double scale);
+ void scaleGestureEnd(double scale);
+#endif
+
private:
EventSendingController() = default;
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/ios/EventSenderProxyIOS.mm (277771 => 277772)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/ios/EventSenderProxyIOS.mm 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/ios/EventSenderProxyIOS.mm 2021-05-20 02:26:07 UTC (rev 277772)
@@ -39,7 +39,7 @@
{
UNUSED_PARAM(m_testController);
UNUSED_PARAM(m_leftMouseButtonDown);
- UNUSED_PARAM(eventNumber);
+ UNUSED_PARAM(m_eventNumber);
}
EventSenderProxy::~EventSenderProxy() = default;
Modified: trunk/Tools/WebKitTestRunner/Scripts/generate-derived-sources.sh (277771 => 277772)
--- trunk/Tools/WebKitTestRunner/Scripts/generate-derived-sources.sh 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/WebKitTestRunner/Scripts/generate-derived-sources.sh 2021-05-20 02:26:07 UTC (rev 277772)
@@ -15,5 +15,5 @@
fi
if [ "${ACTION}" = "build" -o "${ACTION}" = "install" -o "${ACTION}" = "installhdrs" ]; then
- make -f "${WebKitTestRunner}/DerivedSources.make" -j `/usr/sbin/sysctl -n hw.activecpu` "${ARGS[@]}"
+ make -f "${WebKitTestRunner}/DerivedSources.make" -j `/usr/sbin/sysctl -n hw.activecpu` SDKROOT="${SDKROOT}" "${ARGS[@]}"
fi
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (277771 => 277772)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2021-05-20 02:26:07 UTC (rev 277772)
@@ -1777,6 +1777,27 @@
return completionHandler(nullptr);
}
#endif
+
+#if ENABLE(MAC_GESTURE_EVENTS)
+ if (WKStringIsEqualToUTF8CString(subMessageName, "ScaleGestureStart")) {
+ auto scale = doubleValue(dictionary, "Scale");
+ m_eventSenderProxy->scaleGestureStart(scale);
+ return completionHandler(nullptr);
+ }
+
+ if (WKStringIsEqualToUTF8CString(subMessageName, "ScaleGestureChange")) {
+ auto scale = doubleValue(dictionary, "Scale");
+ m_eventSenderProxy->scaleGestureChange(scale);
+ return completionHandler(nullptr);
+ }
+
+ if (WKStringIsEqualToUTF8CString(subMessageName, "ScaleGestureEnd")) {
+ auto scale = doubleValue(dictionary, "Scale");
+ m_eventSenderProxy->scaleGestureEnd(scale);
+ return completionHandler(nullptr);
+ }
+#endif // ENABLE(MAC_GESTURE_EVENTS)
+
ASSERT_NOT_REACHED();
}
Modified: trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm (277771 => 277772)
--- trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm 2021-05-20 02:02:23 UTC (rev 277771)
+++ trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm 2021-05-20 02:26:07 UTC (rev 277772)
@@ -37,6 +37,7 @@
#import <WebKit/WKString.h>
#import <WebKit/WKPagePrivate.h>
#import <WebKit/WKWebView.h>
+#import <pal/spi/cocoa/IOKitSPI.h>
#import <wtf/RetainPtr.h>
@interface NSApplication (Details)
@@ -54,6 +55,7 @@
NSPoint _eventSender_location;
NSInteger _eventSender_stage;
float _eventSender_pressure;
+ CGFloat _eventSender_magnification;
CGFloat _eventSender_stageTransition;
NSEventPhase _eventSender_phase;
NSEventPhase _eventSender_momentumPhase;
@@ -65,40 +67,42 @@
}
- (id)initPressureEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation stage:(NSInteger)stage pressure:(float)pressure stageTransition:(float)stageTransition phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber window:(NSWindow *)window;
+- (id)initMagnifyEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation magnification:(CGFloat)magnification phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber window:(NSWindow *)window;
- (NSTimeInterval)timestamp;
@end
-@implementation EventSenderSyntheticEvent
-
-- (instancetype)initPressureEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation stage:(NSInteger)stage pressure:(float)pressure stageTransition:(float)stageTransition phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber window:(NSWindow *)window
+static CGSGesturePhase EventSenderCGGesturePhaseFromNSEventPhase(NSEventPhase phase)
{
- CGSGesturePhase gesturePhase;
switch (phase) {
case NSEventPhaseMayBegin:
- gesturePhase = kCGSGesturePhaseMayBegin;
- break;
+ return kCGSGesturePhaseMayBegin;
+
case NSEventPhaseBegan:
- gesturePhase = kCGSGesturePhaseBegan;
- break;
+ return kCGSGesturePhaseBegan;
+
case NSEventPhaseChanged:
- gesturePhase = kCGSGesturePhaseChanged;
- break;
+ return kCGSGesturePhaseChanged;
+
case NSEventPhaseCancelled:
- gesturePhase = kCGSGesturePhaseCancelled;
- break;
+ return kCGSGesturePhaseCancelled;
+
case NSEventPhaseEnded:
- gesturePhase = kCGSGesturePhaseEnded;
- break;
+ return kCGSGesturePhaseEnded;
+
case NSEventPhaseNone:
default:
- gesturePhase = kCGSGesturePhaseNone;
- break;
+ return kCGSGesturePhaseNone;
}
+}
+@implementation EventSenderSyntheticEvent
+
+- (instancetype)initPressureEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation stage:(NSInteger)stage pressure:(float)pressure stageTransition:(float)stageTransition phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber window:(NSWindow *)window
+{
auto cgEvent = adoptCF(CGEventCreate(nullptr));
CGEventSetType(cgEvent.get(), (CGEventType)kCGSEventGesture);
- CGEventSetIntegerValueField(cgEvent.get(), kCGEventGestureHIDType, 32);
- CGEventSetIntegerValueField(cgEvent.get(), kCGEventGesturePhase, gesturePhase);
+ CGEventSetIntegerValueField(cgEvent.get(), kCGEventGestureHIDType, kIOHIDEventTypeForce);
+ CGEventSetIntegerValueField(cgEvent.get(), kCGEventGesturePhase, EventSenderCGGesturePhaseFromNSEventPhase(phase));
CGEventSetDoubleValueField(cgEvent.get(), kCGEventStagePressure, pressure);
CGEventSetDoubleValueField(cgEvent.get(), kCGEventTransitionProgress, pressure);
CGEventSetIntegerValueField(cgEvent.get(), kCGEventGestureStage, stageTransition);
@@ -123,6 +127,29 @@
return self;
}
+- (id)initMagnifyEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation magnification:(CGFloat)magnification phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber window:(NSWindow *)window
+{
+ auto cgEvent = adoptCF(CGEventCreate(nullptr));
+ CGEventSetType(cgEvent.get(), (CGEventType)kCGSEventGesture);
+ CGEventSetIntegerValueField(cgEvent.get(), kCGEventGestureHIDType, kIOHIDEventTypeZoom);
+ CGEventSetIntegerValueField(cgEvent.get(), kCGEventGesturePhase, EventSenderCGGesturePhaseFromNSEventPhase(phase));
+ CGEventSetDoubleValueField(cgEvent.get(), kCGEventGestureZoomValue, magnification);
+
+ if (!(self = [super _initWithCGEvent:cgEvent.get() eventRef:nullptr]))
+ return nil;
+
+ _eventSender_location = location;
+ _eventSender_locationInWindow = globalLocation;
+ _eventSender_magnification = magnification;
+ _eventSender_phase = phase;
+ _eventSender_timestamp = time;
+ _eventSender_eventNumber = eventNumber;
+ _eventSender_window = window;
+ _eventSender_type = NSEventTypeMagnify;
+
+ return self;
+}
+
- (CGFloat)stageTransition
{
return _eventSender_stageTransition;
@@ -163,6 +190,11 @@
return _eventSender_pressure;
}
+- (CGFloat)magnification
+{
+ return _eventSender_magnification;
+}
+
- (NSEventPhase)phase
{
return _eventSender_phase;
@@ -308,7 +340,7 @@
timestamp:absoluteTimeForEventTime(currentEventTime())
windowNumber:[m_testController->mainWebView()->platformWindow() windowNumber]
context:[NSGraphicsContext currentContext]
- eventNumber:++eventNumber
+ eventNumber:++m_eventNumber
clickCount:m_clickCount
pressure:0.0];
@@ -334,7 +366,7 @@
timestamp:absoluteTimeForEventTime(currentEventTime())
windowNumber:[m_testController->mainWebView()->platformWindow() windowNumber]
context:[NSGraphicsContext currentContext]
- eventNumber:++eventNumber
+ eventNumber:++m_eventNumber
clickCount:m_clickCount
pressure:0.0];
@@ -366,7 +398,7 @@
timestamp:absoluteTimeForEventTime(currentEventTime())
windowNumber:[m_testController->mainWebView()->platformWindow() windowNumber]
context:[NSGraphicsContext currentContext]
- eventNumber:++eventNumber
+ eventNumber:++m_eventNumber
clickCount:m_clickCount
pressure:0.0];
@@ -390,7 +422,7 @@
stageTransition:0
phase:NSEventPhaseBegan
time:absoluteTimeForEventTime(currentEventTime())
- eventNumber:++eventNumber
+ eventNumber:++m_eventNumber
window:[m_testController->mainWebView()->platformView() window]]);
return event;
@@ -405,7 +437,7 @@
stageTransition:direction == PressureChangeDirection::Increasing ? 0.5 : -0.5
phase:NSEventPhaseChanged
time:absoluteTimeForEventTime(currentEventTime())
- eventNumber:++eventNumber
+ eventNumber:++m_eventNumber
window:[m_testController->mainWebView()->platformView() window]]);
return event;
@@ -430,7 +462,7 @@
timestamp:absoluteTimeForEventTime(currentEventTime())
windowNumber:[m_testController->mainWebView()->platformWindow() windowNumber]
context:[NSGraphicsContext currentContext]
- eventNumber:++eventNumber
+ eventNumber:++m_eventNumber
clickCount:m_clickCount
pressure:0.0];
@@ -466,7 +498,7 @@
timestamp:absoluteTimeForEventTime(currentEventTime())
windowNumber:[m_testController->mainWebView()->platformWindow() windowNumber]
context:[NSGraphicsContext currentContext]
- eventNumber:++eventNumber
+ eventNumber:++m_eventNumber
clickCount:m_clickCount
pressure:0.0];
@@ -567,7 +599,7 @@
timestamp:absoluteTimeForEventTime(currentEventTime())
windowNumber:view.window.windowNumber
context:[NSGraphicsContext currentContext]
- eventNumber:++eventNumber
+ eventNumber:++m_eventNumber
clickCount:(m_leftMouseButtonDown ? m_clickCount : 0)
pressure:0];
@@ -872,4 +904,77 @@
}
}
+#if ENABLE(MAC_GESTURE_EVENTS)
+
+void EventSenderProxy::scaleGestureStart(double scale)
+{
+ auto* mainWebView = m_testController->mainWebView();
+ NSView *platformView = mainWebView->platformView();
+
+ auto event = adoptNS([[EventSenderSyntheticEvent alloc] initMagnifyEventAtLocation:NSMakePoint(m_position.x, m_position.y)
+ globalLocation:([mainWebView->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin)
+ magnification:scale
+ phase:NSEventPhaseBegan
+ time:absoluteTimeForEventTime(currentEventTime())
+ eventNumber:++m_eventNumber
+ window:platformView.window]);
+
+ if (NSView *targetView = [platformView hitTest:[event locationInWindow]]) {
+ [NSApp _setCurrentEvent:event.get()];
+ [targetView magnifyWithEvent:event.get()];
+ [NSApp _setCurrentEvent:nil];
+ } else {
+ NSPoint windowLocation = [event locationInWindow];
+ WTFLogAlways("gestureStart failed to find the target view at %f,%f\n", windowLocation.x, windowLocation.y);
+ }
+}
+
+void EventSenderProxy::scaleGestureChange(double scale)
+{
+ auto* mainWebView = m_testController->mainWebView();
+ NSView *platformView = mainWebView->platformView();
+
+ auto event = adoptNS([[EventSenderSyntheticEvent alloc] initMagnifyEventAtLocation:NSMakePoint(m_position.x, m_position.y)
+ globalLocation:([mainWebView->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin)
+ magnification:scale
+ phase:NSEventPhaseChanged
+ time:absoluteTimeForEventTime(currentEventTime())
+ eventNumber:++m_eventNumber
+ window:platformView.window]);
+
+ if (NSView *targetView = [platformView hitTest:[event locationInWindow]]) {
+ [NSApp _setCurrentEvent:event.get()];
+ [targetView magnifyWithEvent:event.get()];
+ [NSApp _setCurrentEvent:nil];
+ } else {
+ NSPoint windowLocation = [event locationInWindow];
+ WTFLogAlways("gestureStart failed to find the target view at %f,%f\n", windowLocation.x, windowLocation.y);
+ }
+}
+
+void EventSenderProxy::scaleGestureEnd(double scale)
+{
+ auto* mainWebView = m_testController->mainWebView();
+ NSView *platformView = mainWebView->platformView();
+
+ auto event = adoptNS([[EventSenderSyntheticEvent alloc] initMagnifyEventAtLocation:NSMakePoint(m_position.x, m_position.y)
+ globalLocation:([mainWebView->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin)
+ magnification:scale
+ phase:NSEventPhaseEnded
+ time:absoluteTimeForEventTime(currentEventTime())
+ eventNumber:++m_eventNumber
+ window:platformView.window]);
+
+ if (NSView *targetView = [platformView hitTest:[event locationInWindow]]) {
+ [NSApp _setCurrentEvent:event.get()];
+ [targetView magnifyWithEvent:event.get()];
+ [NSApp _setCurrentEvent:nil];
+ } else {
+ NSPoint windowLocation = [event locationInWindow];
+ WTFLogAlways("gestureStart failed to find the target view at %f,%f\n", windowLocation.x, windowLocation.y);
+ }
+}
+
+#endif // ENABLE(MAC_GESTURE_EVENTS)
+
} // namespace WTR