Fixed: <rdar://problem/3802039> 8A259: Can't use Grab services to grab selection...
[WebKit-https.git] / WebKit / WebView.subproj / WebHTMLView.m
index 3a7b575250b91bd9726f4ba5b0421ac5a14d9272..b81f1b166bfdd8a1fa9947a6c630bac74a2b6b3c 100644 (file)
@@ -1341,7 +1341,8 @@ static WebHTMLView *lastHitView = nil;
 + (void)initialize
 {
     WebKitInitializeUnicode();
-    [NSApp registerServicesMenuSendTypes:[[self class] _selectionPasteboardTypes] returnTypes:nil];
+    [NSApp registerServicesMenuSendTypes:[[self class] _selectionPasteboardTypes] 
+                             returnTypes:[[self class] _insertablePasteboardTypes]];
     _NSInitializeKillRing();
 }
 
@@ -1481,10 +1482,27 @@ static WebHTMLView *lastHitView = nil;
 
 - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
 {
-    [self _writeSelectionToPasteboard:pasteboard];
+    [pasteboard declareTypes:types owner:nil];
+    [self writeSelectionWithPasteboardTypes:types toPasteboard:pasteboard];
+    return YES;
+}
+
+- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pasteboard
+{
+    [self _pasteWithPasteboard:pasteboard allowPlainText:YES];
     return YES;
 }
 
+- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
+{
+    if (sendType != nil && [[self pasteboardTypesForSelection] containsObject:sendType] && [self _hasSelection]) {
+        return self;
+    } else if (returnType != nil && [[[self class] _insertablePasteboardTypes] containsObject:returnType] && [self _isEditable]) {
+        return self;
+    }
+    return [[self nextResponder] validRequestorForSendType:sendType returnType:returnType];
+}
+
 - (void)selectAll:(id)sender
 {
     [self selectAll];
@@ -1522,15 +1540,6 @@ static WebHTMLView *lastHitView = nil;
     return YES;
 }
 
-- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
-{
-    if (sendType && ([[[self class] _selectionPasteboardTypes] containsObject:sendType]) && [self _hasSelection]){
-        return self;
-    }
-
-    return [super validRequestorForSendType:sendType returnType:returnType];
-}
-
 - (BOOL)acceptsFirstResponder
 {
     // Don't accept first responder when we first click on this view.