Title: [97081] trunk
Revision
97081
Author
simon.fra...@apple.com
Date
2011-10-10 14:01:59 -0700 (Mon, 10 Oct 2011)

Log Message

WebKitTestRunner needs layoutTestController.setWindowIsKey
https://bugs.webkit.org/show_bug.cgi?id=42688

Reviewed by Anders Carlsson.

Tools:

Implement layoutTestController.setWindowIsKey() in WebKitTestRunner.
This sets a flag that the platform layer uses to indicate that
the window is the key window, which fixes focus ring drawing
in pixel results.

Also focus the web view when we get a 'didCommitLoad' for the main
frame, as DumpRenderTree does.

* WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::postSetWindowIsKey):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::cacheLayoutTestControllerCallback): Replace some magic numbers with an enum.
(WTR::LayoutTestController::addChromeInputField):
(WTR::LayoutTestController::removeChromeInputField):
(WTR::LayoutTestController::focusWebView):
(WTR::LayoutTestController::setWindowIsKey):
(WTR::LayoutTestController::callAddChromeInputFieldCallback):
(WTR::LayoutTestController::callRemoveChromeInputFieldCallback):
(WTR::LayoutTestController::callFocusWebViewCallback):
* WebKitTestRunner/InjectedBundle/LayoutTestController.h:
* WebKitTestRunner/PlatformWebView.h: Add an NSWindow subclass
so that we can override -isKeyWindow. Use a boolean member variable
to track window key status.
(WTR::PlatformWebView::setWindowIsKey):
(WTR::PlatformWebView::windowIsKey):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::runModal): Change the window key status when showing a modal alert, as DRT does.
(WTR::closeOtherPage): Use the same cast as other functions.
(WTR::focus): Implement to call setWindowIsKey(true)
(WTR::unfocus): Implement to call setWindowIsKey(false)
(WTR::TestController::createOtherPage): Add page callbacks for focus and unfocus.
(WTR::TestController::initialize):
(WTR::TestController::didCommitLoadForFrame): Hook up callback to focus the web view, as DRT does.
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
(WTR::PlatformWebView::PlatformWebView):
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(-[WebKitTestRunnerWindow isKeyWindow]):
(WTR::PlatformWebView::PlatformWebView): Make a WebKitTestRunnerWindow.
(WTR::PlatformWebView::~PlatformWebView): Clean up the back pointer on the NSWindow subclass, in case it outlives us.
(WTR::PlatformWebView::focus): Set the view as the first responder, and the window as the key window, as DRT does.
* WebKitTestRunner/qt/PlatformWebViewQt.cpp:
(WTR::PlatformWebView::PlatformWebView):
* WebKitTestRunner/win/PlatformWebViewWin.cpp:
(WTR::PlatformWebView::PlatformWebView):

LayoutTests:

Adjust the Skipped list for WebKit2, unskipping some tests, but
keeping others skipped for new reasons.

* platform/wk2/Skipped:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (97080 => 97081)


--- trunk/LayoutTests/ChangeLog	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/LayoutTests/ChangeLog	2011-10-10 21:01:59 UTC (rev 97081)
@@ -1,3 +1,15 @@
+2011-10-10  Simon Fraser  <simon.fra...@apple.com>
+
+        WebKitTestRunner needs layoutTestController.setWindowIsKey
+        https://bugs.webkit.org/show_bug.cgi?id=42688
+
+        Reviewed by Anders Carlsson.
+
+        Adjust the Skipped list for WebKit2, unskipping some tests, but
+        keeping others skipped for new reasons.
+
+        * platform/wk2/Skipped:
+
 2011-10-10  Abhishek Arya  <infe...@chromium.org>
 
         Style for updated due to inability to locate

Modified: trunk/LayoutTests/platform/wk2/Skipped (97080 => 97081)


--- trunk/LayoutTests/platform/wk2/Skipped	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/LayoutTests/platform/wk2/Skipped	2011-10-10 21:01:59 UTC (rev 97081)
@@ -642,7 +642,9 @@
 
 # WebKitTestRunner needs layoutTestController.setMainFrameIsFirstResponder
 # <https://bugs.webkit.org/show_bug.cgi?id=42685>
+editing/selection/caret-and-focus-ring.html
 editing/selection/designmode-no-caret.html
+editing/selection/selection-background.html
 fast/dom/Window/window-onFocus.html
 platform/mac/scrollbars/key-window-not-first-responder.html
 
@@ -654,15 +656,9 @@
 # <https://bugs.webkit.org/show_bug.cgi?id=42687>
 fast/events/keypress-insert-tab.html
 
-# WebKitTestRunner needs layoutTestController.setWindowIsKey
-# <https://bugs.webkit.org/show_bug.cgi?id=42688>
-editing/selection/4975120.html
-editing/selection/caret-and-focus-ring.html
-editing/selection/selection-background.html
-fast/events/blur-focus-window-should-blur-focus-element.html
+# WebKitTestRunner needs layoutTestController.abortModal
+# <https://bugs.webkit.org/show_bug.cgi?id=69548>
 fast/events/show-modal-dialog-onblur-onfocus.html
-fast/flexbox/horizontal-box-float-crash.html
-plugins/netscape-plugin-setwindow-size-2.html
 
 # WebKitTestRunner needs layoutTestController.setEditingBehavior
 # <https://bugs.webkit.org/show_bug.cgi?id=42689>
@@ -672,6 +668,7 @@
 editing/selection/after-line-break.html
 editing/selection/rtl-move-selection-right-left.html
 editing/selection/5195166-1.html
+editing/selection/collapse-selection-in-bidi.html
 editing/selection/context-menu-text-selection.html
 editing/selection/directionality-after-undo-replace.html
 editing/selection/programmatic-selection-on-mac-is-directionless.html

Modified: trunk/Tools/ChangeLog (97080 => 97081)


--- trunk/Tools/ChangeLog	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/ChangeLog	2011-10-10 21:01:59 UTC (rev 97081)
@@ -1,3 +1,60 @@
+2011-10-10  Simon Fraser  <simon.fra...@apple.com>
+
+        WebKitTestRunner needs layoutTestController.setWindowIsKey
+        https://bugs.webkit.org/show_bug.cgi?id=42688
+
+        Reviewed by Anders Carlsson.
+
+        Implement layoutTestController.setWindowIsKey() in WebKitTestRunner.
+        This sets a flag that the platform layer uses to indicate that
+        the window is the key window, which fixes focus ring drawing
+        in pixel results.
+        
+        Also focus the web view when we get a 'didCommitLoad' for the main
+        frame, as DumpRenderTree does.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::postSetWindowIsKey):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+        (WTR::cacheLayoutTestControllerCallback): Replace some magic numbers with an enum.
+        (WTR::LayoutTestController::addChromeInputField):
+        (WTR::LayoutTestController::removeChromeInputField):
+        (WTR::LayoutTestController::focusWebView):
+        (WTR::LayoutTestController::setWindowIsKey):
+        (WTR::LayoutTestController::callAddChromeInputFieldCallback):
+        (WTR::LayoutTestController::callRemoveChromeInputFieldCallback):
+        (WTR::LayoutTestController::callFocusWebViewCallback):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
+        * WebKitTestRunner/PlatformWebView.h: Add an NSWindow subclass
+        so that we can override -isKeyWindow. Use a boolean member variable
+        to track window key status.
+        (WTR::PlatformWebView::setWindowIsKey):
+        (WTR::PlatformWebView::windowIsKey):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::runModal): Change the window key status when showing a modal alert, as DRT does.
+        (WTR::closeOtherPage): Use the same cast as other functions.
+        (WTR::focus): Implement to call setWindowIsKey(true)
+        (WTR::unfocus): Implement to call setWindowIsKey(false)
+        (WTR::TestController::createOtherPage): Add page callbacks for focus and unfocus.
+        (WTR::TestController::initialize):
+        (WTR::TestController::didCommitLoadForFrame): Hook up callback to focus the web view, as DRT does.
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+        * WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
+        (WTR::PlatformWebView::PlatformWebView):
+        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+        (-[WebKitTestRunnerWindow isKeyWindow]):
+        (WTR::PlatformWebView::PlatformWebView): Make a WebKitTestRunnerWindow.
+        (WTR::PlatformWebView::~PlatformWebView): Clean up the back pointer on the NSWindow subclass, in case it outlives us.
+        (WTR::PlatformWebView::focus): Set the view as the first responder, and the window as the key window, as DRT does.
+        * WebKitTestRunner/qt/PlatformWebViewQt.cpp:
+        (WTR::PlatformWebView::PlatformWebView):
+        * WebKitTestRunner/win/PlatformWebViewWin.cpp:
+        (WTR::PlatformWebView::PlatformWebView):
+
 2011-10-10  Raphael Kubo da Costa  <k...@profusion.mobi>
 
         check-webkit-style: Add readability exception for Ewk_* data types.

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl	2011-10-10 21:01:59 UTC (rev 97081)
@@ -127,6 +127,7 @@
         void addChromeInputField(in object callback);
         void removeChromeInputField(in object callback);
         void focusWebView(in object callback);
+        void setWindowIsKey(in boolean isKey);
     };
 
 }

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2011-10-10 21:01:59 UTC (rev 97081)
@@ -277,4 +277,11 @@
     WKBundlePostMessage(m_bundle, messageName.get(), 0);
 }
 
+void InjectedBundle::postSetWindowIsKey(bool isKey)
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetWindowIsKey"));
+    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(isKey));
+    WKBundlePostSynchronousMessage(m_bundle, messageName.get(), messageBody.get(), 0);
+}
+
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2011-10-10 21:01:59 UTC (rev 97081)
@@ -79,6 +79,7 @@
     void postAddChromeInputField();
     void postRemoveChromeInputField();
     void postFocusWebView();
+    void postSetWindowIsKey(bool);
 
 private:
     InjectedBundle();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp	2011-10-10 21:01:59 UTC (rev 97081)
@@ -525,8 +525,17 @@
     return map;
 }
 
+enum {
+    AddChromeInputFieldCallbackID,
+    RemoveChromeInputFieldCallbackID,
+    FocusWebViewCallbackID
+};
+
 static void cacheLayoutTestControllerCallback(unsigned index, JSValueRef callback)
 {
+    if (!callback)
+        return;
+
     WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
     JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
     JSValueProtect(context, callback);
@@ -546,35 +555,40 @@
 
 void LayoutTestController::addChromeInputField(JSValueRef callback)
 {
-    cacheLayoutTestControllerCallback(1, callback);
+    cacheLayoutTestControllerCallback(AddChromeInputFieldCallbackID, callback);
     InjectedBundle::shared().postAddChromeInputField();
 }
 
 void LayoutTestController::removeChromeInputField(JSValueRef callback)
 {
-    cacheLayoutTestControllerCallback(2, callback);
+    cacheLayoutTestControllerCallback(RemoveChromeInputFieldCallbackID, callback);
     InjectedBundle::shared().postRemoveChromeInputField();
 }
 
 void LayoutTestController::focusWebView(JSValueRef callback)
 {
-    cacheLayoutTestControllerCallback(3, callback);
+    cacheLayoutTestControllerCallback(FocusWebViewCallbackID, callback);
     InjectedBundle::shared().postFocusWebView();
 }
 
+void LayoutTestController::setWindowIsKey(bool isKey)
+{
+    InjectedBundle::shared().postSetWindowIsKey(isKey);
+}
+
 void LayoutTestController::callAddChromeInputFieldCallback()
 {
-    callLayoutTestControllerCallback(1);
+    callLayoutTestControllerCallback(AddChromeInputFieldCallbackID);
 }
 
 void LayoutTestController::callRemoveChromeInputFieldCallback()
 {
-    callLayoutTestControllerCallback(2);
+    callLayoutTestControllerCallback(RemoveChromeInputFieldCallbackID);
 }
 
 void LayoutTestController::callFocusWebViewCallback()
 {
-    callLayoutTestControllerCallback(3);
+    callLayoutTestControllerCallback(FocusWebViewCallbackID);
 }
 
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h	2011-10-10 21:01:59 UTC (rev 97081)
@@ -181,6 +181,8 @@
     void addChromeInputField(JSValueRef);
     void removeChromeInputField(JSValueRef);
     void focusWebView(JSValueRef);
+    void setWindowIsKey(bool);
+
     void callAddChromeInputFieldCallback();
     void callRemoveChromeInputFieldCallback();
     void callFocusWebViewCallback();

Modified: trunk/Tools/WebKitTestRunner/PlatformWebView.h (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/PlatformWebView.h	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/PlatformWebView.h	2011-10-10 21:01:59 UTC (rev 97081)
@@ -34,13 +34,13 @@
 #elif defined(__APPLE__) && __APPLE__
 #if __OBJC__
 @class WKView;
-@class NSWindow;
+@class WebKitTestRunnerWindow;
 #else
 class WKView;
-class NSWindow;
+class WebKitTestRunnerWindow;
 #endif
 typedef WKView* PlatformWKView;
-typedef NSWindow* PlatformWindow;
+typedef WebKitTestRunnerWindow* PlatformWindow;
 #elif defined(WIN32) || defined(_WIN32)
 typedef WKViewRef PlatformWKView;
 typedef HWND PlatformWindow;
@@ -74,10 +74,13 @@
     void addChromeInputField();
     void removeChromeInputField();
     void makeWebViewFirstResponder();
+    void setWindowIsKey(bool isKey) { m_windowIsKey = isKey; }
+    bool windowIsKey() const { return m_windowIsKey; }
 
 private:
     PlatformWKView m_view;
     PlatformWindow m_window;
+    bool m_windowIsKey;
 };
 
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2011-10-10 21:01:59 UTC (rev 97081)
@@ -128,16 +128,31 @@
 
 void TestController::runModal(WKPageRef page, const void* clientInfo)
 {
-    runModal(static_cast<PlatformWebView*>(const_cast<void*>(clientInfo)));
+    PlatformWebView* view = static_cast<PlatformWebView*>(const_cast<void*>(clientInfo));
+    view->setWindowIsKey(false);
+    runModal(view);
+    view->setWindowIsKey(true);
 }
 
 static void closeOtherPage(WKPageRef page, const void* clientInfo)
 {
     WKPageClose(page);
-    const PlatformWebView* view = static_cast<const PlatformWebView*>(clientInfo);
+    PlatformWebView* view = static_cast<PlatformWebView*>(const_cast<void*>(clientInfo));
     delete view;
 }
 
+static void focus(WKPageRef page, const void* clientInfo)
+{
+    PlatformWebView* view = static_cast<PlatformWebView*>(const_cast<void*>(clientInfo));
+    view->setWindowIsKey(true);
+}
+
+static void unfocus(WKPageRef page, const void* clientInfo)
+{
+    PlatformWebView* view = static_cast<PlatformWebView*>(const_cast<void*>(clientInfo));
+    view->setWindowIsKey(false);
+}
+
 WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*)
 {
     PlatformWebView* view = new PlatformWebView(WKPageGetContext(oldPage), WKPageGetPageGroup(oldPage));
@@ -152,8 +167,8 @@
         0, // showPage
         closeOtherPage,
         0, // takeFocus
-        0, // focus
-        0, // unfocus
+        focus,
+        unfocus,
         0, // runJavaScriptAlert        
         0, // runJavaScriptConfirm
         0, // runJavaScriptPrompt
@@ -350,7 +365,7 @@
         0, // didStartProvisionalLoadForFrame
         0, // didReceiveServerRedirectForProvisionalLoadForFrame
         0, // didFailProvisionalLoadWithErrorForFrame
-        0, // didCommitLoadForFrame
+        didCommitLoadForFrame,
         0, // didFinishDocumentLoadForFrame
         didFinishLoadForFrame,
         0, // didFailLoadWithErrorForFrame
@@ -608,6 +623,11 @@
 
 // WKPageLoaderClient
 
+void TestController::didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef, const void* clientInfo)
+{
+    static_cast<TestController*>(const_cast<void*>(clientInfo))->didCommitLoadForFrame(page, frame);
+}
+
 void TestController::didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef, const void* clientInfo)
 {
     static_cast<TestController*>(const_cast<void*>(clientInfo))->didFinishLoadForFrame(page, frame);
@@ -618,6 +638,14 @@
     static_cast<TestController*>(const_cast<void*>(clientInfo))->processDidCrash();
 }
 
+void TestController::didCommitLoadForFrame(WKPageRef page, WKFrameRef frame)
+{
+    if (!WKFrameIsMainFrame(frame))
+        return;
+
+    mainWebView()->focus();
+}
+
 void TestController::didFinishLoadForFrame(WKPageRef page, WKFrameRef frame)
 {
     if (m_state != Resetting)

Modified: trunk/Tools/WebKitTestRunner/TestController.h (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/TestController.h	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2011-10-10 21:01:59 UTC (rev 97081)
@@ -71,6 +71,7 @@
     void platformInitialize();
     void platformInitializeContext();
     void platformRunUntil(bool& done, double timeout);
+    void platformDidCommitLoadForFrame(WKPageRef, WKFrameRef);
     void initializeInjectedBundlePath();
     void initializeTestPluginDirectory();
 
@@ -83,9 +84,12 @@
     WKRetainPtr<WKTypeRef> didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
 
     // WKPageLoaderClient
-    static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void*);
-    void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame);
+    static void didCommitLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void*);
+    void didCommitLoadForFrame(WKPageRef, WKFrameRef);
 
+    static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void*);
+    void didFinishLoadForFrame(WKPageRef, WKFrameRef);
+
     static void processDidCrash(WKPageRef, const void* clientInfo);
     void processDidCrash();
 

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2011-10-10 21:01:59 UTC (rev 97081)
@@ -273,8 +273,15 @@
     ASSERT_NOT_REACHED();
 }
 
-WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedBundle(WKStringRef /*messageName*/, WKTypeRef /*messageBody*/)
+WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
 {
+    if (WKStringIsEqualToUTF8CString(messageName, "SetWindowIsKey")) {
+        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
+        WKBooleanRef isKeyValue = static_cast<WKBooleanRef>(messageBody);
+        TestController::shared().mainWebView()->setWindowIsKey(WKBooleanGetValue(isKeyValue));
+        return 0;
+    }
+
     ASSERT_NOT_REACHED();
     return 0;
 }

Modified: trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp	2011-10-10 21:01:59 UTC (rev 97081)
@@ -35,6 +35,7 @@
 PlatformWebView::PlatformWebView(WKContextRef context, WKPageGroupRef pageGroup)
     : m_view(WKViewCreate(context, pageGroup))
     , m_window(gtk_window_new(GTK_WINDOW_POPUP))
+    , m_windowIsKey(true)
 {
     gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(m_view));
 

Modified: trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm	2011-10-10 21:01:59 UTC (rev 97081)
@@ -25,15 +25,32 @@
 
 #include "PlatformWebView.h"
 
+@interface WebKitTestRunnerWindow : NSWindow {
+    WTR::PlatformWebView* _platformWebView;
+}
+@property (nonatomic, assign) WTR::PlatformWebView* platformWebView;
+@end
+
+@implementation WebKitTestRunnerWindow
+@synthesize platformWebView = _platformWebView;
+
+- (BOOL)isKeyWindow
+{
+    return _platformWebView ? _platformWebView->windowIsKey() : YES;
+}
+@end
+
 namespace WTR {
 
 PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+    : m_windowIsKey(true)
 {
     NSRect rect = NSMakeRect(0, 0, 800, 600);
     m_view = [[WKView alloc] initWithFrame:rect contextRef:contextRef pageGroupRef:pageGroupRef];
 
     NSRect windowRect = NSOffsetRect(rect, -10000, [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
-    m_window = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
+    m_window = [[WebKitTestRunnerWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
+    m_window.platformWebView = this;
     [m_window setColorSpace:[NSColorSpace genericRGBColorSpace]];
     [[m_window contentView] addSubview:m_view];
     [m_window orderBack:nil];
@@ -48,6 +65,7 @@
 
 PlatformWebView::~PlatformWebView()
 {
+    m_window.platformWebView = 0;
     [m_window close];
     [m_window release];
     [m_view release];
@@ -60,7 +78,8 @@
 
 void PlatformWebView::focus()
 {
-    // Implement.
+    [m_window makeFirstResponder:m_view];
+    setWindowIsKey(true);
 }
 
 WKRect PlatformWebView::windowFrame()

Modified: trunk/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp	2011-10-10 21:01:59 UTC (rev 97081)
@@ -69,6 +69,7 @@
 PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
     : m_view(new QDesktopWebView(contextRef, pageGroupRef))
     , m_window(new WrapperWindow(m_view))
+    , m_windowIsKey(true)
 {
 }
 

Modified: trunk/Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp (97080 => 97081)


--- trunk/Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp	2011-10-10 20:48:17 UTC (rev 97080)
+++ trunk/Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp	2011-10-10 21:01:59 UTC (rev 97081)
@@ -49,6 +49,7 @@
 }
 
 PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+    : m_windowIsKey(true)
 {
     registerWindowClass();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to