Fixed: <rdar://problem/3802039> 8A259: Can't use Grab services to grab selection...
authorcblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Oct 2004 17:20:44 +0000 (17:20 +0000)
committercblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Oct 2004 17:20:44 +0000 (17:20 +0000)
        Reviewed by john.

        * WebView.subproj/WebHTMLView.m:
        (+[WebHTMLView initialize]): register service "return types" which are types that can be inserted into a WebView
        (-[WebHTMLView writeSelectionToPasteboard:types:]): service protocol method, be sure to only write specified types
        (-[WebHTMLView readSelectionFromPasteboard:]): new, service protocol method, insert types
        (-[WebHTMLView validRequestorForSendType:returnType:]): moved, handle return types

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

WebKit/ChangeLog
WebKit/WebView.subproj/WebHTMLView.m

index 38d21b80ff125ef96e740daf54beb92f585e1870..34efac770ee2c2f93e7fa44bb1e3c883a2405c94 100644 (file)
@@ -1,3 +1,15 @@
+2004-10-11  Chris Blumenberg  <cblu@apple.com>
+
+       Fixed: <rdar://problem/3802039> 8A259: Can't use Grab services to grab selection from screen
+
+        Reviewed by john.
+
+        * WebView.subproj/WebHTMLView.m:
+        (+[WebHTMLView initialize]): register service "return types" which are types that can be inserted into a WebView
+        (-[WebHTMLView writeSelectionToPasteboard:types:]): service protocol method, be sure to only write specified types
+        (-[WebHTMLView readSelectionFromPasteboard:]): new, service protocol method, insert types
+        (-[WebHTMLView validRequestorForSendType:returnType:]): moved, handle return types
+
 2004-10-11  Darin Adler  <darin@apple.com>
 
         Reviewed by John.
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.