Changeset 200278 in webkit
- Timestamp:
- Apr 29, 2016 7:37:01 PM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r200276 r200278 1 2016-04-29 Brian Burg <bburg@apple.com> 2 3 Web Automation: use a magic eventNumber as a fallback for detecting NSEvents synthesized for automation 4 https://bugs.webkit.org/show_bug.cgi?id=157222 5 6 Reviewed by Timothy Hatcher. 7 8 Sometimes events are copied and redelivered in a way that can't be reliably intercepted, 9 so use eventNumber as an alternate means of detecting synthesized mouse NSEvents. 10 11 * UIProcess/Cocoa/WebAutomationSessionCocoa.mm: 12 (WebKit::WebAutomationSession::wasEventSynthesizedForAutomation): 13 If it's a mouse-related event, check the eventNumber if the associated object was missing. 14 15 (WebKit::WebAutomationSession::platformSimulateMouseInteraction): 16 Most real events from input devices fill in eventNumber with a non-zero value. 17 In my testing, using zero did not seem to adversely affect event delivery. 18 1 19 2016-04-29 Joseph Pecoraro <pecoraro@apple.com> 2 20 -
trunk/Source/WebKit2/UIProcess/Cocoa/WebAutomationSessionCocoa.mm
r198907 r200278 44 44 #if USE(APPKIT) 45 45 46 static const NSInteger synthesizedMouseEventMagicEventNumber = 0; 46 47 static const void *synthesizedAutomationEventAssociatedObjectKey = &synthesizedAutomationEventAssociatedObjectKey; 47 48 … … 59 60 { 60 61 NSString *senderSessionIdentifier = objc_getAssociatedObject(event, &synthesizedAutomationEventAssociatedObjectKey); 61 return [senderSessionIdentifier isEqualToString:m_sessionIdentifier]; 62 if ([senderSessionIdentifier isEqualToString:m_sessionIdentifier]) 63 return true; 64 65 switch (event.type) { 66 case NSEventTypeLeftMouseDown: 67 case NSEventTypeLeftMouseDragged: 68 case NSEventTypeLeftMouseUp: 69 case NSEventTypeMouseMoved: 70 case NSEventTypeOtherMouseDown: 71 case NSEventTypeOtherMouseDragged: 72 case NSEventTypeOtherMouseUp: 73 case NSEventTypeRightMouseDown: 74 case NSEventTypeRightMouseDragged: 75 case NSEventTypeRightMouseUp: 76 // Use this as a backup for checking mouse events, which are frequently copied 77 // and/or faked by AppKit, causing them to lose their associated object tag. 78 return event.eventNumber == synthesizedMouseEventMagicEventNumber; 79 default: 80 break; 81 } 82 83 return false; 62 84 } 63 85 … … 107 129 auto eventsToBeSent = adoptNS([[NSMutableArray alloc] init]); 108 130 131 NSInteger eventNumber = synthesizedMouseEventMagicEventNumber; 132 109 133 switch (interaction) { 110 134 case Inspector::Protocol::Automation::MouseInteraction::Move: 111 [eventsToBeSent addObject:[NSEvent mouseEventWithType:dragEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber: 0clickCount:0 pressure:0.0f]];135 [eventsToBeSent addObject:[NSEvent mouseEventWithType:dragEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:0 pressure:0.0f]]; 112 136 break; 113 137 case Inspector::Protocol::Automation::MouseInteraction::Down: 114 138 // Hard-code the click count to one, since clients don't expect successive simulated 115 139 // down/up events to be potentially counted as a double click event. 116 [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber: 0clickCount:1 pressure:WebCore::ForceAtClick]];140 [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:1 pressure:WebCore::ForceAtClick]]; 117 141 break; 118 142 case Inspector::Protocol::Automation::MouseInteraction::Up: 119 143 // Hard-code the click count to one, since clients don't expect successive simulated 120 144 // down/up events to be potentially counted as a double click event. 121 [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber: 0clickCount:1 pressure:0.0f]];145 [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:1 pressure:0.0f]]; 122 146 break; 123 147 case Inspector::Protocol::Automation::MouseInteraction::SingleClick: 124 148 // Send separate down and up events. WebCore will see this as a single-click event. 125 [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber: 0clickCount:1 pressure:WebCore::ForceAtClick]];126 [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber: 0clickCount:1 pressure:0.0f]];149 [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:1 pressure:WebCore::ForceAtClick]]; 150 [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:1 pressure:0.0f]]; 127 151 break; 128 152 case Inspector::Protocol::Automation::MouseInteraction::DoubleClick: 129 153 // Send multiple down and up events with proper click count. 130 154 // WebCore will see this as a single-click event then double-click event. 131 [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber: 0clickCount:1 pressure:WebCore::ForceAtClick]];132 [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber: 0clickCount:1 pressure:0.0f]];133 [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber: 0clickCount:2 pressure:WebCore::ForceAtClick]];134 [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber: 0clickCount:2 pressure:0.0f]];155 [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:1 pressure:WebCore::ForceAtClick]]; 156 [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:1 pressure:0.0f]]; 157 [eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:2 pressure:WebCore::ForceAtClick]]; 158 [eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:windowPosition modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:2 pressure:0.0f]]; 135 159 } 136 160
Note: See TracChangeset
for help on using the changeset viewer.