Commit 6b59cee5 authored by justing's avatar justing

LayoutTests:

        Reviewed by harrison

        * editing/execCommand/paste-1-expected.checksum: Added.
        * editing/execCommand/paste-1-expected.png: Added.
        * editing/execCommand/paste-1-expected.txt: Added.
        * editing/execCommand/paste-1.html: Added.
        * editing/execCommand/paste-2-expected.checksum: Added.
        * editing/execCommand/paste-2-expected.png: Added.
        * editing/execCommand/paste-2-expected.txt: Added.
        * editing/execCommand/paste-2.html: Added.

WebKit:

        Reviewed by harrison
        
        execCommand("Cut"/"Copy"/"Paste") broken in editable subframes.

        * WebCoreSupport/WebFrameBridge.m:
        (-[WebFrameBridge issueCutCommand]): Issue the command on the WebHTMLView, not the WebView.
        (-[WebFrameBridge issueCopyCommand]): Ditto.
        (-[WebFrameBridge issuePasteCommand]): Ditto.
        (-[WebFrameBridge issuePasteAndMatchStyleCommand]): Ditto.
        (-[WebFrameBridge issueTransposeCommand]): Fixed formatting.
        (-[WebFrameBridge canPaste]): Ask the WebHTMLView, not the WebView.
        * WebView/WebHTMLView.m:
        (-[WebHTMLView copy:]): Moved to WebInternal
        (-[WebHTMLView cut:]): Ditto.
        (-[WebHTMLView paste:]): Ditto.
        (-[WebHTMLView pasteAsPlainText:]): Ditto.
        * WebView/WebHTMLViewInternal.h:
        * WebView/WebView.m: Removed the now unused _canPaste.
        * WebView/WebViewInternal.h: Ditto.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16752 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2630d92a
2006-10-03 Justin Garcia <justin.garcia@apple.com>
Reviewed by harrison
* editing/execCommand/paste-1-expected.checksum: Added.
* editing/execCommand/paste-1-expected.png: Added.
* editing/execCommand/paste-1-expected.txt: Added.
* editing/execCommand/paste-1.html: Added.
* editing/execCommand/paste-2-expected.checksum: Added.
* editing/execCommand/paste-2-expected.png: Added.
* editing/execCommand/paste-2-expected.txt: Added.
* editing/execCommand/paste-2.html: Added.
2006-10-03 Beth Dakin <bdakin@apple.com>
Reviewed by Geoff.
aad725effe134ca193ab4da9d4361901
\ No newline at end of file
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of BODY > HTML > #document to 0 of BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 8 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document givenAction:WebViewInsertActionPasted
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 4 of #text > BODY > HTML > #document to 4 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {P} at (0,0) size 784x18
RenderText {#text} at (0,0) size 509x18
text run at (0,0) width 283: "This tests cut/paste inside an editable iframe. "
text run at (283,0) width 226: "You should see 'foo bar baz' below."
RenderBlock (anonymous) at (0,34) size 784x150
RenderPartObject {IFRAME} at (0,0) size 300x150
layer at (0,0) size 300x150
RenderView at (0,0) size 300x150
layer at (0,0) size 300x150
RenderBlock {HTML} at (0,0) size 300x150
RenderBody {BODY} at (8,8) size 284x134 [bgcolor=#FFFFE0]
RenderText {#text} at (0,0) size 45x18
text run at (0,0) width 45: "foo bar"
RenderText {#text} at (45,0) size 26x18
text run at (45,0) width 26: " baz"
RenderText {#text} at (0,0) size 0x0
<p>This tests cut/paste inside an editable iframe. You should see 'foo bar baz' below.</p>
<iframe src="../resources/contenteditable-iframe-src.html"></iframe>
<script>
function foo() {
var frame = frames[0];
var sel = frame.getSelection();
var doc = frame.document;
sel.setPosition(doc.body, 0);
doc.execCommand("InsertText", false, "foo bar baz");
sel.modify("extend", "backward", "word");
doc.execCommand("Cut");
doc.execCommand("Paste");
if (window.layoutTestController)
window.layoutTestController.notifyDone();
}
if (window.layoutTestController)
window.layoutTestController.waitUntilDone();
window.setTimeout(foo, 100);
</script>
\ No newline at end of file
24df6d6610b82cbe54eb34941f41d571
\ No newline at end of file
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of BODY > HTML > #document to 0 of BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 8 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document givenAction:WebViewInsertActionPasted
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 4 of #text > BODY > HTML > #document to 4 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {P} at (0,0) size 784x18
RenderText {#text} at (0,0) size 562x18
text run at (0,0) width 336: "This tests copy/delete/paste inside an editable iframe. "
text run at (336,0) width 226: "You should see 'foo bar baz' below."
RenderBlock (anonymous) at (0,34) size 784x150
RenderPartObject {IFRAME} at (0,0) size 300x150
layer at (0,0) size 300x150
RenderView at (0,0) size 300x150
layer at (0,0) size 300x150
RenderBlock {HTML} at (0,0) size 300x150
RenderBody {BODY} at (8,8) size 284x134 [bgcolor=#FFFFE0]
RenderText {#text} at (0,0) size 45x18
text run at (0,0) width 45: "foo bar"
RenderText {#text} at (45,0) size 26x18
text run at (45,0) width 26: " baz"
RenderText {#text} at (0,0) size 0x0
<p>This tests copy/delete/paste inside an editable iframe. You should see 'foo bar baz' below.</p>
<iframe src="../resources/contenteditable-iframe-src.html"></iframe>
<script>
function runTest() {
var frame = frames[0];
var sel = frame.getSelection();
var doc = frame.document;
sel.setPosition(doc.body, 0);
doc.execCommand("InsertText", false, "foo bar baz");
sel.modify("extend", "backward", "word");
doc.execCommand("Copy");
doc.execCommand("Delete");
doc.execCommand("Paste");
if (window.layoutTestController)
window.layoutTestController.notifyDone();
}
if (window.layoutTestController)
window.layoutTestController.waitUntilDone();
window.setTimeout(runTest, 100);
</script>
\ No newline at end of file
2006-10-03 Justin Garcia <justin.garcia@apple.com>
Reviewed by harrison
execCommand("Cut"/"Copy"/"Paste") broken in editable subframes.
* WebCoreSupport/WebFrameBridge.m:
(-[WebFrameBridge issueCutCommand]): Issue the command on the WebHTMLView, not the WebView.
(-[WebFrameBridge issueCopyCommand]): Ditto.
(-[WebFrameBridge issuePasteCommand]): Ditto.
(-[WebFrameBridge issuePasteAndMatchStyleCommand]): Ditto.
(-[WebFrameBridge issueTransposeCommand]): Fixed formatting.
(-[WebFrameBridge canPaste]): Ask the WebHTMLView, not the WebView.
* WebView/WebHTMLView.m:
(-[WebHTMLView copy:]): Moved to WebInternal
(-[WebHTMLView cut:]): Ditto.
(-[WebHTMLView paste:]): Ditto.
(-[WebHTMLView pasteAsPlainText:]): Ditto.
* WebView/WebHTMLViewInternal.h:
* WebView/WebView.m: Removed the now unused _canPaste.
* WebView/WebViewInternal.h: Ditto.
2006-10-03 Justin Garcia <justin.garcia@apple.com>
Reviewed by geoff
......
......@@ -1409,35 +1409,43 @@ - (NSUndoManager *)undoManager
- (void)issueCutCommand
{
[[self webView] cut:nil];
NSView* documentView = [[_frame frameView] documentView];
if ([documentView isKindOfClass:[WebHTMLView class]])
[(WebHTMLView*)documentView cut:nil];
}
- (void)issueCopyCommand
{
[[self webView] copy:nil];
NSView* documentView = [[_frame frameView] documentView];
if ([documentView isKindOfClass:[WebHTMLView class]])
[(WebHTMLView*)documentView copy:nil];
}
- (void)issuePasteCommand
{
[[self webView] paste:nil];
NSView* documentView = [[_frame frameView] documentView];
if ([documentView isKindOfClass:[WebHTMLView class]])
[(WebHTMLView*)documentView paste:nil];
}
- (void)issuePasteAndMatchStyleCommand
{
[[self webView] pasteAsPlainText:nil];
NSView <WebDocumentView> *documentView = [[_frame frameView] documentView];
if ([documentView isKindOfClass:[WebHTMLView class]])
[(WebHTMLView*)documentView pasteAsPlainText:nil];
}
- (void)issueTransposeCommand
{
NSView <WebDocumentView> *view = [[_frame frameView] documentView];
if ([view isKindOfClass:[WebHTMLView class]]) {
if ([view isKindOfClass:[WebHTMLView class]])
[(WebHTMLView *)view transpose:nil];
}
}
- (BOOL)canPaste
{
return [[self webView] _canPaste];
NSView* documentView = [[_frame frameView] documentView];
return [documentView isKindOfClass:[WebHTMLView class]] && [(WebHTMLView*)documentView _canPaste];
}
- (void)setIsSelected:(BOOL)isSelected forView:(NSView *)view
......
......@@ -3704,17 +3704,6 @@ - (void)selectWord:(id)sender
[self _expandSelectionToGranularity:WebBridgeSelectByWord];
}
- (void)copy:(id)sender
{
if ([[self _bridge] tryDHTMLCopy])
return; // DHTML did the whole operation
if (![self _canCopy]) {
NSBeep();
return;
}
[self _writeSelectionToPasteboard:[NSPasteboard generalPasteboard]];
}
- (void)delete:(id)sender
{
if (![self _canDelete]) {
......@@ -3724,34 +3713,6 @@ - (void)delete:(id)sender
[self _deleteSelection];
}
- (void)cut:(id)sender
{
WebFrameBridge *bridge = [self _bridge];
if ([bridge tryDHTMLCut])
return; // DHTML did the whole operation
if (![self _canCut]) {
NSBeep();
return;
}
DOMRange *range = [self _selectedRange];
if ([self _shouldDeleteRange:range]) {
[self _writeSelectionToPasteboard:[NSPasteboard generalPasteboard]];
[bridge deleteSelectionWithSmartDelete:[self _canSmartCopyOrDelete]];
}
}
- (void)paste:(id)sender
{
if ([[self _bridge] tryDHTMLPaste])
return; // DHTML did the whole operation
if (![self _canPaste])
return;
if ([[self _bridge] isSelectionRichlyEditable])
[self _pasteWithPasteboard:[NSPasteboard generalPasteboard] allowPlainText:YES];
else
[self _pasteAsPlainTextWithPasteboard:[NSPasteboard generalPasteboard]];
}
- (NSData *)_selectionStartFontAttributesAsRTF
{
NSAttributedString *string = [[NSAttributedString alloc] initWithString:@"x"
......@@ -3979,13 +3940,6 @@ - (void)pasteFont:(id)sender
[self _applyStyleToSelection:[self _styleFromFontAttributes:[self _fontAttributesFromFontPasteboard]] withUndoAction:WebUndoActionPasteFont];
}
- (void)pasteAsPlainText:(id)sender
{
if (![self _canEdit])
return;
[self _pasteAsPlainTextWithPasteboard:[NSPasteboard generalPasteboard]];
}
- (void)pasteAsRichText:(id)sender
{
// Since rich text always beats plain text when both are on the pasteboard, it's not
......@@ -5054,6 +5008,52 @@ - (BOOL)_initiatedDrag
return _private->initiatedDrag;
}
- (void)copy:(id)sender
{
if ([[self _bridge] tryDHTMLCopy])
return; // DHTML did the whole operation
if (![self _canCopy]) {
NSBeep();
return;
}
[self _writeSelectionToPasteboard:[NSPasteboard generalPasteboard]];
}
- (void)cut:(id)sender
{
WebFrameBridge *bridge = [self _bridge];
if ([bridge tryDHTMLCut])
return; // DHTML did the whole operation
if (![self _canCut]) {
NSBeep();
return;
}
DOMRange *range = [self _selectedRange];
if ([self _shouldDeleteRange:range]) {
[self _writeSelectionToPasteboard:[NSPasteboard generalPasteboard]];
[bridge deleteSelectionWithSmartDelete:[self _canSmartCopyOrDelete]];
}
}
- (void)paste:(id)sender
{
if ([[self _bridge] tryDHTMLPaste])
return; // DHTML did the whole operation
if (![self _canPaste])
return;
if ([[self _bridge] isSelectionRichlyEditable])
[self _pasteWithPasteboard:[NSPasteboard generalPasteboard] allowPlainText:YES];
else
[self _pasteAsPlainTextWithPasteboard:[NSPasteboard generalPasteboard]];
}
- (void)pasteAsPlainText:(id)sender
{
if (![self _canEdit])
return;
[self _pasteAsPlainTextWithPasteboard:[NSPasteboard generalPasteboard]];
}
@end
@implementation WebHTMLView (WebNSTextInputSupport)
......
......@@ -110,5 +110,9 @@
- (WebFrame *)_frame;
- (void)_setInitiatedDrag:(BOOL)flag;
- (BOOL)_initiatedDrag;
- (void)copy:(id)sender;
- (void)cut:(id)sender;
- (void)paste:(id)sender;
- (void)pasteAsPlainText:(id)sender;
@end
......@@ -3083,12 +3083,6 @@ - (BOOL)_shouldEndEditingInDOMRange:(DOMRange *)range
return [[self _editingDelegateForwarder] webView:self shouldEndEditingInDOMRange:range];
}
- (BOOL)_canPaste
{
id documentView = [[[self mainFrame] frameView] documentView];
return [documentView respondsToSelector:@selector(_canPaste)] && [documentView _canPaste];
}
- (BOOL)maintainsInactiveSelection
{
return NO;
......
......@@ -39,7 +39,6 @@
- (BOOL)_shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
- (BOOL)_shouldBeginEditingInDOMRange:(DOMRange *)range;
- (BOOL)_shouldEndEditingInDOMRange:(DOMRange *)range;
- (BOOL)_canPaste;
@end
@interface WebView (AllWebViews)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment