Changeset 13990 in webkit
- Timestamp:
- Apr 20, 2006 9:51:48 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r13989 r13990 1 2006-04-20 Mitz Pettel <opendarwin.org@mitzpettel.com> 2 3 Reviewed by Darin. 4 5 WebCore part of: 6 - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8276 7 REGRESSION (NativeTextField): Pasting a Finder item into a text field results in 8 a file: URL being pasted instead of just the file name 9 - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8283 10 REGRESSION: File's path doesn't appear after dragging file into input field 11 12 * bridge/mac/WebCoreFrameBridge.h: 13 * bridge/mac/WebCoreFrameBridge.mm: 14 (-[WebCoreFrameBridge isDragCaretRichlyEditable]): Added. 15 * manual-tests/plain-text-paste.html: Added. 16 * manual-tests/resources/plain-text-paste: Added. 17 * manual-tests/resources/plain-text-paste/1.textClipping: Added. 18 * manual-tests/resources/plain-text-paste/2.textClipping: Added. 19 * manual-tests/resources/plain-text-paste/3.gif: Added. 20 * manual-tests/resources/plain-text-paste/4.txt: Added. 21 * manual-tests/resources/plain-text-paste/5.webloc: Added. 22 1 23 2006-04-20 Darin Adler <darin@apple.com> 2 24 -
trunk/WebCore/bridge/mac/WebCoreFrameBridge.h
r13890 r13990 433 433 - (void)removeDragCaret; 434 434 - (DOMRange *)dragCaretDOMRange; 435 - (BOOL)isDragCaretRichlyEditable; 435 436 - (DOMRange *)editableDOMRangeForPoint:(NSPoint)point; 436 437 - (DOMRange *)characterRangeAtPoint:(NSPoint)point; -
trunk/WebCore/bridge/mac/WebCoreFrameBridge.mm
r13901 r13990 2084 2084 } 2085 2085 2086 - (BOOL)isDragCaretRichlyEditable 2087 { 2088 return m_frame->dragCaret().isContentRichlyEditable(); 2089 } 2090 2086 2091 - (DOMRange *)editableDOMRangeForPoint:(NSPoint)point 2087 2092 { -
trunk/WebKit/ChangeLog
r13989 r13990 1 2006-04-20 Mitz Pettel <opendarwin.org@mitzpettel.com> 2 3 Reviewed by Darin. 4 5 WebKit part of: 6 - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8276 7 REGRESSION (NativeTextField): Pasting a Finder item into a text field results in 8 a file: URL being pasted instead of just the file name 9 - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8283 10 REGRESSION: File's path doesn't appear after dragging file into input field 11 12 * WebView/WebHTMLView.m: 13 (-[WebHTMLView _plainTextFromPasteboard:]): Added method that tries to copy AppKit 14 text fields' logic for extracting plain text from the pasteboard. 15 (-[WebHTMLView _pasteAsPlainTextWithPasteboard:]): Added helper method. 16 (-[WebHTMLView _shouldInsertText:replacingDOMRange:givenAction:]): 17 (-[WebHTMLView _shouldReplaceSelectionWithText:givenAction:]): 18 (-[WebHTMLView readSelectionFromPasteboard:]): Paste as plain text if 19 rich text is not allowed. 20 (-[WebHTMLView validateUserInterfaceItem:]): Changed to not allow pasteAsRichText: 21 if the paste is not going to be handled by the DOM and the selection 22 does not allow pasting rich text. 23 (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]): Paste as plain text if 24 rich text is not allowed. 25 (-[WebHTMLView paste:]): Ditto. 26 (-[WebHTMLView pasteAsPlainText:]): 27 1 28 2006-04-20 Darin Adler <darin@apple.com> 2 29 -
trunk/WebKit/WebView/WebHTMLView.m
r13890 r13990 183 183 - (BOOL)_imageExistsAtPaths:(NSArray *)paths; 184 184 - (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText chosePlainText:(BOOL *)chosePlainText; 185 - (NSString *)_plainTextFromPasteboard:(NSPasteboard *)pasteboard; 185 186 - (void)_pasteWithPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText; 187 - (void)_pasteAsPlainTextWithPasteboard:(NSPasteboard *)pasteboard; 186 188 - (BOOL)_shouldInsertFragment:(DOMDocumentFragment *)fragment replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action; 189 - (BOOL)_shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action; 187 190 - (BOOL)_shouldReplaceSelectionWithText:(NSString *)text givenAction:(WebViewInsertAction)action; 188 191 - (float)_calculatePrintHeight; … … 432 435 } 433 436 437 - (NSString *)_plainTextFromPasteboard:(NSPasteboard *)pasteboard 438 { 439 NSArray *types = [pasteboard types]; 440 441 if ([types containsObject:NSStringPboardType]) 442 return [pasteboard stringForType:NSStringPboardType]; 443 444 NSAttributedString *attributedString = nil; 445 NSString *string; 446 447 if ([types containsObject:NSRTFDPboardType]) 448 attributedString = [[NSAttributedString alloc] initWithRTFD:[pasteboard dataForType:NSRTFDPboardType] documentAttributes:NULL]; 449 if (attributedString == nil && [types containsObject:NSRTFPboardType]) 450 attributedString = [[NSAttributedString alloc] initWithRTF:[pasteboard dataForType:NSRTFPboardType] documentAttributes:NULL]; 451 if (attributedString != nil) { 452 string = [[attributedString string] copy]; 453 [attributedString release]; 454 return [string autorelease]; 455 } 456 457 if ([types containsObject:NSFilenamesPboardType]) { 458 string = [[pasteboard propertyListForType:NSFilenamesPboardType] componentsJoinedByString:@"\n"]; 459 if (string != nil) 460 return string; 461 } 462 463 NSURL *URL; 464 465 if ((URL = [NSURL URLFromPasteboard:pasteboard])) { 466 string = [URL _web_userVisibleString]; 467 if ([string length] > 0) 468 return string; 469 } 470 471 return nil; 472 } 473 434 474 - (WebResource *)resourceForData:(NSData *)data preferredFilename:(NSString *)name 435 475 { … … 465 505 } 466 506 507 - (void)_pasteAsPlainTextWithPasteboard:(NSPasteboard *)pasteboard 508 { 509 NSString *text = [self _plainTextFromPasteboard:pasteboard]; 510 if ([self _shouldReplaceSelectionWithText:text givenAction:WebViewInsertActionPasted]) 511 [[self _bridge] replaceSelectionWithText:text selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard]]; 512 } 513 467 514 - (BOOL)_shouldInsertFragment:(DOMDocumentFragment *)fragment replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action 468 515 { … … 476 523 } 477 524 525 - (BOOL)_shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action 526 { 527 WebView *webView = [self _webView]; 528 return [[webView _editingDelegateForwarder] webView:webView shouldInsertText:text replacingDOMRange:range givenAction:action]; 529 } 530 478 531 - (BOOL)_shouldReplaceSelectionWithText:(NSString *)text givenAction:(WebViewInsertAction)action 479 532 { 480 WebView *webView = [self _webView]; 481 DOMRange *selectedRange = [self _selectedRange]; 482 return [[webView _editingDelegateForwarder] webView:webView shouldInsertText:text replacingDOMRange:selectedRange givenAction:action]; 533 return [self _shouldInsertText:text replacingDOMRange:[self _selectedRange] givenAction:action]; 483 534 } 484 535 … … 1835 1886 - (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pasteboard 1836 1887 { 1837 [self _pasteWithPasteboard:pasteboard allowPlainText:YES]; 1888 if ([[self _bridge] isSelectionRichlyEditable]) 1889 [self _pasteWithPasteboard:pasteboard allowPlainText:YES]; 1890 else 1891 [self _pasteAsPlainTextWithPasteboard:pasteboard]; 1838 1892 return YES; 1839 1893 } … … 1980 2034 || action == @selector(takeFindStringFromSelection:)) { 1981 2035 return [self _hasSelection]; 1982 } else if (action == @selector(paste:) || action == @selector(pasteAsPlainText:) || action == @selector(pasteAsRichText:)) {2036 } else if (action == @selector(paste:) || action == @selector(pasteAsPlainText:)) { 1983 2037 return [bridge mayDHTMLPaste] || [self _canPaste]; 2038 } else if (action == @selector(pasteAsRichText:)) { 2039 return [bridge mayDHTMLPaste] || ([self _canPaste] && [[self _bridge] isSelectionRichlyEditable]); 1984 2040 } else if (action == @selector(performFindPanelAction:)) { 1985 2041 // FIXME: Not yet implemented. … … 2889 2945 if ([self _canProcessDragWithDraggingInfo:draggingInfo]) { 2890 2946 NSPasteboard *pasteboard = [draggingInfo draggingPasteboard]; 2891 BOOL chosePlainText; 2892 DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard allowPlainText:YES chosePlainText:&chosePlainText]; 2893 if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:[bridge dragCaretDOMRange] givenAction:WebViewInsertActionDropped]) { 2894 [[webView _UIDelegateForwarder] webView:webView willPerformDragDestinationAction:WebDragDestinationActionEdit forDraggingInfo:draggingInfo]; 2895 if ([self _isMoveDrag]) { 2896 BOOL smartMove = [[self _bridge] selectionGranularity] == WebBridgeSelectByWord && [self _canSmartReplaceWithPasteboard:pasteboard]; 2897 [bridge moveSelectionToDragCaret:fragment smartMove:smartMove]; 2898 } else { 2947 if ([self _isMoveDrag] || [bridge isDragCaretRichlyEditable]) { 2948 BOOL chosePlainText; 2949 DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard allowPlainText:YES chosePlainText:&chosePlainText]; 2950 if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:[bridge dragCaretDOMRange] givenAction:WebViewInsertActionDropped]) { 2951 [[webView _UIDelegateForwarder] webView:webView willPerformDragDestinationAction:WebDragDestinationActionEdit forDraggingInfo:draggingInfo]; 2952 if ([self _isMoveDrag]) { 2953 BOOL smartMove = [bridge selectionGranularity] == WebBridgeSelectByWord && [self _canSmartReplaceWithPasteboard:pasteboard]; 2954 [bridge moveSelectionToDragCaret:fragment smartMove:smartMove]; 2955 } else { 2956 [bridge setSelectionToDragCaret]; 2957 [bridge replaceSelectionWithFragment:fragment selectReplacement:YES smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:chosePlainText]; 2958 } 2959 didInsert = YES; 2960 } 2961 } else { 2962 NSString *text = [self _plainTextFromPasteboard:pasteboard]; 2963 if (text && [self _shouldInsertText:text replacingDOMRange:[bridge dragCaretDOMRange] givenAction:WebViewInsertActionDropped]) { 2964 [[webView _UIDelegateForwarder] webView:webView willPerformDragDestinationAction:WebDragDestinationActionEdit forDraggingInfo:draggingInfo]; 2899 2965 [bridge setSelectionToDragCaret]; 2900 [bridge replaceSelectionWithFragment:fragment selectReplacement:YES smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:chosePlainText]; 2966 [bridge replaceSelectionWithText:text selectReplacement:YES smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard]]; 2967 didInsert = YES; 2901 2968 } 2902 didInsert = YES;2903 2969 } 2904 2970 } … … 3711 3777 return; 3712 3778 } 3713 [self _pasteWithPasteboard:[NSPasteboard generalPasteboard] allowPlainText:YES]; 3779 if ([[self _bridge] isSelectionRichlyEditable]) 3780 [self _pasteWithPasteboard:[NSPasteboard generalPasteboard] allowPlainText:YES]; 3781 else 3782 [self _pasteAsPlainTextWithPasteboard:[NSPasteboard generalPasteboard]]; 3714 3783 } 3715 3784 … … 3952 4021 if (![self _canEdit]) 3953 4022 return; 3954 3955 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; 3956 NSString *text = [pasteboard stringForType:NSStringPboardType]; 3957 WebFrameBridge *bridge = [self _bridge]; 3958 if ([self _shouldReplaceSelectionWithText:text givenAction:WebViewInsertActionPasted]) { 3959 [bridge replaceSelectionWithText:text selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard]]; 3960 } 4023 [self _pasteAsPlainTextWithPasteboard:[NSPasteboard generalPasteboard]]; 3961 4024 } 3962 4025
Note: See TracChangeset
for help on using the changeset viewer.