LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Oct 2006 23:28:49 +0000 (23:28 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Oct 2006 23:28:49 +0000 (23:28 +0000)
        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: https://svn.webkit.org/repository/webkit/trunk@16752 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/paste-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/paste-1-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/paste-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/paste-1.html [new file with mode: 0644]
LayoutTests/editing/execCommand/paste-2-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/paste-2-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/paste-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/paste-2.html [new file with mode: 0644]
WebKit/ChangeLog
WebKit/WebCoreSupport/WebFrameBridge.m
WebKit/WebView/WebHTMLView.m
WebKit/WebView/WebHTMLViewInternal.h
WebKit/WebView/WebView.m
WebKit/WebView/WebViewInternal.h

index ff4d90d4d6454788b2641f9297076b4f16504535..820775cee473f3a714c76ade870d0f7b9e14c174 100644 (file)
@@ -1,3 +1,16 @@
+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.
diff --git a/LayoutTests/editing/execCommand/paste-1-expected.checksum b/LayoutTests/editing/execCommand/paste-1-expected.checksum
new file mode 100644 (file)
index 0000000..5123898
--- /dev/null
@@ -0,0 +1 @@
+aad725effe134ca193ab4da9d4361901
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/paste-1-expected.png b/LayoutTests/editing/execCommand/paste-1-expected.png
new file mode 100644 (file)
index 0000000..2f49d76
Binary files /dev/null and b/LayoutTests/editing/execCommand/paste-1-expected.png differ
diff --git a/LayoutTests/editing/execCommand/paste-1-expected.txt b/LayoutTests/editing/execCommand/paste-1-expected.txt
new file mode 100644 (file)
index 0000000..672fe2d
--- /dev/null
@@ -0,0 +1,34 @@
+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
diff --git a/LayoutTests/editing/execCommand/paste-1.html b/LayoutTests/editing/execCommand/paste-1.html
new file mode 100644 (file)
index 0000000..2337585
--- /dev/null
@@ -0,0 +1,21 @@
+<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
diff --git a/LayoutTests/editing/execCommand/paste-2-expected.checksum b/LayoutTests/editing/execCommand/paste-2-expected.checksum
new file mode 100644 (file)
index 0000000..c9c5ecb
--- /dev/null
@@ -0,0 +1 @@
+24df6d6610b82cbe54eb34941f41d571
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/paste-2-expected.png b/LayoutTests/editing/execCommand/paste-2-expected.png
new file mode 100644 (file)
index 0000000..b4d99f1
Binary files /dev/null and b/LayoutTests/editing/execCommand/paste-2-expected.png differ
diff --git a/LayoutTests/editing/execCommand/paste-2-expected.txt b/LayoutTests/editing/execCommand/paste-2-expected.txt
new file mode 100644 (file)
index 0000000..4831132
--- /dev/null
@@ -0,0 +1,34 @@
+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
diff --git a/LayoutTests/editing/execCommand/paste-2.html b/LayoutTests/editing/execCommand/paste-2.html
new file mode 100644 (file)
index 0000000..34bd419
--- /dev/null
@@ -0,0 +1,22 @@
+<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
index f947799ca9a431ca17c143abb560c559e700964b..0d8fdac927e7e7ebfd1b6a01f937118b18c90570 100644 (file)
@@ -1,3 +1,25 @@
+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
index 1e283d0598f7f79c4fdc79e67a20c6546771fe40..f2b5ec69b71a9957fe653e5cf4aaa977a20bb829 100644 (file)
@@ -1409,35 +1409,43 @@ static id <WebFormDelegate> formDelegate(WebFrameBridge *self)
 
 - (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
index fab611f8fe2edab626f12034a32a8f728d4ea768..4d48cc593c758c51e553c4d1b99cffce06626d0f 100644 (file)
@@ -3704,17 +3704,6 @@ done:
     [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 @@ done:
     [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 @@ done:
     [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 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
     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)
index 769152cb11118345444056354716b03f9c9701ab..ef659f84d5b497491d42815a070362e4962a583b 100644 (file)
 - (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
 
index 4ecb894b0d2b10d70a8d3f793820232d9853b4fd..371990c8656a18cf3a65ab4e87dee994682ed790 100644 (file)
@@ -3083,12 +3083,6 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
     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;
index 15e42a605e94b3b691b603d4ff1fae4fce7de944..2e8bf3eb776643667cfaa32f946ae065b43bc0a1 100644 (file)
@@ -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)