Reviewed by John
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Nov 2003 20:59:55 +0000 (20:59 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Nov 2003 20:59:55 +0000 (20:59 +0000)
Fix for this bug:

<rdar://problem/3482159>: Tabbing to links gets "stuck" in "style switcher" on zeldman.com

        * Misc.subproj/WebNSEventExtras.h: Added.
        * Misc.subproj/WebNSEventExtras.m: Added.
        (-[NSEvent _isTabKeyEvent]): New helper.
        * WebKit.pbproj/project.pbxproj:
        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView keyDown:]): Pass the key event to super unconditionally
if it is a tab key. This fixes the bug.

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

WebKit/ChangeLog
WebKit/Misc.subproj/WebNSEventExtras.h [new file with mode: 0644]
WebKit/Misc.subproj/WebNSEventExtras.m [new file with mode: 0644]
WebKit/WebKit.pbproj/project.pbxproj
WebKit/WebView.subproj/WebHTMLView.m

index 990d1a5..868fc43 100644 (file)
@@ -1,3 +1,19 @@
+2003-11-20  Ken Kocienda  <kocienda@apple.com>
+
+        Reviewed by John
+
+       Fix for this bug:
+
+       <rdar://problem/3482159>: Tabbing to links gets "stuck" in "style switcher" on zeldman.com
+
+        * Misc.subproj/WebNSEventExtras.h: Added.
+        * Misc.subproj/WebNSEventExtras.m: Added.
+        (-[NSEvent _isTabKeyEvent]): New helper.
+        * WebKit.pbproj/project.pbxproj:
+        * WebView.subproj/WebHTMLView.m: 
+        (-[WebHTMLView keyDown:]): Pass the key event to super unconditionally
+       if it is a tab key. This fixes the bug.
+
 2003-11-19  John Sullivan  <sullivan@apple.com>
 
         - WebKit part of fix for:
diff --git a/WebKit/Misc.subproj/WebNSEventExtras.h b/WebKit/Misc.subproj/WebNSEventExtras.h
new file mode 100644 (file)
index 0000000..1c4339e
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+    WebNSEventExtras.h
+    Copyright (c) 2003, Apple, Inc. All rights reserved.
+ */
+
+#import <AppKit/AppKit.h>
+
+@interface NSEvent (WebExtras)
+
+-(BOOL)_isTabKeyEvent;
+
+@end
diff --git a/WebKit/Misc.subproj/WebNSEventExtras.m b/WebKit/Misc.subproj/WebNSEventExtras.m
new file mode 100644 (file)
index 0000000..48e2304
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+    WebNSEventExtras.m
+    Copyright (c) 2003, Apple, Inc. All rights reserved.
+*/
+
+#import <WebKit/WebNSEventExtras.h>
+
+@implementation NSEvent (WebExtras)
+
+-(BOOL)_isTabKeyEvent
+{
+    if ([self type] != NSKeyDown) {
+        return NO;
+    }
+    
+    NSString *chars = [self charactersIgnoringModifiers];
+    if ([chars length] != 1)
+        return NO;
+    
+    const unichar tabKey = 0x0009;
+    const unichar shiftTabKey = 0x0019;
+    unichar c = [chars characterAtIndex:0];
+    if (c != tabKey && c != shiftTabKey)
+        return NO;
+    
+    return YES;
+}
+
+@end
index 3cd7239..dd135e3 100644 (file)
                                BE26F18F05517E0800BFA0C3,
                                BECD142B0565830A005BB09C,
                                65A7D44B0568AB2600E70EF6,
+                               BE887C01056D3A6E009BB3E7,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                                65DA2609052CC18700A97B31,
                                BE26F19005517E0800BFA0C3,
                                BECD142C0565830A005BB09C,
+                               BE887C02056D3A6E009BB3E7,
                        );
                        isa = PBXSourcesBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                                9345DDB30365FFD0008635CE,
                                BECD14290565830A005BB09C,
                                BECD142A0565830A005BB09C,
+                               BE887BFF056D3A6E009BB3E7,
+                               BE887C00056D3A6E009BB3E7,
                                8398847A03426FB000BC5F5E,
                                8398847B03426FB000BC5F5E,
                                ED2B2474033A2DA800C1A526,
                        settings = {
                        };
                };
+               BE887BFF056D3A6E009BB3E7 = {
+                       expectedFileType = sourcecode.c.h;
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       path = WebNSEventExtras.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               BE887C00056D3A6E009BB3E7 = {
+                       expectedFileType = sourcecode.c.objc;
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       path = WebNSEventExtras.m;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               BE887C01056D3A6E009BB3E7 = {
+                       fileRef = BE887BFF056D3A6E009BB3E7;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               BE887C02056D3A6E009BB3E7 = {
+                       fileRef = BE887C00056D3A6E009BB3E7;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
                BECD14290565830A005BB09C = {
                        expectedFileType = sourcecode.c.h;
                        fileEncoding = 4;
index 762df4d..603e556 100644 (file)
@@ -33,6 +33,7 @@
 
 #import <WebKit/WebImageRenderer.h>
 #import <WebKit/WebKitNSStringExtras.h>
+#import <WebKit/WebNSEventExtras.h>
 #import <WebKit/WebNSImageExtras.h>
 #import <WebKit/WebNSURLExtras.h>
 #import <WebKit/WebPreferences.h>
@@ -1708,7 +1709,8 @@ static WebHTMLView *lastHitView = nil;
 
 - (void)keyDown:(NSEvent *)event
 {
-    if (![[self _bridge] interceptKeyEvent:event toView:self]) {
+    BOOL intercepted = [[self _bridge] interceptKeyEvent:event toView:self];
+    if (!intercepted || [event _isTabKeyEvent]) {
        [super keyDown:event];
     }
 }