LayoutTests:
authorharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Sep 2006 19:19:32 +0000 (19:19 +0000)
committerharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Sep 2006 19:19:32 +0000 (19:19 +0000)
        Reviewed by John and TimH.

        <rdar://problem/4743256> Seed: Ctrl-Y key binding does nothing when kill ring is empty

        * editing/pasteboard/emacs-cntl-y-001-expected.checksum: Added.
        * editing/pasteboard/emacs-cntl-y-001-expected.png: Added.
        * editing/pasteboard/emacs-cntl-y-001-expected.txt: Added.
        * editing/pasteboard/emacs-cntl-y-001.html: Added.

WebKit:

        Reviewed by John and TimH.

        <rdar://problem/4743256> Seed: Ctrl-Y key binding does nothing when kill ring is empty

        Use deleteBackward: when the killring string is empty. Was always using insertText:,
        but that ends up early-returning if the string to insert is empty.

        * WebView/WebHTMLView.m:
        (-[NSArray yank:]):
        (-[NSArray yankAndSelect:]):

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

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/emacs-cntl-y-001-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/emacs-cntl-y-001-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/emacs-cntl-y-001-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/emacs-cntl-y-001.html [new file with mode: 0644]
WebKit/ChangeLog
WebKit/WebView/WebHTMLView.m

index 6849764c623a4c091d255bea7fd2df84ca0c6d95..e1fa504b187697559336ddfd5dd612b87d97cecc 100644 (file)
@@ -1,3 +1,14 @@
+2006-09-26  David Harrison  <harrison@apple.com>
+
+        Reviewed by John and TimH.
+        
+        <rdar://problem/4743256> Seed: Ctrl-Y key binding does nothing when kill ring is empty
+
+        * editing/pasteboard/emacs-cntl-y-001-expected.checksum: Added.
+        * editing/pasteboard/emacs-cntl-y-001-expected.png: Added.
+        * editing/pasteboard/emacs-cntl-y-001-expected.txt: Added.
+        * editing/pasteboard/emacs-cntl-y-001.html: Added.
+
 2006-09-26  Eric Seidel  <eric@eseidel.com>
 
         Reviewed by Tim H.
diff --git a/LayoutTests/editing/pasteboard/emacs-cntl-y-001-expected.checksum b/LayoutTests/editing/pasteboard/emacs-cntl-y-001-expected.checksum
new file mode 100644 (file)
index 0000000..d95c892
--- /dev/null
@@ -0,0 +1 @@
+30a9b797b8e49aae7b0059d5238a4776
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/emacs-cntl-y-001-expected.png b/LayoutTests/editing/pasteboard/emacs-cntl-y-001-expected.png
new file mode 100644 (file)
index 0000000..49b348e
Binary files /dev/null and b/LayoutTests/editing/pasteboard/emacs-cntl-y-001-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/emacs-cntl-y-001-expected.txt b/LayoutTests/editing/pasteboard/emacs-cntl-y-001-expected.txt
new file mode 100644 (file)
index 0000000..300e3cc
--- /dev/null
@@ -0,0 +1,35 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 6 of #text > DIV > DIV > BODY > HTML > #document to 7 of #text > DIV > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > DIV > DIV > BODY > HTML > #document to 7 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 6 of #text > DIV > DIV > BODY > HTML > #document to 6 of #text > DIV > DIV > 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 {DIV} at (0,0) size 784x184 [border: (2px solid #0000FF)]
+        RenderBlock {DIV} at (14,14) size 756x56
+          RenderText {#text} at (0,0) size 67x28
+            text run at (0,0) width 67: "Tests: "
+          RenderBR {BR} at (0,0) size 0x0
+          RenderText {#text} at (0,28) size 544x28
+            text run at (0,28) width 544: "Cntl-y at caret selection when nothing is in the kill ring."
+        RenderBlock {DIV} at (14,86) size 756x84
+          RenderText {#text} at (0,0) size 189x28
+            text run at (0,0) width 189: "Expected Results: "
+          RenderBR {BR} at (189,22) size 0x0
+          RenderText {#text} at (0,28) size 291x28
+            text run at (0,28) width 291: "Deletes a character, yielding: "
+          RenderBR {BR} at (291,50) size 0x0
+          RenderText {#text} at (0,56) size 166x28
+            text run at (0,56) width 166: "one tw three four"
+      RenderBlock {DIV} at (0,208) size 784x32
+        RenderBlock {DIV} at (0,0) size 784x32 [border: (2px solid #FF0000)]
+          RenderText {#text} at (2,2) size 166x28
+            text run at (2,2) width 166: "one tw three four"
+caret: position 6 of child 0 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/emacs-cntl-y-001.html b/LayoutTests/editing/pasteboard/emacs-cntl-y-001.html
new file mode 100644 (file)
index 0000000..19cb25e
--- /dev/null
@@ -0,0 +1,60 @@
+<html> 
+<head>
+
+<style>
+.editing { 
+    border: 2px solid red; 
+    font-size: 24px; 
+}
+.explanation { 
+    border: 2px solid blue; 
+    padding: 12px; 
+    font-size: 24px; 
+    margin-bottom: 24px;
+}
+.scenario { margin-bottom: 16px;}
+.scenario:first-line { font-weight: bold; margin-bottom: 16px;}
+.expected-results:first-line { font-weight: bold }
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+    moveSelectionForwardByWordCommand();
+    moveSelectionForwardByWordCommand();
+    if (window.eventSender)
+        eventSender.keyDown("y", ["ctrlKey"]);
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests: 
+<br>
+Cntl-y at caret selection when nothing is in the kill ring.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+Deletes a character, yielding:
+<BR>
+one tw three four
+</div>
+</div>
+
+<div contenteditable id="root" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div id="test" class="editing">one two three four</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
index 4b2711d6b22b99a68b21de4fb4c620cf0464d75a..767846d172d9c83e67acaa42985f4ede1c196e60 100644 (file)
@@ -1,3 +1,16 @@
+2006-09-26  David Harrison  <harrison@apple.com>
+
+        Reviewed by John and TimH.
+
+        <rdar://problem/4743256> Seed: Ctrl-Y key binding does nothing when kill ring is empty
+
+        Use deleteBackward: when the killring string is empty. Was always using insertText:,
+        but that ends up early-returning if the string to insert is empty.
+        
+        * WebView/WebHTMLView.m:
+        (-[NSArray yank:]):
+        (-[NSArray yankAndSelect:]):
+
 2006-09-25  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Brady.
index 997b2c6c9f81d0373cca1187570e2bff884e8d62..1358d713b6efb7736c74ef58f0e296e1467e8f1b 100644 (file)
@@ -4570,8 +4570,13 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
 {
     if (![self _canEdit])
         return;
-        
-    [self insertText:_NSYankFromKillRing()];
+    
+    NSString* yankee = _NSYankFromKillRing();
+    if ([yankee length])
+        [self insertText:yankee];
+    else
+        [self deleteBackward:nil];
+
     _NSSetKillRingToYankedState();
 }
 
@@ -4580,7 +4585,12 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
     if (![self _canEdit])
         return;
 
-    [self _insertText:_NSYankPreviousFromKillRing() selectInsertedText:YES];
+    NSString* yankee = _NSYankPreviousFromKillRing();
+    if ([yankee length])
+        [self _insertText:yankee selectInsertedText:YES];
+    else
+        [self deleteBackward:nil];
+        
     _NSSetKillRingToYankedState();
 }