Cleanup canPerformActionForWebView in relation to the webSelectionAssistant being...
authormegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2018 23:03:00 +0000 (23:03 +0000)
committermegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2018 23:03:00 +0000 (23:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185536

Reviewed by Tim Horton.

The _webSelectionAssistant is now always nil, therefor many of these checks are unnecessary.
Remove the check for a webSelection and clean up the logic surrounding those checks.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView canPerformActionForWebView:withSender:]):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

index fb9b636..bf6def7 100644 (file)
@@ -1,3 +1,16 @@
+2018-05-11  Megan Gardner  <megan_gardner@apple.com>
+
+        Cleanup canPerformActionForWebView in relation to the webSelectionAssistant being removed
+        https://bugs.webkit.org/show_bug.cgi?id=185536
+
+        Reviewed by Tim Horton.
+        
+        The _webSelectionAssistant is now always nil, therefor many of these checks are unnecessary.
+        Remove the check for a webSelection and clean up the logic surrounding those checks.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView canPerformActionForWebView:withSender:]):
+
 2018-05-11  Brady Eidson  <beidson@apple.com>
 
         Followup to: Make sure history navigations reuse the existing process when necessary.
index aa519c5..b311c17 100644 (file)
@@ -2209,8 +2209,6 @@ FOR_EACH_WKCONTENTVIEW_ACTION(FORWARD_ACTION_TO_WKWEBVIEW)
 
 - (BOOL)canPerformActionForWebView:(SEL)action withSender:(id)sender
 {
-    BOOL hasWebSelection = _webSelectionAssistant && !CGRectIsEmpty(_webSelectionAssistant.get().selectionFrame);
-
     if (action == @selector(_arrowKey:))
         return [self isFirstResponder];
         
@@ -2235,11 +2233,11 @@ FOR_EACH_WKCONTENTVIEW_ACTION(FORWARD_ACTION_TO_WKWEBVIEW)
     if (action == @selector(copy:)) {
         if (_page->editorState().isInPasswordField)
             return NO;
-        return hasWebSelection || _page->editorState().selectionIsRange;
+        return _page->editorState().selectionIsRange;
     }
 
     if (action == @selector(_define:)) {
-        if (_page->editorState().isInPasswordField || !(hasWebSelection || _page->editorState().selectionIsRange))
+        if (_page->editorState().isInPasswordField || !_page->editorState().selectionIsRange)
             return NO;
 
         NSUInteger textLength = _page->editorState().postLayoutData().selectedTextLength;
@@ -2266,18 +2264,18 @@ FOR_EACH_WKCONTENTVIEW_ACTION(FORWARD_ACTION_TO_WKWEBVIEW)
             return NO;
 #endif
 
-        return hasWebSelection || _page->editorState().selectionIsRange;
+        return _page->editorState().selectionIsRange;
     }
 
     if (action == @selector(_share:)) {
-        if (_page->editorState().isInPasswordField || !(hasWebSelection || _page->editorState().selectionIsRange))
+        if (_page->editorState().isInPasswordField || !_page->editorState().selectionIsRange)
             return NO;
 
         return _page->editorState().postLayoutData().selectedTextLength > 0;
     }
 
     if (action == @selector(_addShortcut:)) {
-        if (_page->editorState().isInPasswordField || !(hasWebSelection || _page->editorState().selectionIsRange))
+        if (_page->editorState().isInPasswordField || !_page->editorState().selectionIsRange)
             return NO;
 
         NSString *selectedText = [self selectedText];
@@ -2311,19 +2309,9 @@ FOR_EACH_WKCONTENTVIEW_ACTION(FORWARD_ACTION_TO_WKWEBVIEW)
     }
 
     if (action == @selector(selectAll:)) {
-        if (_page->editorState().selectionIsNone || ![self hasContent])
-            return NO;
-        if (!_page->editorState().selectionIsRange)
+        if (!_page->editorState().selectionIsNone && !_page->editorState().selectionIsRange)
             return YES;
-        // Enable selectAll for non-editable text, where the user can't access
-        // this command via long-press to get a caret.
-        if (_page->editorState().isContentEditable)
-            return NO;
-        // Don't attempt selectAll with general web content.
-        if (hasWebSelection)
-            return NO;
-        // FIXME: Only enable if the selection doesn't already span the entire document.
-        return YES;
+        return NO;
     }
 
     if (action == @selector(replace:))