WK1: Support default actions for editable whitespace
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Nov 2014 00:04:56 +0000 (00:04 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Nov 2014 00:04:56 +0000 (00:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138586
-and corresponding-
rdar://problem/18932048

Reviewed by Tim Horton.

New menu type. Just wants paste.

* WebView/WebActionMenuController.mm:
(-[WebActionMenuController isMenuForTextContent]):
(-[WebActionMenuController _defaultMenuItemsForWhitespaceInEditableArea:]):
(-[WebActionMenuController _defaultMenuItemsForHitTestResult:]):
* WebView/WebUIDelegatePrivate.h:

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

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebActionMenuController.mm
Source/WebKit/mac/WebView/WebUIDelegatePrivate.h

index 6a4aac252925256943506c0e7c98337cc75b6986..1b242c80526e5c00ac33a579f8a6bc22dd7dc517 100644 (file)
@@ -1,3 +1,20 @@
+2014-11-10  Beth Dakin  <bdakin@apple.com>
+
+        WK1: Support default actions for editable whitespace
+        https://bugs.webkit.org/show_bug.cgi?id=138586
+        -and corresponding-
+        rdar://problem/18932048
+
+        Reviewed by Tim Horton.
+
+        New menu type. Just wants paste.
+
+        * WebView/WebActionMenuController.mm:
+        (-[WebActionMenuController isMenuForTextContent]):
+        (-[WebActionMenuController _defaultMenuItemsForWhitespaceInEditableArea:]):
+        (-[WebActionMenuController _defaultMenuItemsForHitTestResult:]):
+        * WebView/WebUIDelegatePrivate.h:
+
 2014-11-10  Beth Dakin  <bdakin@apple.com>
 
         WK1: Support default actions for editable text
 2014-11-10  Beth Dakin  <bdakin@apple.com>
 
         WK1: Support default actions for editable text
index 2777e0115b643d5658d82dfe8a79d3467737be92..35b6844eb350131a75ec484786ace80ebc86d010 100644 (file)
@@ -128,7 +128,7 @@ struct DictionaryPopupInfo {
 
 - (BOOL)isMenuForTextContent
 {
 
 - (BOOL)isMenuForTextContent
 {
-    return _type == WebActionMenuReadOnlyText || _type == WebActionMenuEditableText;
+    return _type == WebActionMenuReadOnlyText || _type == WebActionMenuEditableText || _type == WebActionMenuWhitespaceInEditableArea;
 }
 
 - (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event
 }
 
 - (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event
@@ -366,6 +366,15 @@ static DictionaryPopupInfo performDictionaryLookupForRange(Frame* frame, Range&
     return popupInfo;
 }
 
     return popupInfo;
 }
 
+#pragma mark Whitespace actions
+
+- (NSArray *)_defaultMenuItemsForWhitespaceInEditableArea:(WebElementDictionary *)hitTestResult
+{
+    RetainPtr<NSMenuItem> pasteItem = [self _createActionMenuItemForTag:WebActionMenuItemTagPaste withHitTestResult:hitTestResult];
+
+    return @[ [NSMenuItem separatorItem], [NSMenuItem separatorItem], pasteItem.get() ];
+}
+
 #pragma mark Menu Items
 
 - (RetainPtr<NSMenuItem>)_createActionMenuItemForTag:(uint32_t)tag withHitTestResult:(WebElementDictionary *)hitTestResult
 #pragma mark Menu Items
 
 - (RetainPtr<NSMenuItem>)_createActionMenuItemForTag:(uint32_t)tag withHitTestResult:(WebElementDictionary *)hitTestResult
@@ -453,6 +462,11 @@ static NSImage *webKitBundleImageNamed(NSString *name)
         return [self _defaultMenuItemsForText:hitTestResult];
     }
 
         return [self _defaultMenuItemsForText:hitTestResult];
     }
 
+    if (_hitTestResult.isContentEditable()) {
+        _type = WebActionMenuWhitespaceInEditableArea;
+        return [self _defaultMenuItemsForWhitespaceInEditableArea:hitTestResult];
+    }
+
     _type = WebActionMenuNone;
     return @[ ];
 }
     _type = WebActionMenuNone;
     return @[ ];
 }
index c76e4656667c77ac900b763cc688a4bb9d51e583..f41d908fe9678c1b79b1c16d2ca308a197942279 100644 (file)
@@ -126,7 +126,8 @@ typedef enum {
     WebActionMenuNone = 0,
     WebActionMenuLink,
     WebActionMenuReadOnlyText,
     WebActionMenuNone = 0,
     WebActionMenuLink,
     WebActionMenuReadOnlyText,
-    WebActionMenuEditableText
+    WebActionMenuEditableText,
+    WebActionMenuWhitespaceInEditableArea
 } WebActionMenuType;
 
 // Message Sources.
 } WebActionMenuType;
 
 // Message Sources.