Fixed: <rdar://problem/3768439> can't click in WebView in Carbon WebKit apps (GetEve...
authorcblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Aug 2004 21:59:25 +0000 (21:59 +0000)
committercblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Aug 2004 21:59:25 +0000 (21:59 +0000)
        Reviewed by rjw.

        * Carbon.subproj/HIWebView.m:
        (Click): use WebGetEventPlatformEventRecord not GetEventPlatformEventRecord
        (MouseUp): ditto
        (MouseMoved): ditto
        (MouseDragged): ditto
        (MouseWheelMoved): ditto
        (WindowHandler): ditto
        (HIWebViewEventHandler): ditto
        (UpdateObserver): ditto
        (WebGetEventPlatformEventRecord): Call GetEventPlatformEventRecord, if that fails fallback to the current event. This is code Eric Schlegel to me to use.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7377 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/Carbon.subproj/HIWebView.m
WebKit/ChangeLog

index 97b448c7ab8da6b2583ef18fe2f79980a5c45b84..e060df9cc9137c70e5627290e3e464d689e8b71f 100644 (file)
@@ -19,6 +19,7 @@
 
 
 extern Boolean GetEventPlatformEventRecord( EventRef inEvent, void * eventRec );
+Boolean WebGetEventPlatformEventRecord( EventRef inEvent, void * eventRec );
 
 struct HIWebView
 {
@@ -487,7 +488,7 @@ Click( HIWebView* inView, EventRef inEvent )
        UInt32                                  modifiers;
        Rect                                    windRect;
        
-       if (!GetEventPlatformEventRecord( inEvent, &eventRec )) {
+       if (!WebGetEventPlatformEventRecord( inEvent, &eventRec )) {
             NSLog (@"Unable to get platform event");
             return noErr;
         }
@@ -541,7 +542,7 @@ MouseUp( HIWebView* inView, EventRef inEvent )
        NSEvent*                                kitEvent;
 //     NSView*                                 targ;
        
-       GetEventPlatformEventRecord( inEvent, &eventRec );
+       WebGetEventPlatformEventRecord( inEvent, &eventRec );
        RetainEvent( inEvent );
        kitEvent = [[NSEvent alloc] _initWithCGSEvent:(CGSEventRecord)eventRec eventRef:(void *)inEvent];
 
@@ -567,7 +568,7 @@ MouseMoved( HIWebView* inView, EventRef inEvent )
        NSEvent*                                kitEvent;
 //     NSView*                                 targ;
        
-       GetEventPlatformEventRecord( inEvent, &eventRec );
+       WebGetEventPlatformEventRecord( inEvent, &eventRec );
        RetainEvent( inEvent );
 
 #define WORK_AROUND_3585644
@@ -600,7 +601,7 @@ MouseDragged( HIWebView* inView, EventRef inEvent )
        NSEvent*                                kitEvent;
 //     NSView*                                 targ;
     
-       GetEventPlatformEventRecord( inEvent, &eventRec );
+       WebGetEventPlatformEventRecord( inEvent, &eventRec );
        RetainEvent( inEvent );
        kitEvent = [[NSEvent alloc] _initWithCGSEvent:(CGSEventRecord)eventRec eventRef:(void *)inEvent];
 
@@ -625,7 +626,7 @@ MouseWheelMoved( HIWebView* inView, EventRef inEvent )
        NSEvent*                                kitEvent;
 //     NSView*                                 targ;
        
-       GetEventPlatformEventRecord( inEvent, &eventRec );
+       WebGetEventPlatformEventRecord( inEvent, &eventRec );
        RetainEvent( inEvent );
        kitEvent = [[NSEvent alloc] _initWithCGSEvent:(CGSEventRecord)eventRec eventRef:(void *)inEvent];
 
@@ -804,7 +805,7 @@ WindowHandler( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData
                                        NSResponder* responder = [kitWindow firstResponder];
                                        if ( responder != kitWindow )
                                        {
-                                               GetEventPlatformEventRecord( inEvent, &eventRec );
+                                               WebGetEventPlatformEventRecord( inEvent, &eventRec );
                                                RetainEvent( inEvent );
                                                kitEvent = [[NSEvent alloc] _initWithCGSEvent:(CGSEventRecord)eventRec eventRef:(void *)inEvent];
                                                
@@ -1400,7 +1401,7 @@ HIWebViewEventHandler(
                                CGSEventRecord          eventRec;
                                NSEvent*                        kitEvent;
 
-                               GetEventPlatformEventRecord( inEvent, &eventRec );
+                               WebGetEventPlatformEventRecord( inEvent, &eventRec );
                                RetainEvent( inEvent );
                                kitEvent = [[NSEvent alloc] _initWithCGSEvent:(CGSEventRecord)eventRec eventRef:(void *)inEvent];
 
@@ -1742,3 +1743,20 @@ UpdateObserver( CFRunLoopObserverRef observer, CFRunLoopActivity activity, void
         DisposeRgn( region );
     }
 }
+
+Boolean WebGetEventPlatformEventRecord( EventRef event, void * eventRec )
+{
+    if (GetEventPlatformEventRecord(event, eventRec)) {
+        return true;
+    }
+    // This event might not have been created directly from a CGS event, and might not
+    // have a platform event associated with it. In that case, try using the event most
+    // recently dispatched by the event dispatcher, which is likely to be the original
+    // user-input event containing a valid platform event.
+    // See 3768439 for more info.
+    event = GetCurrentEvent();
+    if (event != NULL && GetEventPlatformEventRecord(event, eventRec)) {
+        return true;
+    }
+    return false;
+}
index 3c837245bddb5cfb4240ea3af2e58eb6066f4437..5977efeefcaa407c1186553b8e9802536a41939d 100644 (file)
@@ -1,3 +1,20 @@
+2004-08-26  Chris Blumenberg  <cblu@apple.com>
+
+       Fixed: <rdar://problem/3768439> can't click in WebView in Carbon WebKit apps (GetEventPlatformEventRecord returns false)
+
+        Reviewed by rjw.
+
+        * Carbon.subproj/HIWebView.m:
+        (Click): use WebGetEventPlatformEventRecord not GetEventPlatformEventRecord
+        (MouseUp): ditto
+        (MouseMoved): ditto
+        (MouseDragged): ditto
+        (MouseWheelMoved): ditto
+        (WindowHandler): ditto
+        (HIWebViewEventHandler): ditto
+        (UpdateObserver): ditto
+        (WebGetEventPlatformEventRecord): Call GetEventPlatformEventRecord, if that fails fallback to the current event. This is code Eric Schlegel to me to use. 
+
 2004-08-24  Chris Blumenberg  <cblu@apple.com>
 
        Fixed with help from Trey: