Title: [226826] trunk/Source/WebKit
Revision
226826
Author
[email protected]
Date
2018-01-11 17:43:06 -0800 (Thu, 11 Jan 2018)

Log Message

Implement MultiDocument protocol for restoring focus to a WKWebView
https://bugs.webkit.org/show_bug.cgi?id=181510

Reviewed by Dan Bernstein.

Support the UIKit protocol for restoring focus to a what previously had focus.
WebKit already has a method to silently remove and replace focus, without telling the
web process about the unfocus and refocusing, so we're just using that.

* Platform/spi/ios/UIKitSPI.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _restoreFocusWithToken:]):
(-[WKContentView _preserveFocusWithToken:destructively:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (226825 => 226826)


--- trunk/Source/WebKit/ChangeLog	2018-01-12 01:16:59 UTC (rev 226825)
+++ trunk/Source/WebKit/ChangeLog	2018-01-12 01:43:06 UTC (rev 226826)
@@ -1,3 +1,21 @@
+2018-01-11  Megan Gardner  <[email protected]>
+
+        Implement MultiDocument protocol for restoring focus to a WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=181510
+
+        Reviewed by Dan Bernstein.
+
+        Support the UIKit protocol for restoring focus to a what previously had focus.
+        WebKit already has a method to silently remove and replace focus, without telling the
+        web process about the unfocus and refocusing, so we're just using that.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _restoreFocusWithToken:]):
+        (-[WKContentView _preserveFocusWithToken:destructively:]):
+
+
 2018-01-11  Wenson Hsieh  <[email protected]>
 
         Don't load inline data when requesting info for an attachment element backed by a file path

Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (226825 => 226826)


--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2018-01-12 01:16:59 UTC (rev 226825)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2018-01-12 01:43:06 UTC (rev 226826)
@@ -378,6 +378,12 @@
 @interface UITextInputTraits : NSObject <UITextInputTraits, UITextInputTraits_Private, NSCopying>
 @end
 
+@protocol UITextInputMultiDocument <NSObject>
+@optional
+- (void)_restoreFocusWithToken:(id <NSCopying, NSSecureCoding>)token completion:(void (^)(BOOL didRestore))completion;
+- (void)_preserveFocusWithToken:(id <NSCopying, NSSecureCoding>)token destructively:(BOOL)destructively;
+@end
+
 @interface UITextInteractionAssistant : NSObject
 @end
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (226825 => 226826)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2018-01-12 01:16:59 UTC (rev 226825)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2018-01-12 01:43:06 UTC (rev 226826)
@@ -242,7 +242,7 @@
 
 @end
 
-@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate, WKActionSheetAssistantDelegate, UITextAutoscrolling
+@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UITextAutoscrolling, UITextInputMultiDocument, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWebTouchEventsGestureRecognizerDelegate, UIWKInteractionViewProtocol, WKActionSheetAssistantDelegate, WKFileUploadPanelDelegate
 #if ENABLE(DATA_INTERACTION)
     , UIDragInteractionDelegate, UIDropInteractionDelegate
 #endif

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (226825 => 226826)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-01-12 01:16:59 UTC (rev 226825)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-01-12 01:43:06 UTC (rev 226826)
@@ -4127,6 +4127,18 @@
     _fileUploadPanel = nil;
 }
 
+#pragma mark - UITextInputMultiDocument
+
+- (void)_restoreFocusWithToken:(id <NSCopying, NSSecureCoding>)token
+{
+    --_webView->_activeFocusedStateRetainCount;
+}
+
+- (void)_preserveFocusWithToken:(id <NSCopying, NSSecureCoding>)token destructively:(BOOL)destructively
+{
+    ++_webView->_activeFocusedStateRetainCount;
+}
+
 #pragma mark - Implementation of UIWebTouchEventsGestureRecognizerDelegate.
 
 // FIXME: Remove once -gestureRecognizer:shouldIgnoreWebTouchWithEvent: is in UIWebTouchEventsGestureRecognizer.h. Refer to <rdar://problem/33217525> for more details.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to