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 aca21f35370ba7665ebad6e233ebbdfe27aa6d99..9e1804fa2c2c4a5aab5fb10f1737de90bf37e239 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 6d3799e92b4a6e574ee15ad2617c21764f9b9ed5..b5de9ea08b92007d98ec5baba2ace93c380451d4 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 28f76e31e22159d57099e0f2055a12c9ca0e0834..906cc82c72a3bf1e76d70972a51eb4b9f1da7577 100644 (file)
@@ -89,7 +89,7 @@ void BrowserExtensionMac::createNewWindow(const ResourceRequest& request,
                      formValues:nil];
             }
 
-            [frameBridge focusWindow];
+            [frameBridge activateWindow];
 
             if (partResult)
                 *partResult = [frameBridge impl];
index ce6abcf4b52240f31eb96ef154ca065ff14164cd..5199e347273175e642b8804fe95dfc26074e305c 100644 (file)
@@ -140,6 +140,7 @@ public:
 
     virtual void scheduleClose();
 
+    virtual void focusWindow();
     virtual void unfocusWindow();
     
     void openURLFromPageCache(KWQPageState*);
index 858d0208c5b7fd7255ec0982a71084adabfff4e7..7fdbe0bd91062388b0d51bf8d0ed982a64817749 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 4609ed5d3f9fda18ad350f2d7f5c3073f027547f..54dac175fb37140d18e4c51fceada6833fb0de3f 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 16b5f9a117600b8e59dba1a9843812d0c05bfd77..ed858168703236e6e5e09d6b050ece0cbad146f9 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 8e4c82cf88eb10ecfd3da795e7313004fb62fe22..50b7881e88ac00ae0f6721d6caf493d3eb71319a 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 79d01acf8343b4b14ca91663f3c335182f1f1d9e..932144e2e529e79dbc8f161032ed61b71d555e4c 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 62145b05dbd64f268b3385f87bd49ad8351750ec..75eb8e87f00910112e9fb1c3482052902e30210f 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 16d21d5cc2d87f867f805ecde6e5139ea5ae94c2..646816004844960fdb5b4b5121fef0ac28ec1b61 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 5fbf43b80cc22e331e851ccdb6b54bf04747c5bf..94a30774c127a17beb88b01802e43974b0480409 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 9202e8706770e71fc3a4ff81ed57098bcd0b2e8b..9a5d6ce21623419c34b23db715ff968bc765e697 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 22e07976b661e1af8a9a7eef7c99acc5f89dfd37..37d1dedc649085a118be4d84ebfb796b51203397 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,