WebCore:
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 May 2006 21:36:19 +0000 (21:36 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 May 2006 21:36:19 +0000 (21:36 +0000)
        Fix for the gmail tab-focus-stealing bug.

        Reviewed by darin

        * bindings/js/kjs_window.cpp:
        (KJS::WindowFunc::callAsFunction):
        * bridge/mac/BrowserExtensionMac.mm:
        (WebCore::BrowserExtensionMac::createNewWindow):
        * bridge/mac/FrameMac.h:
        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::focusWindow):
        (WebCore::FrameMac::unfocusWindow):
        * bridge/mac/WebCoreFrameBridge.h:
        * page/Frame.h:
        * platform/Widget.h:
        * platform/mac/WidgetMac.mm:
        * platform/win/TemporaryLinkStubs.cpp:
        (FrameWin::focusWindow):
        * platform/win/WidgetWin.cpp:

WebKit:

        Make programmatic focus/blur actually work on sub-frames.  Make the
        top-level UI delegate get called for deactivation of windows.

        Reviewed by darin

        * WebCoreSupport/WebFrameBridge.m:
        (-[WebFrameBridge activateWindow]):
        (-[WebFrameBridge deactivateWindow]):
        (-[WebFrameBridge loadURL:referrer:reload:userGesture:target:triggeringEvent:form:formValues:]):
        (-[WebFrameBridge postWithURL:referrer:target:data:contentType:triggeringEvent:form:formValues:]):
        * WebKit.xcodeproj/project.pbxproj:

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

14 files changed:
WebCore/ChangeLog
WebCore/bindings/js/kjs_window.cpp
WebCore/bridge/mac/BrowserExtensionMac.mm
WebCore/bridge/mac/FrameMac.h
WebCore/bridge/mac/FrameMac.mm
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/page/Frame.h
WebCore/platform/Widget.h
WebCore/platform/mac/WidgetMac.mm
WebCore/platform/win/TemporaryLinkStubs.cpp
WebCore/platform/win/WidgetWin.cpp
WebKit/ChangeLog
WebKit/WebCoreSupport/WebFrameBridge.m
WebKit/WebKit.xcodeproj/project.pbxproj

index aca21f3..9e1804f 100644 (file)
@@ -1,3 +1,25 @@
+2006-05-31  David Hyatt  <hyatt@apple.com>
+
+        Fix for the gmail tab-focus-stealing bug.
+
+        Reviewed by darin
+
+        * bindings/js/kjs_window.cpp:
+        (KJS::WindowFunc::callAsFunction):
+        * bridge/mac/BrowserExtensionMac.mm:
+        (WebCore::BrowserExtensionMac::createNewWindow):
+        * bridge/mac/FrameMac.h:
+        * bridge/mac/FrameMac.mm:
+        (WebCore::FrameMac::focusWindow):
+        (WebCore::FrameMac::unfocusWindow):
+        * bridge/mac/WebCoreFrameBridge.h:
+        * page/Frame.h:
+        * platform/Widget.h:
+        * platform/mac/WidgetMac.mm:
+        * platform/win/TemporaryLinkStubs.cpp:
+        (FrameWin::focusWindow):
+        * platform/win/WidgetWin.cpp:
+
 2006-05-31  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Hyatt.
index 6d3799e..b5de9ea 100644 (file)
@@ -1709,8 +1709,7 @@ JSValue *WindowFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const Li
     (const_cast<Window*>(window))->clearTimeout(v->toInt32(exec));
     return jsUndefined();
   case Window::Focus:
-    if (widget)
-      widget->setActiveWindow();
+    frame->focusWindow();
     return jsUndefined();
   case Window::GetSelection:
     if (!window->isSafeScript(exec))
index 28f76e3..906cc82 100644 (file)
@@ -89,7 +89,7 @@ void BrowserExtensionMac::createNewWindow(const ResourceRequest& request,
                      formValues:nil];
             }
 
-            [frameBridge focusWindow];
+            [frameBridge activateWindow];
 
             if (partResult)
                 *partResult = [frameBridge impl];
index ce6abcf..5199e34 100644 (file)
@@ -140,6 +140,7 @@ public:
 
     virtual void scheduleClose();
 
+    virtual void focusWindow();
     virtual void unfocusWindow();
     
     void openURLFromPageCache(KWQPageState*);
index 858d020..7fdbe0b 100644 (file)
@@ -663,10 +663,33 @@ void FrameMac::scheduleClose()
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
+void FrameMac::focusWindow()
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    // If we're a top level window, bring the window to the front.
+    if (!tree()->parent())
+        [_bridge activateWindow];
+    NSView *view = d->m_view->getDocumentView();
+    if ([_bridge firstResponder] != view)
+        [_bridge makeFirstResponder:view];
+    END_BLOCK_OBJC_EXCEPTIONS;
+}
+
 void FrameMac::unfocusWindow()
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [_bridge unfocusWindow];
+    NSView *view = d->m_view->getDocumentView();
+    if ([_bridge firstResponder] == view) {
+        // If we're a top level window, deactivate the window.
+        if (!tree()->parent())
+            [_bridge deactivateWindow];
+        else {
+            // We want to shift focus to our parent.
+            FrameMac* parentFrame = static_cast<FrameMac*>(tree()->parent());
+            NSView* parentView = parentFrame->d->m_view->getDocumentView();
+            [parentFrame->bridge() makeFirstResponder:parentView];
+        }
+    }
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
index 4609ed5..54dac17 100644 (file)
@@ -565,8 +565,8 @@ typedef enum {
 - (void)reportClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date lockHistory:(BOOL)lockHistory isJavaScriptFormAction:(BOOL)isJavaScriptFormAction;
 - (void)reportClientRedirectCancelled:(BOOL)cancelWithLoadInProgress;
 
-- (void)focusWindow;
-- (void)unfocusWindow;
+- (void)activateWindow;
+- (void)deactivateWindow;
 
 - (void)formControlIsBecomingFirstResponder:(NSView *)formControl;
 - (void)formControlIsResigningFirstResponder:(NSView *)formControl;
index 16b5f9a..ed85816 100644 (file)
@@ -537,6 +537,7 @@ public:
   virtual bool statusbarVisible() = 0;
   virtual bool toolbarVisible() = 0;
   virtual void scheduleClose() = 0;
+  virtual void focusWindow() = 0;
   virtual void unfocusWindow() = 0;
   virtual void createEmptyDocument() = 0;
   virtual Range* markedTextRange() const = 0;
index 8e4c82c..50b7881 100644 (file)
@@ -71,8 +71,6 @@ namespace WebCore {
         
         virtual void setEnabled(bool);
         virtual bool isEnabled() const;
-        
-        void setActiveWindow();
 
         int x() const;
         int y() const;
index 79d01ac..932144e 100644 (file)
@@ -84,13 +84,6 @@ Widget::~Widget()
     delete data;
 }
 
-void Widget::setActiveWindow() 
-{
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [FrameMac::bridgeForWidget(this) focusWindow];
-    END_BLOCK_OBJC_EXCEPTIONS;
-}
-
 void Widget::setEnabled(bool enabled)
 {
     id view = data->view;
index 62145b0..75eb8e8 100644 (file)
@@ -163,6 +163,7 @@ int WebCore::findNextWordFromIndex(UChar const*,int,int,bool) { notImplemented()
 
 DeprecatedArray<char> KWQServeSynchronousRequest(Loader*,DocLoader*,TransferJob*,KURL&,DeprecatedString&) { notImplemented(); return 0; }
 
+void FrameWin::focusWindow() { notImplemented(); }
 void FrameWin::unfocusWindow() { notImplemented(); }
 bool FrameWin::locationbarVisible() { notImplemented(); return 0; }
 void FrameWin::issueRedoCommand(void) { notImplemented(); }
index 16d21d5..6468160 100644 (file)
@@ -72,11 +72,6 @@ void Widget::setWindowHandle(HWND hWnd)
     data->windowHandle = hWnd;
 }
 
-void Widget::setActiveWindow() 
-{
-    BringWindowToTop(data->windowHandle);
-}
-
 void Widget::setClient(WidgetClient* c)
 {
     data->client = c;
index 5fbf43b..94a3077 100644 (file)
@@ -1,3 +1,17 @@
+2006-05-31  David Hyatt  <hyatt@apple.com>
+
+        Make programmatic focus/blur actually work on sub-frames.  Make the
+        top-level UI delegate get called for deactivation of windows.
+
+        Reviewed by darin
+
+        * WebCoreSupport/WebFrameBridge.m:
+        (-[WebFrameBridge activateWindow]):
+        (-[WebFrameBridge deactivateWindow]):
+        (-[WebFrameBridge loadURL:referrer:reload:userGesture:target:triggeringEvent:form:formValues:]):
+        (-[WebFrameBridge postWithURL:referrer:target:data:contentType:triggeringEvent:form:formValues:]):
+        * WebKit.xcodeproj/project.pbxproj:
+
 === WebKit-521.12 ===
 
 2006-05-26  David Harrison  <harrison@apple.com>
index 9202e87..9a5d6ce 100644 (file)
@@ -646,16 +646,14 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
     _frame = nil;
 }
 
-- (void)focusWindow
+- (void)activateWindow
 {
     [[[self webView] _UIDelegateForwarder] webViewFocus:[self webView]];
 }
 
-- (void)unfocusWindow
+- (void)deactivateWindow
 {
-    if ([[self window] isKeyWindow] || [[[self window] attachedSheet] isKeyWindow]) {
-        [NSApp _cycleWindowsReversed:FALSE];
-    }
+   [[[self webView] _UIDelegateForwarder] webViewUnfocus:[self webView]];
 }
 
 - (void)formControlIsBecomingFirstResponder:(NSView *)formControl
@@ -708,7 +706,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
     [_frame _loadURL:URL referrer:(hideReferrer ? nil : referrer) loadType:loadType target:target triggeringEvent:event form:form formValues:values];
 
     if (targetFrame != nil && _frame != targetFrame) {
-        [[targetFrame _bridge] focusWindow];
+        [[targetFrame _bridge] activateWindow];
     }
 }
 
@@ -730,7 +728,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
     [_frame _postWithURL:URL referrer:(hideReferrer ? nil : referrer) target:target data:postData contentType:contentType triggeringEvent:event form:form formValues:values];
 
     if (targetFrame != nil && _frame != targetFrame) {
-        [[targetFrame _bridge] focusWindow];
+        [[targetFrame _bridge] activateWindow];
     }
 }
 
index 22e0797..37d1ded 100644 (file)
                ED7F6D8B0980683500C235ED /* WebNSDataExtrasPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               BC5D261E0A2E3FC000102DF0 /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               BC5D261F0A2E3FC000102DF0 /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
 /* Begin PBXFileReference section */
                1C68F640095B5FC100C2984E /* webInspector */ = {isa = PBXFileReference; lastKnownFileType = folder; name = webInspector; path = WebInspector/webInspector; sourceTree = SOURCE_ROOT; };
                1C68F65C095B5FC100C2984E /* WebInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebInspector.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
+                       buildSettings = {
+                       };
+                       buildStyles = (
+                               BC5D261E0A2E3FC000102DF0 /* Development */,
+                               BC5D261F0A2E3FC000102DF0 /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,