LayoutTests:
authorharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jul 2006 21:08:56 +0000 (21:08 +0000)
committerharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jul 2006 21:08:56 +0000 (21:08 +0000)
        Reviewed by Justin and Levi.

        <rdar://problem/4620743> REGRESSION: Option-Delete doesn't delete words during typing

        * editing/deleting/delete-by-word-001-expected.checksum: Added.
        * editing/deleting/delete-by-word-001-expected.png: Added.
        * editing/deleting/delete-by-word-001-expected.txt: Added.
        * editing/deleting/delete-by-word-001.html: Added.
        * editing/deleting/delete-by-word-002-expected.checksum: Added.
        * editing/deleting/delete-by-word-002-expected.png: Added.
        * editing/deleting/delete-by-word-002-expected.txt: Added.
        * editing/deleting/delete-by-word-002.html: Added.

WebCore:

        Reviewed by Justin and Levi.

        <rdar://problem/4620743> REGRESSION: Option-Delete doesn't delete words during typing

        * Tests:
        editing/deleting/delete-by-word-001.html
        editing/deleting/delete-by-word-002.html

        * editing/TypingCommand.cpp:
        (WebCore::TypingCommand::deleteKeyPressed):
        (WebCore::TypingCommand::forwardDeleteKeyPressed):
        (WebCore::TypingCommand::doApply):
        * editing/TypingCommand.h:
        Delete and forward delete to use specified granularity.
        Undo of delete and forward delete to select what had been deleted (non-char granularity only).

        * page/Frame.cpp:
        (WebCore::Frame::setSelection):
        Close typing and end style even if selection is not changing.
        * page/Frame.h:
        Remove unused setSelection parameter keepTypingStyle.

WebKit:

        Reviewed by Justin and Levi.

        <rdar://problem/4620743> REGRESSION: Option-Delete doesn't delete words during typing

        * Tests:
        editing/deleting/delete-by-word-001.html
        editing/deleting/delete-by-word-002.html

        * WebView/WebHTMLView.m:
        (-[WebHTMLView _deleteRange:killRing:prepend:smartDeleteOK:deletionAction:granularity:]):

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/deleting/delete-by-word-001-expected.checksum [new file with mode: 0644]
LayoutTests/editing/deleting/delete-by-word-001-expected.png [new file with mode: 0644]
LayoutTests/editing/deleting/delete-by-word-001-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-by-word-001.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-by-word-002-expected.checksum [new file with mode: 0644]
LayoutTests/editing/deleting/delete-by-word-002-expected.png [new file with mode: 0644]
LayoutTests/editing/deleting/delete-by-word-002-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-by-word-002.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/TypingCommand.cpp
WebCore/editing/TypingCommand.h
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebKit/ChangeLog
WebKit/WebView/WebHTMLView.m

index 675e041..ec157be 100644 (file)
@@ -1,3 +1,18 @@
+2006-07-13  David Harrison  <harrison@apple.com>
+
+        Reviewed by Justin and Levi.
+
+        <rdar://problem/4620743> REGRESSION: Option-Delete doesn't delete words during typing
+
+        * editing/deleting/delete-by-word-001-expected.checksum: Added.
+        * editing/deleting/delete-by-word-001-expected.png: Added.
+        * editing/deleting/delete-by-word-001-expected.txt: Added.
+        * editing/deleting/delete-by-word-001.html: Added.
+        * editing/deleting/delete-by-word-002-expected.checksum: Added.
+        * editing/deleting/delete-by-word-002-expected.png: Added.
+        * editing/deleting/delete-by-word-002-expected.txt: Added.
+        * editing/deleting/delete-by-word-002.html: Added.
+
 2006-07-13  Levi Weintraub  <lweintraub@apple.com>
 
         Reviewed by justin
diff --git a/LayoutTests/editing/deleting/delete-by-word-001-expected.checksum b/LayoutTests/editing/deleting/delete-by-word-001-expected.checksum
new file mode 100644 (file)
index 0000000..b9ebe1a
--- /dev/null
@@ -0,0 +1 @@
+d225c8c8852206f0c64f31645135836b
\ No newline at end of file
diff --git a/LayoutTests/editing/deleting/delete-by-word-001-expected.png b/LayoutTests/editing/deleting/delete-by-word-001-expected.png
new file mode 100644 (file)
index 0000000..2e73fac
Binary files /dev/null and b/LayoutTests/editing/deleting/delete-by-word-001-expected.png differ
diff --git a/LayoutTests/editing/deleting/delete-by-word-001-expected.txt b/LayoutTests/editing/deleting/delete-by-word-001-expected.txt
new file mode 100644 (file)
index 0000000..2ac5403
--- /dev/null
@@ -0,0 +1,56 @@
+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: shouldChangeSelectedDOMRange:range from 8 of #text > DIV > DIV > BODY > HTML > #document to 8 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 10 of #text > DIV > DIV > BODY > HTML > #document to 10 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 10 of #text > DIV > DIV > BODY > HTML > #document to 10 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 11 of #text > DIV > DIV > BODY > HTML > #document to 11 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 11 of #text > DIV > DIV > BODY > HTML > #document to 11 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 12 of #text > DIV > DIV > BODY > HTML > #document to 12 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 12 of #text > DIV > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 12 of #text > DIV > DIV > BODY > HTML > #document to 12 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 10 of #text > DIV > DIV > BODY > HTML > #document to 10 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 10 of #text > DIV > DIV > BODY > HTML > #document to 10 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 11 of #text > DIV > DIV > BODY > HTML > #document to 11 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 11 of #text > DIV > DIV > BODY > HTML > #document to 11 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 12 of #text > DIV > DIV > BODY > HTML > #document to 12 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 460x28
+            text run at (0,28) width 460: "Option-delete when a typing command is open."
+        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 440x28
+            text run at (0,28) width 440: "Net result is a third \"cha\". It should like this: "
+          RenderBR {BR} at (440,50) size 0x0
+          RenderText {#text} at (0,56) size 418x28
+            text run at (0,56) width 418: "one two cha cha cha three four cha cha cha"
+      RenderBlock {DIV} at (0,208) size 784x32
+        RenderBlock {DIV} at (0,0) size 784x32 [border: (2px solid #FF0000)]
+          RenderText {#text} at (2,2) size 418x28
+            text run at (2,2) width 418: "one two cha cha cha three four cha cha cha"
+caret: position 12 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/deleting/delete-by-word-001.html b/LayoutTests/editing/deleting/delete-by-word-001.html
new file mode 100644 (file)
index 0000000..1fff567
--- /dev/null
@@ -0,0 +1,69 @@
+<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();
+    typeCharacterCommand(' ');
+    typeCharacterCommand('a');
+    typeCharacterCommand('b');
+    typeCharacterCommand('c');
+       if (window.eventSender)
+               eventSender.keyDown(String.fromCharCode(127), ["altKey"]);
+    typeCharacterCommand('c');
+    typeCharacterCommand('h');
+    typeCharacterCommand('a');
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests: 
+<br>
+Option-delete when a typing command is open.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+Net result is a third "cha". It should like this:
+<BR>
+one two cha cha cha three four cha cha cha
+</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 cha cha three four cha cha cha
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
diff --git a/LayoutTests/editing/deleting/delete-by-word-002-expected.checksum b/LayoutTests/editing/deleting/delete-by-word-002-expected.checksum
new file mode 100644 (file)
index 0000000..be514fd
--- /dev/null
@@ -0,0 +1 @@
+8f7bd2ffd17e0719f475ba398c895b83
\ No newline at end of file
diff --git a/LayoutTests/editing/deleting/delete-by-word-002-expected.png b/LayoutTests/editing/deleting/delete-by-word-002-expected.png
new file mode 100644 (file)
index 0000000..fe06695
Binary files /dev/null and b/LayoutTests/editing/deleting/delete-by-word-002-expected.png differ
diff --git a/LayoutTests/editing/deleting/delete-by-word-002-expected.txt b/LayoutTests/editing/deleting/delete-by-word-002-expected.txt
new file mode 100644 (file)
index 0000000..337c6a6
--- /dev/null
@@ -0,0 +1,39 @@
+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 4 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 4 of #text > DIV > DIV > BODY > HTML > #document to 4 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV > DIV > BODY > HTML > #document to 4 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > DIV > BODY > HTML > #document to 7 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 581x28
+            text run at (0,28) width 581: "Option-delete when no typing command is open, then undo."
+        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 475x28
+            text run at (0,28) width 475: "It should like this, with the word \"two\" selected: "
+          RenderBR {BR} at (475,50) size 0x0
+          RenderText {#text} at (0,56) size 178x28
+            text run at (0,56) width 178: "one two 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 178x28
+            text run at (2,2) width 178: "one two three four"
+selection start: position 4 of child 0 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 7 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/deleting/delete-by-word-002.html b/LayoutTests/editing/deleting/delete-by-word-002.html
new file mode 100644 (file)
index 0000000..fd14abe
--- /dev/null
@@ -0,0 +1,61 @@
+<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(String.fromCharCode(127), ["altKey"]);
+       undoCommand();
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests: 
+<br>
+Option-delete when no typing command is open, then undo.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+It should like this, with the word "two" selected:
+<BR>
+one two 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 3dafb01..5a5601e 100644 (file)
@@ -1,3 +1,27 @@
+2006-07-13  David Harrison  <harrison@apple.com>
+
+        Reviewed by Justin and Levi.
+
+        <rdar://problem/4620743> REGRESSION: Option-Delete doesn't delete words during typing
+
+        * Tests:
+        editing/deleting/delete-by-word-001.html
+        editing/deleting/delete-by-word-002.html
+
+        * editing/TypingCommand.cpp:
+        (WebCore::TypingCommand::deleteKeyPressed):
+        (WebCore::TypingCommand::forwardDeleteKeyPressed):
+        (WebCore::TypingCommand::doApply):
+        * editing/TypingCommand.h:
+        Delete and forward delete to use specified granularity.
+        Undo of delete and forward delete to select what had been deleted (non-char granularity only).
+        
+        * page/Frame.cpp:
+        (WebCore::Frame::setSelection):
+        Close typing and end style even if selection is not changing.
+        * page/Frame.h:
+        Remove unused setSelection parameter keepTypingStyle.
+
 2006-07-12  Levi Weintraub  <lweintraub@apple.com>
 
         Reviewed by justin
index 0d2c05e..aceec24 100644 (file)
@@ -63,7 +63,7 @@ void TypingCommand::deleteKeyPressed(Document *document, bool smartDelete, TextG
     
     EditCommandPtr lastEditCommand = frame->lastEditCommand();
     if (isOpenForMoreTypingCommand(lastEditCommand)) {
-        static_cast<TypingCommand *>(lastEditCommand.get())->deleteKeyPressed();
+        static_cast<TypingCommand *>(lastEditCommand.get())->deleteKeyPressed(granularity);
         return;
     }
     
@@ -82,7 +82,7 @@ void TypingCommand::forwardDeleteKeyPressed(Document *document, bool smartDelete
     
     EditCommandPtr lastEditCommand = frame->lastEditCommand();
     if (isOpenForMoreTypingCommand(lastEditCommand)) {
-        static_cast<TypingCommand *>(lastEditCommand.get())->forwardDeleteKeyPressed();
+        static_cast<TypingCommand *>(lastEditCommand.get())->forwardDeleteKeyPressed(granularity);
         return;
     }
 
@@ -193,10 +193,10 @@ void TypingCommand::doApply()
 
     switch (m_commandType) {
         case DeleteKey:
-            deleteKeyPressed();
+            deleteKeyPressed(m_granularity);
             return;
         case ForwardDeleteKey:
-            forwardDeleteKeyPressed();
+            forwardDeleteKeyPressed(m_granularity);
             return;
         case InsertLineBreak:
             insertLineBreak();
@@ -320,7 +320,7 @@ void TypingCommand::insertParagraphSeparatorInQuotedContent()
     typingAddedToOpenCommand();
 }
 
-void TypingCommand::deleteKeyPressed()
+void TypingCommand::deleteKeyPressed(TextGranularity granularity)
 {
     Selection selectionToDelete;
     
@@ -333,7 +333,8 @@ void TypingCommand::deleteKeyPressed()
             // Do nothing in the case that the caret is at the start of a
             // root editable element or at the start of a document.
             SelectionController sc = SelectionController(endingSelection().start(), endingSelection().end(), SEL_DEFAULT_AFFINITY);
-            sc.modify(SelectionController::EXTEND, SelectionController::BACKWARD, m_granularity);
+            sc.modify(SelectionController::EXTEND, SelectionController::BACKWARD, granularity);
+            
             Position upstreamStart = endingSelection().start().upstream();
             VisiblePosition visibleStart = endingSelection().visibleStart();
             if (visibleStart == startOfParagraph(visibleStart))
@@ -344,7 +345,12 @@ void TypingCommand::deleteKeyPressed()
                 typingAddedToOpenCommand();
                 return;
             }
+
             selectionToDelete = sc.selection();
+            
+            // setStartingSelection so that undo selects what was deleted
+            if (selectionToDelete.isCaretOrRange() && granularity != CharacterGranularity)
+                setStartingSelection(selectionToDelete);
             break;
         }
         case Selection::NONE:
@@ -359,7 +365,7 @@ void TypingCommand::deleteKeyPressed()
     }
 }
 
-void TypingCommand::forwardDeleteKeyPressed()
+void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity)
 {
     Selection selectionToDelete;
     
@@ -372,7 +378,7 @@ void TypingCommand::forwardDeleteKeyPressed()
             // Do nothing in the case that the caret is at the start of a
             // root editable element or at the start of a document.
             SelectionController sc = SelectionController(endingSelection().start(), endingSelection().end(), SEL_DEFAULT_AFFINITY);
-            sc.modify(SelectionController::EXTEND, SelectionController::FORWARD, m_granularity);
+            sc.modify(SelectionController::EXTEND, SelectionController::FORWARD, granularity);
             Position downstreamEnd = endingSelection().end().downstream();
             VisiblePosition visibleEnd = endingSelection().visibleEnd();
             if (visibleEnd == endOfParagraph(visibleEnd))
@@ -384,6 +390,10 @@ void TypingCommand::forwardDeleteKeyPressed()
                 return;
             }
             selectionToDelete = sc.selection();
+
+            // setStartingSelection so that undo selects what was deleted
+            if (selectionToDelete.isCaretOrRange() && granularity != CharacterGranularity)
+                setStartingSelection(selectionToDelete);
             break;
         }
         case Selection::NONE:
index fe77960..c0c6020 100644 (file)
@@ -64,8 +64,8 @@ public:
     void insertLineBreak();
     void insertParagraphSeparatorInQuotedContent();
     void insertParagraphSeparator();
-    void deleteKeyPressed();
-    void forwardDeleteKeyPressed();
+    void deleteKeyPressed(TextGranularity);
+    void forwardDeleteKeyPressed(TextGranularity);
 
     bool smartDelete() { return m_smartDelete; }
     void setSmartDelete(bool smartDelete) { m_smartDelete = smartDelete; }
index c68f7be..b42bb51 100644 (file)
@@ -1159,11 +1159,16 @@ void Frame::setMark(const Selection& s)
     d->m_mark = s;
 }
 
-void Frame::setSelection(const SelectionController& s, bool closeTyping, bool keepTypingStyle)
+void Frame::setSelection(const SelectionController& s, bool closeTyping)
 {
+    if (closeTyping)
+        TypingCommand::closeTyping(lastEditCommand());
+
+    clearTypingStyle();
+        
     if (d->m_selection == s)
         return;
-
+    
     ASSERT(!s.base().node() || s.base().node()->document() == document());
     ASSERT(!s.extent().node() || s.extent().node()->document() == document());
     ASSERT(!s.start().node() || s.start().node()->document() == document());
@@ -1182,12 +1187,6 @@ void Frame::setSelection(const SelectionController& s, bool closeTyping, bool ke
     // Always clear the x position used for vertical arrow navigation.
     // It will be restored by the vertical arrow navigation code if necessary.
     d->m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation;
-
-    if (closeTyping)
-        TypingCommand::closeTyping(lastEditCommand());
-
-    if (!keepTypingStyle)
-        clearTypingStyle();
     
     notifyRendererOfSelectionChange(false);
 
index 10531a6..4b4c3b1 100644 (file)
@@ -324,7 +324,7 @@ public:
   void setSelectionGranularity(TextGranularity granularity) const;
 
   // FIXME: Replace these with functions on the selection controller.
-  void setSelection(const SelectionController&, bool closeTyping = true, bool keepTypingStyle = false);
+  void setSelection(const SelectionController&, bool closeTyping = true);
   bool shouldChangeSelection(const SelectionController&) const;
   virtual bool shouldDeleteSelection(const SelectionController&) const;
   
index cdb81fc..c379d51 100644 (file)
@@ -1,3 +1,16 @@
+2006-07-13  David Harrison  <harrison@apple.com>
+
+        Reviewed by Justin and Levi.
+
+        <rdar://problem/4620743> REGRESSION: Option-Delete doesn't delete words during typing
+
+        * Tests:
+        editing/deleting/delete-by-word-001.html
+        editing/deleting/delete-by-word-002.html
+
+        * WebView/WebHTMLView.m:
+        (-[WebHTMLView _deleteRange:killRing:prepend:smartDeleteOK:deletionAction:granularity:]):
+
 2006-07-13  Timothy Hatcher  <timothy@apple.com>
 
         Rolling out this earlier change (r15378) now that it is fixed on AGL's end.
index 4959864..9fd2b3c 100644 (file)
@@ -600,11 +600,11 @@ void *_NSSoftLinkingGetFrameworkFuncPtr(NSString *inUmbrellaFrameworkName,
             [bridge deleteSelectionWithSmartDelete:smartDelete];
             break;
         case deleteKeyAction:
-            [bridge setSelectedDOMRange:range affinity:NSSelectionAffinityDownstream closeTyping:NO];
+            [bridge setSelectedDOMRange:range affinity:NSSelectionAffinityDownstream closeTyping:(granularity != WebBridgeSelectByCharacter)];
             [bridge deleteKeyPressedWithSmartDelete:smartDelete granularity:granularity];
             break;
         case forwardDeleteKeyAction:
-            [bridge setSelectedDOMRange:range affinity:NSSelectionAffinityDownstream closeTyping:NO];
+            [bridge setSelectedDOMRange:range affinity:NSSelectionAffinityDownstream closeTyping:(granularity != WebBridgeSelectByCharacter)];
             [bridge forwardDeleteKeyPressedWithSmartDelete:smartDelete granularity:granularity];
             break;
     }