Title: [176701] trunk/Source/WebKit2
Revision
176701
Author
m...@apple.com
Date
2014-12-02 16:59:06 -0800 (Tue, 02 Dec 2014)

Log Message

<rdar://problem/18441138> [iOS] Text selection in WKWebView with WKSelectionGranularityCharacter only works in the most recent WKWebView to load
https://bugs.webkit.org/show_bug.cgi?id=139211

Reviewed by Anders Carlsson.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView becomeFirstResponder]): Override to activate the text selection for when
becoming first resopnder.
(-[WKContentView resignFirstResponder]): Deactiavte the text selection when resigning first
responder. This ensures that if another WKWebView becomes first responder, and it uses
block selection, we don’t end up with two active selection views.
(-[WKContentView useSelectionAssistantWithMode:]): Only activate the text selection if this
is the first responder. This ensures that loading content into a non-first-responder
WKWebView doesn‘t deactivate the text selection in the current first responder.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (176700 => 176701)


--- trunk/Source/WebKit2/ChangeLog	2014-12-03 00:49:19 UTC (rev 176700)
+++ trunk/Source/WebKit2/ChangeLog	2014-12-03 00:59:06 UTC (rev 176701)
@@ -1,3 +1,20 @@
+2014-12-02  Dan Bernstein  <m...@apple.com>
+
+        <rdar://problem/18441138> [iOS] Text selection in WKWebView with WKSelectionGranularityCharacter only works in the most recent WKWebView to load
+        https://bugs.webkit.org/show_bug.cgi?id=139211
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView becomeFirstResponder]): Override to activate the text selection for when
+        becoming first resopnder.
+        (-[WKContentView resignFirstResponder]): Deactiavte the text selection when resigning first
+        responder. This ensures that if another WKWebView becomes first responder, and it uses
+        block selection, we don’t end up with two active selection views.
+        (-[WKContentView useSelectionAssistantWithMode:]): Only activate the text selection if this
+        is the first responder. This ensures that loading content into a non-first-responder
+        WKWebView doesn‘t deactivate the text selection in the current first responder.
+
 2014-12-02  Alexey Proskuryakov  <a...@apple.com>
 
         http/tests/appcache/main-resource-fallback-for-network-error-crash.html can break subsequent tests

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (176700 => 176701)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-12-03 00:49:19 UTC (rev 176700)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-12-03 00:59:06 UTC (rev 176701)
@@ -450,6 +450,15 @@
     return YES;
 }
 
+- (BOOL)becomeFirstResponder
+{
+    BOOL didBecomeFirstResponder = [super becomeFirstResponder];
+    if (didBecomeFirstResponder)
+        [_textSelectionAssistant activateSelection];
+
+    return didBecomeFirstResponder;
+}
+
 - (BOOL)resignFirstResponder
 {
     // FIXME: Maybe we should call resignFirstResponder on the superclass
@@ -459,6 +468,7 @@
     _page->blurAssistedNode();
     [self _cancelInteraction];
     [_webSelectionAssistant resignedFirstResponder];
+    [_textSelectionAssistant deactivateSelection];
 
     return [super resignFirstResponder];
 }
@@ -1086,7 +1096,8 @@
             [_textSelectionAssistant setGestureRecognizers];
         }
 
-        [_textSelectionAssistant activateSelection];
+        if (self.isFirstResponder)
+            [_textSelectionAssistant activateSelection];
     }
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to