Title: [170858] trunk/Source/WebKit2
Revision
170858
Author
enr...@apple.com
Date
2014-07-07 14:42:53 -0700 (Mon, 07 Jul 2014)

Log Message

REGRESSION(iOS WK2): arrow keys movements don't work.
https://bugs.webkit.org/show_bug.cgi?id=134561
<rdar://problem/16827629>

Reviewed by Benjamin Poulain.

This change add the implementations for cursor movement selectors.
It also provides a mechanism to ensure that every selection
change in WebKit is reflected in UIKit so that it can update the 
autocorrection data. This way we ensure that the autocorraction state
is consistent even when selection changes are originated by _javascript_.
WebPageProxy::editorStateChanged now notifies the page client when the
selection is about to change as well as when it actually changed.
        
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::editorStateChanged):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::selectionWillChange):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cut:]): Removed incorrect calls to textWillChange and
textDidChange.
(-[WKContentView paste:]):
(-[WKContentView _moveUp:withHistory:]):
(-[WKContentView _moveDown:withHistory:]):
(-[WKContentView _moveLeft:withHistory:]):
(-[WKContentView _moveRight:withHistory:]):
(-[WKContentView _moveToStartOfWord:withHistory:]):
(-[WKContentView _moveToStartOfParagraph:withHistory:]):
(-[WKContentView _moveToStartOfLine:withHistory:]):
(-[WKContentView _moveToStartOfDocument:withHistory:]):
(-[WKContentView _moveToEndOfWord:withHistory:]):
(-[WKContentView _moveToEndOfParagraph:withHistory:]):
(-[WKContentView _moveToEndOfLine:withHistory:]):
(-[WKContentView _moveToEndOfDocument:withHistory:]):
(-[WKContentView _selectionWillChange]):
(-[WKContentView _selectionChanged]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::notifySelectionWillChange):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (170857 => 170858)


--- trunk/Source/WebKit2/ChangeLog	2014-07-07 21:06:15 UTC (rev 170857)
+++ trunk/Source/WebKit2/ChangeLog	2014-07-07 21:42:53 UTC (rev 170858)
@@ -1,3 +1,48 @@
+2014-07-07  Enrica Casucci  <enr...@apple.com>
+
+        REGRESSION(iOS WK2): arrow keys movements don't work.
+        https://bugs.webkit.org/show_bug.cgi?id=134561
+        <rdar://problem/16827629>
+
+        Reviewed by Benjamin Poulain.
+
+        This change add the implementations for cursor movement selectors.
+        It also provides a mechanism to ensure that every selection
+        change in WebKit is reflected in UIKit so that it can update the 
+        autocorrection data. This way we ensure that the autocorraction state
+        is consistent even when selection changes are originated by _javascript_.
+        WebPageProxy::editorStateChanged now notifies the page client when the
+        selection is about to change as well as when it actually changed.
+        
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::editorStateChanged):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::selectionWillChange):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView cut:]): Removed incorrect calls to textWillChange and
+        textDidChange.
+        (-[WKContentView paste:]):
+        (-[WKContentView _moveUp:withHistory:]):
+        (-[WKContentView _moveDown:withHistory:]):
+        (-[WKContentView _moveLeft:withHistory:]):
+        (-[WKContentView _moveRight:withHistory:]):
+        (-[WKContentView _moveToStartOfWord:withHistory:]):
+        (-[WKContentView _moveToStartOfParagraph:withHistory:]):
+        (-[WKContentView _moveToStartOfLine:withHistory:]):
+        (-[WKContentView _moveToStartOfDocument:withHistory:]):
+        (-[WKContentView _moveToEndOfWord:withHistory:]):
+        (-[WKContentView _moveToEndOfParagraph:withHistory:]):
+        (-[WKContentView _moveToEndOfLine:withHistory:]):
+        (-[WKContentView _moveToEndOfDocument:withHistory:]):
+        (-[WKContentView _selectionWillChange]):
+        (-[WKContentView _selectionChanged]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::notifySelectionWillChange):
+
 2014-07-07  Anders Carlsson  <ander...@apple.com>
 
         Add SPI for saving and restoring a WKWebView's _WKSessionState

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (170857 => 170858)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2014-07-07 21:06:15 UTC (rev 170857)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2014-07-07 21:42:53 UTC (rev 170858)
@@ -259,6 +259,7 @@
 
     virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) = 0;
     virtual void stopAssistingNode() = 0;
+    virtual void selectionWillChange() = 0;
     virtual void selectionDidChange() = 0;
     virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) = 0;
     virtual void positionInformationDidChange(const InteractionInformationAtPosition&) = 0;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (170857 => 170858)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-07-07 21:06:15 UTC (rev 170857)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-07-07 21:42:53 UTC (rev 170858)
@@ -3410,6 +3410,9 @@
     m_temporarilyClosedComposition = editorState.shouldIgnoreCompositionSelectionChange && (m_temporarilyClosedComposition || m_editorState.hasComposition) && !editorState.hasComposition;
 #endif
 
+#if PLATFORM(IOS)
+    notifySelectionWillChange();
+#endif
     m_editorState = editorState;
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (170857 => 170858)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-07-07 21:06:15 UTC (rev 170857)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-07-07 21:42:53 UTC (rev 170858)
@@ -1222,7 +1222,7 @@
     void enableInspectorNodeSearch();
     void disableInspectorNodeSearch();
 #endif
-
+    void notifySelectionWillChange();
     void notifyRevealedSelection();
 #endif // PLATFORM(IOS)
 

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (170857 => 170858)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2014-07-07 21:06:15 UTC (rev 170857)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2014-07-07 21:42:53 UTC (rev 170858)
@@ -119,6 +119,7 @@
 
     virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) override;
     virtual void stopAssistingNode() override;
+    virtual void selectionWillChange() override;
     virtual void selectionDidChange() override;
     virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) override;
     virtual void positionInformationDidChange(const InteractionInformationAtPosition&) override;

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (170857 => 170858)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2014-07-07 21:06:15 UTC (rev 170857)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2014-07-07 21:42:53 UTC (rev 170858)
@@ -350,6 +350,11 @@
     notImplemented();
 }
 
+void PageClientImpl::selectionWillChange()
+{
+    [m_contentView _selectionWillChange];
+}
+
 void PageClientImpl::selectionDidChange()
 {
     [m_contentView _selectionChanged];

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (170857 => 170858)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2014-07-07 21:06:15 UTC (rev 170857)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2014-07-07 21:42:53 UTC (rev 170858)
@@ -164,6 +164,7 @@
 
 - (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode userObject:(NSObject <NSSecureCoding> *)userObject;
 - (void)_stopAssistingNode;
+- (void)_selectionWillChange;
 - (void)_selectionChanged;
 - (void)_updateChangedSelection;
 - (BOOL)_interpretKeyEvent:(WebIOSEvent *)theEvent isCharEvent:(BOOL)isCharEvent;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (170857 => 170858)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-07-07 21:06:15 UTC (rev 170857)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-07-07 21:42:53 UTC (rev 170858)
@@ -1289,20 +1289,12 @@
 
 - (void)cut:(id)sender
 {
-    [self.inputDelegate textWillChange:self];
-
     _page->executeEditCommand(ASCIILiteral("cut"));
-
-    [self.inputDelegate textDidChange:self];
 }
 
 - (void)paste:(id)sender
 {
-    [self.inputDelegate textWillChange:self];
-    
     _page->executeEditCommand(ASCIILiteral("paste"));
-    
-    [self.inputDelegate textDidChange:self];
 }
 
 - (void)select:(id)sender
@@ -2218,6 +2210,78 @@
     return NO;
 }
 
+- (UITextInputArrowKeyHistory *)_moveUp:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveUp"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveDown:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveDown"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveLeft:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveLeft"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveRight:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveRight"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveToStartOfWord:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveWordBackward"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveToStartOfParagraph:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveToStartOfParagraph"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveToStartOfLine:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveToStartOfLine"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveToStartOfDocument:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveToBeginningOfDocument"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveToEndOfWord:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveWordForward"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveToEndOfParagraph:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveToEndOfParagraph"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveToEndOfLine:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveToEndOfLine"));
+    return nil;
+}
+
+- (UITextInputArrowKeyHistory *)_moveToEndOfDocument:(BOOL) extending withHistory:(UITextInputArrowKeyHistory *)history
+{
+    _page->executeEditCommand(ASCIILiteral("moveToEndOfDocument"));
+    return nil;
+}
+
 // Sets a buffer to make room for autocorrection views
 - (void)setBottomBufferHeight:(CGFloat)bottomBuffer
 {
@@ -2425,6 +2489,13 @@
     [_webSelectionAssistant resignedFirstResponder];
 }
 
+- (void)_selectionWillChange
+{
+    if (_usingGestureForSelection)
+        return;
+    [self beginSelectionChange];
+}
+
 - (void)_selectionChanged
 {
     _selectionNeedsUpdate = YES;
@@ -2432,6 +2503,8 @@
     // to wait to paint the selection.
     if (_usingGestureForSelection)
         [self _updateChangedSelection];
+    else
+        [self endSelectionChange];
 }
 
 - (void)selectWordForReplacement

Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (170857 => 170858)


--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2014-07-07 21:06:15 UTC (rev 170857)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2014-07-07 21:42:53 UTC (rev 170858)
@@ -466,6 +466,11 @@
     m_process->send(Messages::WebPage::ApplicationDidBecomeActive(), m_pageID);
 }
 
+void WebPageProxy::notifySelectionWillChange()
+{
+    m_pageClient.selectionWillChange();
+}
+
 void WebPageProxy::notifyRevealedSelection()
 {
     m_pageClient.selectionDidChange();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to