Changeset 277772 in webkit
- Timestamp:
- May 19, 2021 7:26:07 PM (14 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 18 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/fast/events/gesture (added)
-
LayoutTests/fast/events/gesture/wheel-from-gesture-expected.txt (added)
-
LayoutTests/fast/events/gesture/wheel-from-gesture.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/PlatformWheelEvent.cpp (modified) (1 diff)
-
Source/WebCore/platform/PlatformWheelEvent.h (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/DumpRenderTree/DerivedSources.make (modified) (2 diffs)
-
Tools/DumpRenderTree/Scripts/generate-derived-sources.sh (modified) (1 diff)
-
Tools/WebKitTestRunner/DerivedSources-input.xcfilelist (modified) (1 diff)
-
Tools/WebKitTestRunner/DerivedSources.make (modified) (2 diffs)
-
Tools/WebKitTestRunner/EventSenderProxy.h (modified) (2 diffs)
-
Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/ios/EventSenderProxyIOS.mm (modified) (1 diff)
-
Tools/WebKitTestRunner/Scripts/generate-derived-sources.sh (modified) (1 diff)
-
Tools/WebKitTestRunner/TestController.cpp (modified) (1 diff)
-
Tools/WebKitTestRunner/mac/EventSenderProxy.mm (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r277767 r277772 1 2021-05-19 Devin Rousso <drousso@apple.com> 2 3 Add a way to create `"wheel"` events from gesture/touch events 4 https://bugs.webkit.org/show_bug.cgi?id=225788 5 <rdar://problem/76714308> 6 7 Reviewed by Simon Fraser. 8 9 * fast/events/gesture/wheel-from-gesture.html: Added. 10 * fast/events/gesture/wheel-from-gesture-expected.txt: Added. 11 12 * TestExpectations: 13 1 14 2021-05-19 Alex Christensen <achristensen@webkit.org> 2 15 -
trunk/LayoutTests/TestExpectations
r277767 r277772 54 54 http/tests/device-orientation [ Skip ] 55 55 fast/events/cursors [ Skip ] 56 fast/events/gesture [ Skip ] 56 57 fast/events/ios [ Skip ] 57 58 fast/events/watchos [ Skip ] -
trunk/Source/WebCore/ChangeLog
r277768 r277772 1 2021-05-19 Devin Rousso <drousso@apple.com> 2 3 Add a way to create `"wheel"` events from gesture/touch events 4 https://bugs.webkit.org/show_bug.cgi?id=225788 5 <rdar://problem/76714308> 6 7 Reviewed by Simon Fraser. 8 9 Test: fast/events/gesture/wheel-from-gesture.html 10 11 Other browsers have taken the approach of dispatching `"wheel"` events with `ctrlKey` and 12 `deltaY` when handling multi-touch pinch-to-zoom gestures. Add helper functions to do this. 13 14 * platform/PlatformWheelEvent.h: 15 * platform/PlatformWheelEvent.cpp: 16 (WebCore::PlatformWheelEvent::createFromGesture): Added. 17 1 18 2021-05-19 Chris Dumez <cdumez@apple.com> 2 19 -
trunk/Source/WebCore/platform/PlatformWheelEvent.cpp
r270312 r277772 27 27 #include "PlatformWheelEvent.h" 28 28 29 #include "Scrollbar.h" 29 30 #include <wtf/text/TextStream.h> 30 31 32 #if ENABLE(MAC_GESTURE_EVENTS) 33 #include "PlatformGestureEventMac.h" 34 #endif 35 31 36 namespace WebCore { 37 38 #if ENABLE(MAC_GESTURE_EVENTS) 39 40 PlatformWheelEvent PlatformWheelEvent::createFromGesture(const PlatformGestureEvent& platformGestureEvent, double deltaY) 41 { 42 // This tries to match as much of the behavior of `WebKit::WebEventFactory::createWebWheelEvent` as 43 // possible assuming `-[NSEvent hasPreciseScrollingDeltas]` and no `-[NSEvent _scrollCount]`. 44 45 double deltaX = 0; 46 double wheelTicksX = 0; 47 double wheelTicksY = deltaY / static_cast<float>(Scrollbar::pixelsPerLineStep()); 48 bool shiftKey = platformGestureEvent.modifiers().contains(PlatformEvent::Modifier::ShiftKey); 49 bool ctrlKey = true; 50 bool altKey = platformGestureEvent.modifiers().contains(PlatformEvent::Modifier::AltKey); 51 bool metaKey = platformGestureEvent.modifiers().contains(PlatformEvent::Modifier::MetaKey); 52 PlatformWheelEvent platformWheelEvent(platformGestureEvent.pos(), platformGestureEvent.globalPosition(), deltaX, deltaY, wheelTicksX, wheelTicksY, ScrollByPixelWheelEvent, shiftKey, ctrlKey, altKey, metaKey); 53 54 // PlatformEvent 55 platformWheelEvent.m_timestamp = platformGestureEvent.timestamp(); 56 57 // PlatformWheelEvent 58 platformWheelEvent.m_hasPreciseScrollingDeltas = true; 59 60 #if ENABLE(KINETIC_SCROLLING) 61 switch (platformGestureEvent.type()) { 62 case PlatformEvent::GestureStart: 63 platformWheelEvent.m_phase = PlatformWheelEventPhase::Began; 64 break; 65 case PlatformEvent::GestureChange: 66 platformWheelEvent.m_phase = PlatformWheelEventPhase::Changed; 67 break; 68 case PlatformEvent::GestureEnd: 69 platformWheelEvent.m_phase = PlatformWheelEventPhase::Ended; 70 break; 71 default: 72 ASSERT_NOT_REACHED(); 73 break; 74 } 75 #endif // ENABLE(KINETIC_SCROLLING) 76 77 #if PLATFORM(COCOA) 78 platformWheelEvent.m_unacceleratedScrollingDeltaY = deltaY; 79 #endif // PLATFORM(COCOA) 80 81 return platformWheelEvent; 82 } 83 84 #endif // ENABLE(MAC_GESTURE_EVENTS) 32 85 33 86 #if ENABLE(KINETIC_SCROLLING) -
trunk/Source/WebCore/platform/PlatformWheelEvent.h
r270425 r277772 37 37 namespace WebCore { 38 38 39 class PlatformGestureEvent; 40 39 41 enum class WheelEventProcessingSteps : uint8_t { 40 42 ScrollingThread = 1 << 0, … … 107 109 } 108 110 111 #if ENABLE(MAC_GESTURE_EVENTS) 112 static PlatformWheelEvent createFromGesture(const PlatformGestureEvent&, double deltaY); 113 #endif 114 109 115 PlatformWheelEvent copySwappingDirection() const 110 116 { -
trunk/Tools/ChangeLog
r277769 r277772 1 2021-05-19 Devin Rousso <drousso@apple.com> 2 3 Add a way to create `"wheel"` events from gesture/touch events 4 https://bugs.webkit.org/show_bug.cgi?id=225788 5 <rdar://problem/76714308> 6 7 Reviewed by Simon Fraser. 8 9 * WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl: 10 * WebKitTestRunner/InjectedBundle/EventSendingController.h: 11 * WebKitTestRunner/InjectedBundle/EventSendingController.cpp: 12 (WTR::EventSendingController::scaleGestureStart): Added. 13 (WTR::EventSendingController::scaleGestureChange): Added. 14 (WTR::EventSendingController::scaleGestureEnd): Added. 15 * WebKitTestRunner/TestController.cpp: 16 (WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle): 17 * WebKitTestRunner/EventSenderProxy.h: 18 * WebKitTestRunner/mac/EventSenderProxy.mm: 19 (EventSenderCGGesturePhaseFromNSEventPhase): 20 (-[EventSenderSyntheticEvent initPressureEventAtLocation:globalLocation:stage:pressure:stageTransition:phase:time:eventNumber:window:]): 21 (-[EventSenderSyntheticEvent initMagnifyEventAtLocation:globalLocation:magnification:phase:time:eventNumber:window:]): Added. 22 (-[EventSenderSyntheticEvent magnification]): Added. 23 (WTR::EventSenderProxy::mouseDown): 24 (WTR::EventSenderProxy::mouseUp): 25 (WTR::EventSenderProxy::sendMouseDownToStartPressureEvents): 26 (WTR::EventSenderProxy::beginPressureEvent): 27 (WTR::EventSenderProxy::pressureChangeEvent): 28 (WTR::EventSenderProxy::mouseForceClick): 29 (WTR::EventSenderProxy::startAndCancelMouseForceClick): 30 (WTR::EventSenderProxy::mouseMoveTo): 31 (WTR::EventSenderProxy::scaleGestureStart): Added. 32 (WTR::EventSenderProxy::scaleGestureChange): Added. 33 (WTR::EventSenderProxy::scaleGestureEnd): Added. 34 Allow tests to synthesize scale (a.k.a. magnify) gesture events. 35 36 * WebKitTestRunner/InjectedBundle/ios/EventSenderProxyIOS.mm: 37 (WTR::EventSenderProxy::EventSenderProxy): 38 Drive-by: Rename `eventNumber` to `m_eventNumber` since it's a member variable. 39 40 * DumpRenderTree/Scripts/generate-derived-sources.sh: 41 * DumpRenderTree/DerivedSources.make: 42 * WebKitTestRunner/Scripts/generate-derived-sources.sh: 43 * WebKitTestRunner/DerivedSources.make: 44 Make sure to pass all feature flags when generating JS files from IDL files. 45 1 46 2021-05-19 Wenson Hsieh <wenson_hsieh@apple.com> 2 47 -
trunk/Tools/DumpRenderTree/DerivedSources.make
r269105 r277772 22 22 # THE POSSIBILITY OF SUCH DAMAGE. 23 23 24 PERL = perl 24 25 RUBY = ruby 26 27 ifneq ($(SDKROOT),) 28 SDK_FLAGS = -isysroot $(SDKROOT) 29 endif 30 31 ifeq ($(USE_LLVM_TARGET_TRIPLES_FOR_CLANG),YES) 32 WK_CURRENT_ARCH = $(word 1, $(ARCHS)) 33 TARGET_TRIPLE_FLAGS = -target $(WK_CURRENT_ARCH)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(LLVM_TARGET_TRIPLE_OS_VERSION)$(LLVM_TARGET_TRIPLE_SUFFIX) 34 endif 35 36 FRAMEWORK_FLAGS := $(shell echo $(BUILT_PRODUCTS_DIR) $(FRAMEWORK_SEARCH_PATHS) $(SYSTEM_FRAMEWORK_SEARCH_PATHS) | $(PERL) -e 'print "-F " . join(" -F ", split(" ", <>));') 37 HEADER_FLAGS := $(shell echo $(BUILT_PRODUCTS_DIR) $(HEADER_SEARCH_PATHS) $(SYSTEM_HEADER_SEARCH_PATHS) | $(PERL) -e 'print "-I" . join(" -I", split(" ", <>));') 38 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/") 39 40 # 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. 41 FEATURE_AND_PLATFORM_DEFINE_DEPENDENCIES = $(DumpRenderTree)/DerivedSources.make 25 42 26 43 UISCRIPTCONTEXT_DIR = $(DumpRenderTree)/../TestRunnerShared/UIScriptContext/Bindings … … 47 64 .PHONY : all 48 65 49 JS%.h JS%.cpp : %.idl $(SCRIPTS) $(IDL_ATTRIBUTES_FILE) 66 JS%.h JS%.cpp : %.idl $(SCRIPTS) $(IDL_ATTRIBUTES_FILE) $(FEATURE_AND_PLATFORM_DEFINE_DEPENDENCIES) 50 67 @echo Generating bindings for $*... 51 @perl -I $(WebCoreScripts) -I $(UISCRIPTCONTEXT_DIR) -I $(DumpRenderTree)/Bindings $(WebCoreScripts)/generate-bindings.pl --defines "" --include $(UISCRIPTCONTEXT_DIR) --outputDir . --generator DumpRenderTree --idlAttributesFile $(IDL_ATTRIBUTES_FILE) $<68 $(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) $< 52 69 53 70 all : \ -
trunk/Tools/DumpRenderTree/Scripts/generate-derived-sources.sh
r238639 r277772 16 16 17 17 if [ "${ACTION}" = "build" -o "${ACTION}" = "install" -o "${ACTION}" = "installhdrs" ]; then 18 make -f "${DumpRenderTree}/DerivedSources.make" -j `/usr/sbin/sysctl -n hw.activecpu` "${ARGS[@]}"18 make -f "${DumpRenderTree}/DerivedSources.make" -j `/usr/sbin/sysctl -n hw.activecpu` SDKROOT="${SDKROOT}" "${ARGS[@]}" 19 19 fi -
trunk/Tools/WebKitTestRunner/DerivedSources-input.xcfilelist
r268604 r277772 6 6 $(BUILT_PRODUCTS_DIR)/usr/local/include/wtf/Scripts/Preferences/WebPreferencesInternal.yaml 7 7 $(PROJECT_DIR)/../TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl 8 $(PROJECT_DIR)/DerivedSources.make 8 9 $(PROJECT_DIR)/InjectedBundle/Bindings/AccessibilityController.idl 9 10 $(PROJECT_DIR)/InjectedBundle/Bindings/AccessibilityTextMarker.idl -
trunk/Tools/WebKitTestRunner/DerivedSources.make
r268604 r277772 27 27 # 28 28 29 PERL = perl 29 30 RUBY = ruby 31 32 ifneq ($(SDKROOT),) 33 SDK_FLAGS = -isysroot $(SDKROOT) 34 endif 35 36 ifeq ($(USE_LLVM_TARGET_TRIPLES_FOR_CLANG),YES) 37 WK_CURRENT_ARCH = $(word 1, $(ARCHS)) 38 TARGET_TRIPLE_FLAGS = -target $(WK_CURRENT_ARCH)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(LLVM_TARGET_TRIPLE_OS_VERSION)$(LLVM_TARGET_TRIPLE_SUFFIX) 39 endif 40 41 FRAMEWORK_FLAGS := $(shell echo $(BUILT_PRODUCTS_DIR) $(FRAMEWORK_SEARCH_PATHS) $(SYSTEM_FRAMEWORK_SEARCH_PATHS) | $(PERL) -e 'print "-F " . join(" -F ", split(" ", <>));') 42 HEADER_FLAGS := $(shell echo $(BUILT_PRODUCTS_DIR) $(HEADER_SEARCH_PATHS) $(SYSTEM_HEADER_SEARCH_PATHS) | $(PERL) -e 'print "-I" . join(" -I", split(" ", <>));') 43 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/") 44 45 # 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. 46 FEATURE_AND_PLATFORM_DEFINE_DEPENDENCIES = $(WebKitTestRunner)/DerivedSources.make 30 47 31 48 WEB_PREFERENCES = \ … … 74 91 .PHONY : all 75 92 76 JS%.h JS%.cpp : %.idl $(SCRIPTS) $(IDL_ATTRIBUTES_FILE) 93 JS%.h JS%.cpp : %.idl $(SCRIPTS) $(IDL_ATTRIBUTES_FILE) $(FEATURE_AND_PLATFORM_DEFINE_DEPENDENCIES) 77 94 @echo Generating bindings for $*... 78 @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) $<95 $(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) $< 79 96 80 97 all : \ -
trunk/Tools/WebKitTestRunner/EventSenderProxy.h
r270582 r277772 88 88 #endif 89 89 90 #if ENABLE(MAC_GESTURE_EVENTS) 91 // Gesture events. 92 void scaleGestureStart(double scale); 93 void scaleGestureChange(double scale); 94 void scaleGestureEnd(double scale); 95 #endif 96 90 97 private: 91 98 TestController* m_testController; … … 122 129 unsigned m_mouseButtonsCurrentlyDown { 0 }; 123 130 #if PLATFORM(COCOA) 124 int eventNumber { 0 };131 int m_eventNumber { 0 }; 125 132 #endif 126 133 #if PLATFORM(WPE) -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl
r270582 r277772 72 72 undefined cancelTouchPoint(long index); 73 73 #endif 74 75 #if defined(ENABLE_MAC_GESTURE_EVENTS) && ENABLE_MAC_GESTURE_EVENTS 76 // Gesture events. 77 undefined scaleGestureStart(double scale); 78 undefined scaleGestureChange(double scale); 79 undefined scaleGestureEnd(double scale); 80 #endif 74 81 }; 75 82 -
trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp
r271459 r277772 619 619 #endif 620 620 621 #if ENABLE(MAC_GESTURE_EVENTS) 622 623 void EventSendingController::scaleGestureStart(double scale) 624 { 625 auto body = adoptWK(WKMutableDictionaryCreate()); 626 setValue(body, "SubMessage", "ScaleGestureStart"); 627 setValue(body, "Scale", scale); 628 postSynchronousPageMessage("EventSender", body); 629 } 630 631 void EventSendingController::scaleGestureChange(double scale) 632 { 633 auto body = adoptWK(WKMutableDictionaryCreate()); 634 setValue(body, "SubMessage", "ScaleGestureChange"); 635 setValue(body, "Scale", scale); 636 postSynchronousPageMessage("EventSender", body); 637 } 638 639 void EventSendingController::scaleGestureEnd(double scale) 640 { 641 auto body = adoptWK(WKMutableDictionaryCreate()); 642 setValue(body, "SubMessage", "ScaleGestureEnd"); 643 setValue(body, "Scale", scale); 644 postSynchronousPageMessage("EventSender", body); 645 } 646 647 #endif // ENABLE(MAC_GESTURE_EVENTS) 648 621 649 // Object Creation 622 650 -
trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h
r270582 r277772 90 90 #endif 91 91 92 #if ENABLE(MAC_GESTURE_EVENTS) 93 void scaleGestureStart(double scale); 94 void scaleGestureChange(double scale); 95 void scaleGestureEnd(double scale); 96 #endif 97 92 98 private: 93 99 EventSendingController() = default; -
trunk/Tools/WebKitTestRunner/InjectedBundle/ios/EventSenderProxyIOS.mm
r270582 r277772 40 40 UNUSED_PARAM(m_testController); 41 41 UNUSED_PARAM(m_leftMouseButtonDown); 42 UNUSED_PARAM( eventNumber);42 UNUSED_PARAM(m_eventNumber); 43 43 } 44 44 -
trunk/Tools/WebKitTestRunner/Scripts/generate-derived-sources.sh
r238639 r277772 16 16 17 17 if [ "${ACTION}" = "build" -o "${ACTION}" = "install" -o "${ACTION}" = "installhdrs" ]; then 18 make -f "${WebKitTestRunner}/DerivedSources.make" -j `/usr/sbin/sysctl -n hw.activecpu` "${ARGS[@]}"18 make -f "${WebKitTestRunner}/DerivedSources.make" -j `/usr/sbin/sysctl -n hw.activecpu` SDKROOT="${SDKROOT}" "${ARGS[@]}" 19 19 fi -
trunk/Tools/WebKitTestRunner/TestController.cpp
r277564 r277772 1778 1778 } 1779 1779 #endif 1780 1781 #if ENABLE(MAC_GESTURE_EVENTS) 1782 if (WKStringIsEqualToUTF8CString(subMessageName, "ScaleGestureStart")) { 1783 auto scale = doubleValue(dictionary, "Scale"); 1784 m_eventSenderProxy->scaleGestureStart(scale); 1785 return completionHandler(nullptr); 1786 } 1787 1788 if (WKStringIsEqualToUTF8CString(subMessageName, "ScaleGestureChange")) { 1789 auto scale = doubleValue(dictionary, "Scale"); 1790 m_eventSenderProxy->scaleGestureChange(scale); 1791 return completionHandler(nullptr); 1792 } 1793 1794 if (WKStringIsEqualToUTF8CString(subMessageName, "ScaleGestureEnd")) { 1795 auto scale = doubleValue(dictionary, "Scale"); 1796 m_eventSenderProxy->scaleGestureEnd(scale); 1797 return completionHandler(nullptr); 1798 } 1799 #endif // ENABLE(MAC_GESTURE_EVENTS) 1800 1780 1801 ASSERT_NOT_REACHED(); 1781 1802 } -
trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm
r273966 r277772 38 38 #import <WebKit/WKPagePrivate.h> 39 39 #import <WebKit/WKWebView.h> 40 #import <pal/spi/cocoa/IOKitSPI.h> 40 41 #import <wtf/RetainPtr.h> 41 42 … … 55 56 NSInteger _eventSender_stage; 56 57 float _eventSender_pressure; 58 CGFloat _eventSender_magnification; 57 59 CGFloat _eventSender_stageTransition; 58 60 NSEventPhase _eventSender_phase; … … 66 68 67 69 - (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; 70 - (id)initMagnifyEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation magnification:(CGFloat)magnification phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber window:(NSWindow *)window; 68 71 - (NSTimeInterval)timestamp; 69 72 @end 70 73 71 @implementation EventSenderSyntheticEvent 72 73 - (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 74 { 75 CGSGesturePhase gesturePhase; 74 static CGSGesturePhase EventSenderCGGesturePhaseFromNSEventPhase(NSEventPhase phase) 75 { 76 76 switch (phase) { 77 77 case NSEventPhaseMayBegin: 78 gesturePhase =kCGSGesturePhaseMayBegin;79 break; 78 return kCGSGesturePhaseMayBegin; 79 80 80 case NSEventPhaseBegan: 81 gesturePhase =kCGSGesturePhaseBegan;82 break; 81 return kCGSGesturePhaseBegan; 82 83 83 case NSEventPhaseChanged: 84 gesturePhase =kCGSGesturePhaseChanged;85 break; 84 return kCGSGesturePhaseChanged; 85 86 86 case NSEventPhaseCancelled: 87 gesturePhase =kCGSGesturePhaseCancelled;88 break; 87 return kCGSGesturePhaseCancelled; 88 89 89 case NSEventPhaseEnded: 90 gesturePhase =kCGSGesturePhaseEnded;91 break; 90 return kCGSGesturePhaseEnded; 91 92 92 case NSEventPhaseNone: 93 93 default: 94 gesturePhase = kCGSGesturePhaseNone; 95 break; 96 } 97 94 return kCGSGesturePhaseNone; 95 } 96 } 97 98 @implementation EventSenderSyntheticEvent 99 100 - (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 101 { 98 102 auto cgEvent = adoptCF(CGEventCreate(nullptr)); 99 103 CGEventSetType(cgEvent.get(), (CGEventType)kCGSEventGesture); 100 CGEventSetIntegerValueField(cgEvent.get(), kCGEventGestureHIDType, 32);101 CGEventSetIntegerValueField(cgEvent.get(), kCGEventGesturePhase, gesturePhase);104 CGEventSetIntegerValueField(cgEvent.get(), kCGEventGestureHIDType, kIOHIDEventTypeForce); 105 CGEventSetIntegerValueField(cgEvent.get(), kCGEventGesturePhase, EventSenderCGGesturePhaseFromNSEventPhase(phase)); 102 106 CGEventSetDoubleValueField(cgEvent.get(), kCGEventStagePressure, pressure); 103 107 CGEventSetDoubleValueField(cgEvent.get(), kCGEventTransitionProgress, pressure); … … 124 128 } 125 129 130 - (id)initMagnifyEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation magnification:(CGFloat)magnification phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber window:(NSWindow *)window 131 { 132 auto cgEvent = adoptCF(CGEventCreate(nullptr)); 133 CGEventSetType(cgEvent.get(), (CGEventType)kCGSEventGesture); 134 CGEventSetIntegerValueField(cgEvent.get(), kCGEventGestureHIDType, kIOHIDEventTypeZoom); 135 CGEventSetIntegerValueField(cgEvent.get(), kCGEventGesturePhase, EventSenderCGGesturePhaseFromNSEventPhase(phase)); 136 CGEventSetDoubleValueField(cgEvent.get(), kCGEventGestureZoomValue, magnification); 137 138 if (!(self = [super _initWithCGEvent:cgEvent.get() eventRef:nullptr])) 139 return nil; 140 141 _eventSender_location = location; 142 _eventSender_locationInWindow = globalLocation; 143 _eventSender_magnification = magnification; 144 _eventSender_phase = phase; 145 _eventSender_timestamp = time; 146 _eventSender_eventNumber = eventNumber; 147 _eventSender_window = window; 148 _eventSender_type = NSEventTypeMagnify; 149 150 return self; 151 } 152 126 153 - (CGFloat)stageTransition 127 154 { … … 162 189 { 163 190 return _eventSender_pressure; 191 } 192 193 - (CGFloat)magnification 194 { 195 return _eventSender_magnification; 164 196 } 165 197 … … 309 341 windowNumber:[m_testController->mainWebView()->platformWindow() windowNumber] 310 342 context:[NSGraphicsContext currentContext] 311 eventNumber:++ eventNumber343 eventNumber:++m_eventNumber 312 344 clickCount:m_clickCount 313 345 pressure:0.0]; … … 335 367 windowNumber:[m_testController->mainWebView()->platformWindow() windowNumber] 336 368 context:[NSGraphicsContext currentContext] 337 eventNumber:++ eventNumber369 eventNumber:++m_eventNumber 338 370 clickCount:m_clickCount 339 371 pressure:0.0]; … … 367 399 windowNumber:[m_testController->mainWebView()->platformWindow() windowNumber] 368 400 context:[NSGraphicsContext currentContext] 369 eventNumber:++ eventNumber401 eventNumber:++m_eventNumber 370 402 clickCount:m_clickCount 371 403 pressure:0.0]; … … 391 423 phase:NSEventPhaseBegan 392 424 time:absoluteTimeForEventTime(currentEventTime()) 393 eventNumber:++ eventNumber425 eventNumber:++m_eventNumber 394 426 window:[m_testController->mainWebView()->platformView() window]]); 395 427 … … 406 438 phase:NSEventPhaseChanged 407 439 time:absoluteTimeForEventTime(currentEventTime()) 408 eventNumber:++ eventNumber440 eventNumber:++m_eventNumber 409 441 window:[m_testController->mainWebView()->platformView() window]]); 410 442 … … 431 463 windowNumber:[m_testController->mainWebView()->platformWindow() windowNumber] 432 464 context:[NSGraphicsContext currentContext] 433 eventNumber:++ eventNumber465 eventNumber:++m_eventNumber 434 466 clickCount:m_clickCount 435 467 pressure:0.0]; … … 467 499 windowNumber:[m_testController->mainWebView()->platformWindow() windowNumber] 468 500 context:[NSGraphicsContext currentContext] 469 eventNumber:++ eventNumber501 eventNumber:++m_eventNumber 470 502 clickCount:m_clickCount 471 503 pressure:0.0]; … … 568 600 windowNumber:view.window.windowNumber 569 601 context:[NSGraphicsContext currentContext] 570 eventNumber:++ eventNumber602 eventNumber:++m_eventNumber 571 603 clickCount:(m_leftMouseButtonDown ? m_clickCount : 0) 572 604 pressure:0]; … … 873 905 } 874 906 907 #if ENABLE(MAC_GESTURE_EVENTS) 908 909 void EventSenderProxy::scaleGestureStart(double scale) 910 { 911 auto* mainWebView = m_testController->mainWebView(); 912 NSView *platformView = mainWebView->platformView(); 913 914 auto event = adoptNS([[EventSenderSyntheticEvent alloc] initMagnifyEventAtLocation:NSMakePoint(m_position.x, m_position.y) 915 globalLocation:([mainWebView->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin) 916 magnification:scale 917 phase:NSEventPhaseBegan 918 time:absoluteTimeForEventTime(currentEventTime()) 919 eventNumber:++m_eventNumber 920 window:platformView.window]); 921 922 if (NSView *targetView = [platformView hitTest:[event locationInWindow]]) { 923 [NSApp _setCurrentEvent:event.get()]; 924 [targetView magnifyWithEvent:event.get()]; 925 [NSApp _setCurrentEvent:nil]; 926 } else { 927 NSPoint windowLocation = [event locationInWindow]; 928 WTFLogAlways("gestureStart failed to find the target view at %f,%f\n", windowLocation.x, windowLocation.y); 929 } 930 } 931 932 void EventSenderProxy::scaleGestureChange(double scale) 933 { 934 auto* mainWebView = m_testController->mainWebView(); 935 NSView *platformView = mainWebView->platformView(); 936 937 auto event = adoptNS([[EventSenderSyntheticEvent alloc] initMagnifyEventAtLocation:NSMakePoint(m_position.x, m_position.y) 938 globalLocation:([mainWebView->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin) 939 magnification:scale 940 phase:NSEventPhaseChanged 941 time:absoluteTimeForEventTime(currentEventTime()) 942 eventNumber:++m_eventNumber 943 window:platformView.window]); 944 945 if (NSView *targetView = [platformView hitTest:[event locationInWindow]]) { 946 [NSApp _setCurrentEvent:event.get()]; 947 [targetView magnifyWithEvent:event.get()]; 948 [NSApp _setCurrentEvent:nil]; 949 } else { 950 NSPoint windowLocation = [event locationInWindow]; 951 WTFLogAlways("gestureStart failed to find the target view at %f,%f\n", windowLocation.x, windowLocation.y); 952 } 953 } 954 955 void EventSenderProxy::scaleGestureEnd(double scale) 956 { 957 auto* mainWebView = m_testController->mainWebView(); 958 NSView *platformView = mainWebView->platformView(); 959 960 auto event = adoptNS([[EventSenderSyntheticEvent alloc] initMagnifyEventAtLocation:NSMakePoint(m_position.x, m_position.y) 961 globalLocation:([mainWebView->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin) 962 magnification:scale 963 phase:NSEventPhaseEnded 964 time:absoluteTimeForEventTime(currentEventTime()) 965 eventNumber:++m_eventNumber 966 window:platformView.window]); 967 968 if (NSView *targetView = [platformView hitTest:[event locationInWindow]]) { 969 [NSApp _setCurrentEvent:event.get()]; 970 [targetView magnifyWithEvent:event.get()]; 971 [NSApp _setCurrentEvent:nil]; 972 } else { 973 NSPoint windowLocation = [event locationInWindow]; 974 WTFLogAlways("gestureStart failed to find the target view at %f,%f\n", windowLocation.x, windowLocation.y); 975 } 976 } 977 978 #endif // ENABLE(MAC_GESTURE_EVENTS) 979 875 980 } // namespace WTR
Note: See TracChangeset
for help on using the changeset viewer.