Reviewed by Anders Carlsson.
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Dec 2010 22:43:49 +0000 (22:43 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Dec 2010 22:43:49 +0000 (22:43 +0000)
        Implement WKView::setInitialFocus().
        https://bugs.webkit.org/show_bug.cgi?id=51274

        * UIProcess/API/C/win/WKView.cpp:
        (WKViewSetInitialFocus):
        * UIProcess/API/C/win/WKView.h:
        * UIProcess/WebPageProxy.cpp:
        (WebKit::WebPageProxy::setInitialFocus): Send message to the Web Process to set
        initial focus.
        * UIProcess/WebPageProxy.h:
        * UIProcess/win/WebView.cpp:
        (WebKit::WebView::setInitialFocus):
        * UIProcess/win/WebView.h:
        * WebProcess/WebPage/WebPage.cpp:
        (WebKit::WebPage::setInitialFocus): Set the focused node to null initially.  Then
        ask FocusController to set the initial focus based on the focus direction.
        * WebProcess/WebPage/WebPage.h:
        * WebProcess/WebPage/WebPage.messages.in: Add a new message for SetInitialFocus.

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

WebKit2/ChangeLog
WebKit2/UIProcess/API/C/win/WKView.cpp
WebKit2/UIProcess/API/C/win/WKView.h
WebKit2/UIProcess/WebPageProxy.cpp
WebKit2/UIProcess/WebPageProxy.h
WebKit2/UIProcess/win/WebView.cpp
WebKit2/UIProcess/win/WebView.h
WebKit2/WebProcess/WebPage/WebPage.cpp
WebKit2/WebProcess/WebPage/WebPage.h
WebKit2/WebProcess/WebPage/WebPage.messages.in

index 458fad1..a02f404 100644 (file)
@@ -1,3 +1,26 @@
+2010-12-17  Ada Chan  <adachan@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Implement WKView::setInitialFocus().
+        https://bugs.webkit.org/show_bug.cgi?id=51274
+
+        * UIProcess/API/C/win/WKView.cpp:
+        (WKViewSetInitialFocus):
+        * UIProcess/API/C/win/WKView.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setInitialFocus): Send message to the Web Process to set
+        initial focus.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/win/WebView.cpp:
+        (WebKit::WebView::setInitialFocus):
+        * UIProcess/win/WebView.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setInitialFocus): Set the focused node to null initially.  Then
+        ask FocusController to set the initial focus based on the focus direction.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in: Add a new message for SetInitialFocus.
+
 2010-12-17  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index 290b755..612661e 100644 (file)
@@ -65,3 +65,8 @@ void WKViewSetIsInWindow(WKViewRef viewRef, bool isInWindow)
 {
     toImpl(viewRef)->setIsInWindow(isInWindow);
 }
+
+void WKViewSetInitialFocus(WKViewRef viewRef, bool forward)
+{
+    toImpl(viewRef)->setInitialFocus(forward);
+}
index b9791ec..f4226cd 100644 (file)
@@ -44,6 +44,7 @@ WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
 WK_EXPORT void WKViewSetParentWindow(WKViewRef view, HWND parentWindow);
 WK_EXPORT void WKViewWindowAncestryDidChange(WKViewRef view);
 WK_EXPORT void WKViewSetIsInWindow(WKViewRef view, bool isInWindow);
+WK_EXPORT void WKViewSetInitialFocus(WKViewRef view, bool forward);
 
 #ifdef __cplusplus
 }
index 54ecd25..77b03b9 100644 (file)
@@ -433,6 +433,13 @@ void WebPageProxy::setFocused(bool isFocused)
     process()->send(Messages::WebPage::SetFocused(isFocused), m_pageID);
 }
 
+void WebPageProxy::setInitialFocus(bool forward)
+{
+    if (!isValid())
+        return;
+    process()->send(Messages::WebPage::SetInitialFocus(forward), m_pageID);
+}
+
 void WebPageProxy::setActive(bool active)
 {
     if (!isValid())
index 4514bee..c80004f 100644 (file)
@@ -165,6 +165,7 @@ public:
     void setDrawsTransparentBackground(bool);
 
     void setFocused(bool);
+    void setInitialFocus(bool);
     void setActive(bool);
     void setIsInWindow(bool);
     void setWindowResizerSize(const WebCore::IntSize&);
index 6c5c31d..384a1d4 100644 (file)
@@ -628,6 +628,11 @@ void WebView::setOverrideCursor(HCURSOR overrideCursor)
     updateNativeCursor();
 }
 
+void WebView::setInitialFocus(bool forward)
+{
+    m_page->setInitialFocus(forward);
+}
+
 void WebView::setViewportArguments(const WebCore::ViewportArguments&)
 {
 }
index ffe9e64..05a7e94 100644 (file)
@@ -53,6 +53,7 @@ public:
     void windowAncestryDidChange();
     void setIsInWindow(bool);
     void setOverrideCursor(HCURSOR overrideCursor);
+    void setInitialFocus(bool forward);
 
     WebPageProxy* page() const { return m_page.get(); }
 
index 22754c1..74f6f54 100644 (file)
@@ -827,6 +827,16 @@ void WebPage::setFocused(bool isFocused)
     m_page->focusController()->setFocused(isFocused);
 }
 
+void WebPage::setInitialFocus(bool forward)
+{
+    if (!m_page || !m_page->focusController())
+        return;
+
+    Frame* frame = m_page->focusController()->focusedOrMainFrame();
+    frame->document()->setFocusedNode(0);
+    m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);
+}
+
 void WebPage::setWindowResizerSize(const IntSize& windowResizerSize)
 {
     if (m_windowResizerSize == windowResizerSize)
index d921930..6c4d94b 100644 (file)
@@ -292,6 +292,7 @@ private:
     void goToBackForwardItem(uint64_t);
     void setActive(bool);
     void setFocused(bool);
+    void setInitialFocus(bool);
     void setWindowResizerSize(const WebCore::IntSize&);
     void setIsInWindow(bool);
     void mouseEvent(const WebMouseEvent&);
index e7cea12..6643948 100644 (file)
@@ -23,6 +23,7 @@
 messages -> WebPage {
     SetActive(bool active)
     SetFocused(bool focused)
+    SetInitialFocus(bool forward)
     SetIsInWindow(bool isInWindow)
 
     SetDrawsBackground(bool drawsBackground)