WebKit:
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Sep 2004 00:39:53 +0000 (00:39 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Sep 2004 00:39:53 +0000 (00:39 +0000)
Fixed <rdar://problem/3779998> bringing window to front or sending to back does not send focus/blur events to JavaScript window object

The fix has two parts, 1) make onblur and onfocus work for windows,
        and 2), allow the dashboard to override WebKit's special key/non-key
        behaviors.

        Reviewed by Maciej.

        * Plugins.subproj/WebBaseNetscapePluginView.m:
        (-[WebBaseNetscapePluginView restartNullEvents]):
        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView addMouseMovedObserver]):
        (-[WebHTMLView removeMouseMovedObserver]):
        * WebView.subproj/WebView.m:
        (-[WebView _dashboardBehavior:]):
        * WebView.subproj/WebViewInternal.h:
        * WebView.subproj/WebViewPrivate.h:

WebCore:
Fixed <rdar://problem/3779998> bringing window to front or sending to back does not send focus/blur events to JavaScript window object

The fix has two parts, 1) make onblur and onfocus work for windows,
        and 2), allow the dashboard to override WebKit's special key/non-key
        behaviors.

        Reviewed by Chris.

        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::setDisplaysWithFocusAttributes):

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

WebCore/ChangeLog-2005-08-23
WebCore/kwq/KWQKHTMLPart.mm
WebKit/ChangeLog
WebKit/Plugins.subproj/WebBaseNetscapePluginView.m
WebKit/WebView.subproj/WebHTMLView.m
WebKit/WebView.subproj/WebView.m
WebKit/WebView.subproj/WebViewInternal.h
WebKit/WebView.subproj/WebViewPrivate.h

index 9bdb060cca44d997e669046df404daf80714cdaa..10c7c3efdf6d99db7d1b88e2383a4d7d5de6ab50 100644 (file)
@@ -1,3 +1,16 @@
+2004-09-29  Richard Williamson   <rjw@apple.com>
+
+       Fixed <rdar://problem/3779998> bringing window to front or sending to back does not send focus/blur events to JavaScript window object
+
+       The fix has two parts, 1) make onblur and onfocus work for windows, 
+        and 2), allow the dashboard to override WebKit's special key/non-key
+        behaviors.
+
+        Reviewed by Chris.
+
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::setDisplaysWithFocusAttributes):
+
 2004-09-29  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Hyatt
index 3478dbabb7976589693d316bb877ceb2ada3fc9c..0496cfba54e82e39dae398ffc1b64b1a14123374 100644 (file)
@@ -3523,6 +3523,17 @@ void KWQKHTMLPart::setDisplaysWithFocusAttributes(bool flag)
         if (node && node->renderer())
             node->renderer()->repaint();
     }
+    
+    if (doc) {
+        if (flag) {
+            // Send onfocus event.
+            doc->body()->dispatchWindowEvent(EventImpl::FOCUS_EVENT, false, false);
+        }
+        else {
+            // Send onblur event.
+            doc->body()->dispatchWindowEvent(EventImpl::BLUR_EVENT, false, false);
+        }
+    }
 }
 
 bool KWQKHTMLPart::displaysWithFocusAttributes() const
index bb1bf505934d237b42e05dee53264b679958f3a3..acedd1c190188ddf9ed040e6cd00deb7e44323bc 100644 (file)
@@ -1,3 +1,23 @@
+2004-09-29  Richard Williamson   <rjw@apple.com>
+
+       Fixed <rdar://problem/3779998> bringing window to front or sending to back does not send focus/blur events to JavaScript window object
+
+       The fix has two parts, 1) make onblur and onfocus work for windows, 
+        and 2), allow the dashboard to override WebKit's special key/non-key
+        behaviors.
+
+        Reviewed by Maciej.
+
+        * Plugins.subproj/WebBaseNetscapePluginView.m:
+        (-[WebBaseNetscapePluginView restartNullEvents]):
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView addMouseMovedObserver]):
+        (-[WebHTMLView removeMouseMovedObserver]):
+        * WebView.subproj/WebView.m:
+        (-[WebView _dashboardBehavior:]):
+        * WebView.subproj/WebViewInternal.h:
+        * WebView.subproj/WebViewPrivate.h:
+
 2004-09-29  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by John.
index 104be55b56d041a021cbe0f27096fb4c37693931..525cf8a4764e0c6aee42a1cd963474fd32a612dc 100644 (file)
@@ -436,8 +436,9 @@ void ConsoleConnectionChangeNotifyProc(CGSNotificationType type, CGSNotification
 
     NSTimeInterval interval;
 
-    // Send null events less frequently when the actual window is not key.
-    if ([[self window] isKeyWindow]) {
+    // Send null events less frequently when the actual window is not key.  Also, allow the DB
+    // to override this behavior and send full speed events to non key windows.
+    if ([[self window] isKeyWindow] || [[self webView] _dashboardBehavior:WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns]) {
         interval = NullEventIntervalActive;
     } else {
         interval = NullEventIntervalNotActive;
index a2e35b7e4510123f658f8a162ada34fcdd2a3e2e..80fb881a8496d86db1f2c5b9d253edad94cc97ea 100644 (file)
@@ -1590,7 +1590,9 @@ static WebHTMLView *lastHitView = nil;
 
 - (void)addMouseMovedObserver
 {
-    if ([[self window] isKeyWindow] && ![self _insideAnotherHTMLView]) {
+    // Always add a mouse move observer if the DB requested, or if we're the key window.
+    if (([[self window] isKeyWindow] && ![self _insideAnotherHTMLView]) ||
+        [[self _webView] _dashboardBehavior:WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows]){
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mouseMovedNotification:)
             name:NSMouseMovedNotification object:nil];
         [self _frameOrBoundsChanged];
@@ -1599,6 +1601,10 @@ static WebHTMLView *lastHitView = nil;
 
 - (void)removeMouseMovedObserver
 {
+    // Don't remove the observer if we're running the DB
+    if ([[self _webView] _dashboardBehavior:WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows])
+        return;
+        
     [[self _webView] _mouseDidMoveOverElement:nil modifierFlags:0];
     [[NSNotificationCenter defaultCenter] removeObserver:self
         name:NSMouseMovedNotification object:nil];
index 5922143232724ee7d40d0acf62e396aff4ab91f2..cd9776210f6a02c835ea8efb6800b59f83a6be56 100644 (file)
@@ -1181,6 +1181,33 @@ NSString *_WebMainFrameURLKey =         @"mainFrameURL";
     return regions;
 }
 
+- (void)_setDashboardBehavior:(WebDashboardBehavior)behavior to:(BOOL)flag;
+{
+    switch (behavior) {
+        case WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows: {
+            _private->dashboardBehaviorAlwaysSendMouseEventsToAllWindows = flag;
+            break;
+        }
+        case WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns: {
+            _private->dashboardBehaviorAlwaysSendActiveNullEventsToPlugIns = flag;
+            break;
+        }
+    }
+}
+
+- (BOOL)_dashboardBehavior:(WebDashboardBehavior)behavior
+{
+    switch (behavior) {
+        case WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows: {
+            return _private->dashboardBehaviorAlwaysSendMouseEventsToAllWindows;
+        }
+        case WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns: {
+            return _private->dashboardBehaviorAlwaysSendActiveNullEventsToPlugIns;
+        }
+    }
+    return NO;
+}
+
 @end
 
 
index e6fe3a57be3a62785c4a61f949ef34bce9e57b2f..1bd1cec1849447ddde4d5ca1f954d356010f626b 100644 (file)
@@ -82,6 +82,9 @@
     BOOL continuousSpellCheckingEnabled;
     BOOL continuousGrammarCheckingEnabled;
     BOOL smartInsertDeleteEnabled;
+    
+    BOOL dashboardBehaviorAlwaysSendMouseEventsToAllWindows;
+    BOOL dashboardBehaviorAlwaysSendActiveNullEventsToPlugIns;
 }
 @end
 
index 7099a9d4d02a2e9fd384a8c41454f0b6d5a8c079..8189bd54fa4f586068b27d0490994a56924ca3e4 100644 (file)
@@ -31,6 +31,12 @@ extern NSString *_WebMainFrameIconKey;
 extern NSString *_WebMainFrameTitleKey;
 extern NSString *_WebMainFrameURLKey;
 
+typedef enum {
+       WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows,
+       WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns
+} WebDashboardBehavior;
+
+
 @interface WebView (WebPendingPublic)
 
 - (void)setMainFrameURL:(NSString *)URLString;
@@ -217,6 +223,10 @@ Could be worth adding to the API.
 - (void)_addScrollerDashboardRegions:(NSMutableDictionary *)regions;
 - (NSDictionary *)_dashboardRegions;
 
+- (void)_setDashboardBehavior:(WebDashboardBehavior)behavior to:(BOOL)flag;
+- (BOOL)_dashboardBehavior:(WebDashboardBehavior)behavior;
+
+
 @end
 
 @interface WebView (WebViewPrintingPrivate)