Title: [165081] trunk/Source/WebKit2
Revision
165081
Author
[email protected]
Date
2014-03-04 14:52:56 -0800 (Tue, 04 Mar 2014)

Log Message

[iOS WebKit2]: Next/Prev button in the accessory bar do not work.
https://bugs.webkit.org/show_bug.cgi?id=129690
<rdar://problem/16073569>

Reviewed by Simon Fraser.

Adding support for Next and Previous buttons in the accessory bar.
When the request is processed by the WebProcess, we identify the next
focusable node that needs to be assisted and we call focus() on the element
letting the focus changing machinery take care of updating the assisted node.
This change also add support for the Clear button, when appropriate and hooks up
the call to the WebProcess.

* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView accessoryTab:]):
(-[WKContentView accessoryClear]):
(-[WKContentView _updateAccessory]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::focusNextAssistedNode):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::nextFocusableElement):
(WebKit::hasFocusableElement):
(WebKit::WebPage::focusNextAssistedNode):
(WebKit::WebPage::getAssistedNodeInformation):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (165080 => 165081)


--- trunk/Source/WebKit2/ChangeLog	2014-03-04 22:48:30 UTC (rev 165080)
+++ trunk/Source/WebKit2/ChangeLog	2014-03-04 22:52:56 UTC (rev 165081)
@@ -1,3 +1,33 @@
+2014-03-04  Enrica Casucci  <[email protected]>
+
+        [iOS WebKit2]: Next/Prev button in the accessory bar do not work.
+        https://bugs.webkit.org/show_bug.cgi?id=129690
+        <rdar://problem/16073569>
+
+        Reviewed by Simon Fraser.
+
+        Adding support for Next and Previous buttons in the accessory bar.
+        When the request is processed by the WebProcess, we identify the next
+        focusable node that needs to be assisted and we call focus() on the element
+        letting the focus changing machinery take care of updating the assisted node.
+        This change also add support for the Clear button, when appropriate and hooks up
+        the call to the WebProcess.
+
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView accessoryTab:]):
+        (-[WKContentView accessoryClear]):
+        (-[WKContentView _updateAccessory]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::focusNextAssistedNode):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::nextFocusableElement):
+        (WebKit::hasFocusableElement):
+        (WebKit::WebPage::focusNextAssistedNode):
+        (WebKit::WebPage::getAssistedNodeInformation):
+
 2014-03-04  Simon Fraser  <[email protected]>
 
         Allow iOS DumpRenderTree crashes to show application-specific information

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (165080 => 165081)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-03-04 22:48:30 UTC (rev 165080)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-03-04 22:52:56 UTC (rev 165081)
@@ -480,6 +480,7 @@
     void performActionOnElement(uint32_t action);
     void saveImageToLibrary(const SharedMemory::Handle& imageHandle, uint64_t imageSize);
     void didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold);
+    void focusNextAssistedNode(bool isForward);
     void setAssistedNodeValue(const String&);
     void setAssistedNodeValueAsNumber(double);
     void setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection = false);

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (165080 => 165081)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-03-04 22:48:30 UTC (rev 165080)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-03-04 22:52:56 UTC (rev 165081)
@@ -1287,6 +1287,7 @@
 
 - (void)accessoryTab:(BOOL)isNext
 {
+    _page->focusNextAssistedNode(isNext);
 }
 
 - (void)accessoryAutoFill
@@ -1295,15 +1296,30 @@
 
 - (void)accessoryClear
 {
+    _page->setAssistedNodeValue(String());
 }
 
 - (void)_updateAccessory
 {
     [_formAccessoryView setNextEnabled:_assistedNodeInformation.hasNextNode];
     [_formAccessoryView setPreviousEnabled:_assistedNodeInformation.hasPreviousNode];
-    
-    [_formAccessoryView setClearVisible:NO];
 
+    if (UICurrentUserInterfaceIdiomIsPad())
+        [_formAccessoryView setClearVisible:NO];
+    else {
+        switch (_assistedNodeInformation.elementType) {
+        case WebKit::WKTypeDate:
+        case WebKit::WKTypeMonth:
+        case WebKit::WKTypeDateTimeLocal:
+        case WebKit::WKTypeTime:
+            [_formAccessoryView setClearVisible:YES];
+            break;
+        default:
+            [_formAccessoryView setClearVisible:NO];
+            break;
+        }
+    }
+
     // FIXME: hide or show the AutoFill button as needed.
 }
 

Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (165080 => 165081)


--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2014-03-04 22:48:30 UTC (rev 165080)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2014-03-04 22:52:56 UTC (rev 165081)
@@ -510,6 +510,11 @@
     m_pageClient.stopAssistingNode();
 }
 
+void WebPageProxy::focusNextAssistedNode(bool isForward)
+{
+    process().send(Messages::WebPage::FocusNextAssistedNode(isForward), m_pageID);
+}
+
 void WebPageProxy::setAssistedNodeValue(const String& value)
 {
     process().send(Messages::WebPage::SetAssistedNodeValue(value), m_pageID);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (165080 => 165081)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-03-04 22:48:30 UTC (rev 165080)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-03-04 22:52:56 UTC (rev 165081)
@@ -466,6 +466,7 @@
     void startInteractionWithElementAtPosition(const WebCore::IntPoint&);
     void stopInteraction();
     void performActionOnElement(uint32_t action);
+    void focusNextAssistedNode(bool isForward);
     void setAssistedNodeValue(const String&);
     void setAssistedNodeValueAsNumber(double);
     void setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (165080 => 165081)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2014-03-04 22:48:30 UTC (rev 165080)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2014-03-04 22:52:56 UTC (rev 165081)
@@ -64,6 +64,7 @@
     StartInteractionWithElementAtPosition(WebCore::IntPoint point)
     StopInteraction()
     PerformActionOnElement(uint32_t action)
+    FocusNextAssistedNode(bool isForward)
     SetAssistedNodeValue(String value)
     SetAssistedNodeValueAsNumber(double value)
     SetAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (165080 => 165081)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-03-04 22:48:30 UTC (rev 165080)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-03-04 22:52:56 UTC (rev 165081)
@@ -1568,26 +1568,38 @@
     return node->isContentEditable();
 }
 
-static inline bool hasFocusableNode(Node* startNode, Page* page, bool isForward)
+static inline Element* nextFocusableElement(Node* startNode, Page* page, bool isForward)
 {
     RefPtr<KeyboardEvent> key = KeyboardEvent::create();
 
-    Node* nextNode = startNode;
+    Element* nextElement = toElement(startNode);
     do {
-        nextNode = isForward ? page->focusController().nextFocusableElement(FocusNavigationScope::focusNavigationScopeOf(&nextNode->document()), nextNode, key.get())
-            : page->focusController().previousFocusableElement(FocusNavigationScope::focusNavigationScopeOf(&nextNode->document()), nextNode, key.get());
-    } while (nextNode && !isAssistableNode(nextNode));
+        nextElement = isForward ? page->focusController().nextFocusableElement(FocusNavigationScope::focusNavigationScopeOf(&nextElement->document()), nextElement, key.get())
+            : page->focusController().previousFocusableElement(FocusNavigationScope::focusNavigationScopeOf(&nextElement->document()), nextElement, key.get());
+    } while (nextElement && !isAssistableNode(nextElement));
 
-    return nextNode;
+    return nextElement;
 }
 
+static inline bool hasFocusableElement(Node* startNode, Page* page, bool isForward)
+{
+    return nextFocusableElement(startNode, page, isForward) != nil;
+}
+
+void WebPage::focusNextAssistedNode(bool isForward)
+{
+    Element* nextElement = nextFocusableElement(m_assistedNode.get(), m_page.get(), isForward);
+    if (nextElement)
+        nextElement->focus();
+}
+
 void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information)
 {
     information.elementRect = m_page->focusController().focusedOrMainFrame().view()->contentsToRootView(m_assistedNode->renderer()->absoluteBoundingBoxRect());
     information.minimumScaleFactor = m_viewportConfiguration.minimumScale();
     information.maximumScaleFactor = m_viewportConfiguration.maximumScale();
-    information.hasNextNode = hasFocusableNode(m_assistedNode.get(), m_page.get(), true);
-    information.hasPreviousNode = hasFocusableNode(m_assistedNode.get(), m_page.get(), false);
+    information.hasNextNode = hasFocusableElement(m_assistedNode.get(), m_page.get(), true);
+    information.hasPreviousNode = hasFocusableElement(m_assistedNode.get(), m_page.get(), false);
 
     if (isHTMLSelectElement(m_assistedNode.get())) {
         HTMLSelectElement* element = toHTMLSelectElement(m_assistedNode.get());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to