Rubber-stamped by Eric.

        - moved editing sources from khtml/editing to editing, and renamed files with single classes

        * WebCore.xcodeproj/project.pbxproj: Added new, removed old.
        * WebCore.vcproj/WebCore/WebCore.vcproj: Ditto.

        * bridge/mac/MacFrame.mm:
        * bridge/mac/WebCoreFrameBridge.mm:
        * dom/DocumentImpl.cpp:
        * dom/dom2_rangeimpl.cpp:
        * dom/dom_position.cpp:
        * khtml/khtml_events.cpp:
        * kwq/KWQAccObject.mm:
        * kwq/KWQAccObjectCache.h:
        * kwq/KWQEditCommand.mm:
        * page/Frame.cpp:
        * page/FramePrivate.h:
        * rendering/RenderBlock.cpp:
        * rendering/RenderContainer.cpp:
        * rendering/RenderText.cpp:
        * rendering/render_br.cpp:
        * rendering/render_inline.cpp:
        * rendering/render_object.cpp:
        * rendering/render_replaced.cpp:
        Fixed up includes.

        * editing: Added.
        * editing/AppendNodeCommand.cpp: Added.
        * editing/AppendNodeCommand.h: Added.
        * editing/ApplyStyleCommand.cpp: Added.
        * editing/ApplyStyleCommand.h: Added.
        * editing/BreakBlockquoteCommand.cpp: Added.
        * editing/BreakBlockquoteCommand.h: Added.
        * editing/CompositeEditCommand.cpp: Added.
        * editing/CompositeEditCommand.h: Added.
        * editing/DeleteFromTextNodeCommand.cpp: Added.
        * editing/DeleteFromTextNodeCommand.h: Added.
        * editing/DeleteSelectionCommand.cpp: Added.
        * editing/DeleteSelectionCommand.h: Added.
        * editing/EditCommand.cpp: Added.
        * editing/EditCommand.h: Added.
        * editing/InsertIntoTextNodeCommand.cpp: Added.
        * editing/InsertIntoTextNodeCommand.h: Added.
        * editing/InsertLineBreakCommand.cpp: Added.
        * editing/InsertLineBreakCommand.h: Added.
        * editing/InsertNodeBeforeCommand.cpp: Added.
        * editing/InsertNodeBeforeCommand.h: Added.
        * editing/InsertParagraphSeparatorCommand.cpp: Added.
        * editing/InsertParagraphSeparatorCommand.h: Added.
        * editing/InsertTextCommand.cpp: Added.
        * editing/InsertTextCommand.h: Added.
        * editing/JoinTextNodesCommand.cpp: Added.
        * editing/JoinTextNodesCommand.h: Added.
        * editing/MergeIdenticalElementsCommand.cpp: Added.
        * editing/MergeIdenticalElementsCommand.h: Added.
        * editing/MoveSelectionCommand.cpp: Added.
        * editing/MoveSelectionCommand.h: Added.
        * editing/RebalanceWhitespaceCommand.cpp: Added.
        * editing/RebalanceWhitespaceCommand.h: Added.
        * editing/RemoveCSSPropertyCommand.cpp: Added.
        * editing/RemoveCSSPropertyCommand.h: Added.
        * editing/RemoveNodeAttributeCommand.cpp: Added.
        * editing/RemoveNodeAttributeCommand.h: Added.
        * editing/RemoveNodeCommand.cpp: Added.
        * editing/RemoveNodeCommand.h: Added.
        * editing/RemoveNodePreservingChildrenCommand.cpp: Added.
        * editing/RemoveNodePreservingChildrenCommand.h: Added.
        * editing/ReplaceSelectionCommand.cpp: Added.
        * editing/ReplaceSelectionCommand.h: Added.
        * editing/Selection.cpp:
        * editing/SelectionController.cpp:
        * editing/SetNodeAttributeCommand.cpp: Added.
        * editing/SetNodeAttributeCommand.h: Added.
        * editing/SplitElementCommand.cpp: Added.
        * editing/SplitElementCommand.h: Added.
        * editing/SplitTextNodeCommand.cpp: Added.
        * editing/SplitTextNodeCommand.h: Added.
        * editing/SplitTextNodeContainingElementCommand.cpp: Added.
        * editing/SplitTextNodeContainingElementCommand.h: Added.
        * editing/TypingCommand.cpp: Added.
        * editing/TypingCommand.h: Added.
        * editing/VisiblePosition.cpp: Added.
        * editing/VisiblePosition.h: Added.
        * editing/VisibleRange.cpp: Added.
        * editing/VisibleRange.h: Added.
        * editing/WrapContentsInDummySpanCommand.cpp: Added.
        * editing/WrapContentsInDummySpanCommand.h: Added.
        * editing/append_node_command.cpp: Removed.
        * editing/append_node_command.h: Removed.
        * editing/apply_style_command.cpp: Removed.
        * editing/apply_style_command.h: Removed.
        * editing/break_blockquote_command.cpp: Removed.
        * editing/break_blockquote_command.h: Removed.
        * editing/composite_edit_command.cpp: Removed.
        * editing/composite_edit_command.h: Removed.
        * editing/delete_from_text_node_command.cpp: Removed.
        * editing/delete_from_text_node_command.h: Removed.
        * editing/delete_selection_command.cpp: Removed.
        * editing/delete_selection_command.h: Removed.
        * editing/edit_command.cpp: Removed.
        * editing/edit_command.h: Removed.
        * editing/htmlediting.cpp:
        * editing/insert_into_text_node_command.cpp: Removed.
        * editing/insert_into_text_node_command.h: Removed.
        * editing/insert_line_break_command.cpp: Removed.
        * editing/insert_line_break_command.h: Removed.
        * editing/insert_node_before_command.cpp: Removed.
        * editing/insert_node_before_command.h: Removed.
        * editing/insert_paragraph_separator_command.cpp: Removed.
        * editing/insert_paragraph_separator_command.h: Removed.
        * editing/insert_text_command.cpp: Removed.
        * editing/insert_text_command.h: Removed.
        * editing/join_text_nodes_command.cpp: Removed.
        * editing/join_text_nodes_command.h: Removed.
        * editing/jsediting.cpp:
        * editing/markup.cpp:
        * editing/merge_identical_elements_command.cpp: Removed.
        * editing/merge_identical_elements_command.h: Removed.
        * editing/move_selection_command.cpp: Removed.
        * editing/move_selection_command.h: Removed.
        * editing/rebalance_whitespace_command.cpp: Removed.
        * editing/rebalance_whitespace_command.h: Removed.
        * editing/remove_css_property_command.cpp: Removed.
        * editing/remove_css_property_command.h: Removed.
        * editing/remove_node_attribute_command.cpp: Removed.
        * editing/remove_node_attribute_command.h: Removed.
        * editing/remove_node_command.cpp: Removed.
        * editing/remove_node_command.h: Removed.
        * editing/remove_node_preserving_children_command.cpp: Removed.
        * editing/remove_node_preserving_children_command.h: Removed.
        * editing/replace_selection_command.cpp: Removed.
        * editing/replace_selection_command.h: Removed.
        * editing/set_node_attribute_command.cpp: Removed.
        * editing/set_node_attribute_command.h: Removed.
        * editing/split_element_command.cpp: Removed.
        * editing/split_element_command.h: Removed.
        * editing/split_text_node_command.cpp: Removed.
        * editing/split_text_node_command.h: Removed.
        * editing/split_text_node_containing_element.cpp: Removed.
        * editing/split_text_node_containing_element_command.h: Removed.
        * editing/typing_command.cpp: Removed.
        * editing/typing_command.h: Removed.
        * editing/visible_position.cpp: Removed.
        * editing/visible_position.h: Removed.
        * editing/visible_range.cpp: Removed.
        * editing/visible_range.h: Removed.
        * editing/visible_units.cpp:
        * editing/wrap_contents_in_dummy_span_command.cpp: Removed.
        * editing/wrap_contents_in_dummy_span_command.h: Removed.

        * khtml/editing: Removed.
        * khtml/editing/Selection.cpp: Removed.
        * khtml/editing/Selection.h: Removed.
        * khtml/editing/SelectionController.cpp: Removed.
        * khtml/editing/SelectionController.h: Removed.
        * khtml/editing/append_node_command.cpp: Removed.
        * khtml/editing/append_node_command.h: Removed.
        * khtml/editing/apply_style_command.cpp: Removed.
        * khtml/editing/apply_style_command.h: Removed.
        * khtml/editing/break_blockquote_command.cpp: Removed.
        * khtml/editing/break_blockquote_command.h: Removed.
        * khtml/editing/composite_edit_command.cpp: Removed.
        * khtml/editing/composite_edit_command.h: Removed.
        * khtml/editing/delete_from_text_node_command.cpp: Removed.
        * khtml/editing/delete_from_text_node_command.h: Removed.
        * khtml/editing/delete_selection_command.cpp: Removed.
        * khtml/editing/delete_selection_command.h: Removed.
        * khtml/editing/edit_actions.h: Removed.
        * khtml/editing/edit_command.cpp: Removed.
        * khtml/editing/edit_command.h: Removed.
        * khtml/editing/html_interchange.cpp: Removed.
        * khtml/editing/html_interchange.h: Removed.
        * khtml/editing/htmlediting.cpp: Removed.
        * khtml/editing/htmlediting.h: Removed.
        * khtml/editing/insert_into_text_node_command.cpp: Removed.
        * khtml/editing/insert_into_text_node_command.h: Removed.
        * khtml/editing/insert_line_break_command.cpp: Removed.
        * khtml/editing/insert_line_break_command.h: Removed.
        * khtml/editing/insert_node_before_command.cpp: Removed.
        * khtml/editing/insert_node_before_command.h: Removed.
        * khtml/editing/insert_paragraph_separator_command.cpp: Removed.
        * khtml/editing/insert_paragraph_separator_command.h: Removed.
        * khtml/editing/insert_text_command.cpp: Removed.
        * khtml/editing/insert_text_command.h: Removed.
        * khtml/editing/join_text_nodes_command.cpp: Removed.
        * khtml/editing/join_text_nodes_command.h: Removed.
        * khtml/editing/jsediting.cpp: Removed.
        * khtml/editing/jsediting.h: Removed.
        * khtml/editing/markup.cpp: Removed.
        * khtml/editing/markup.h: Removed.
        * khtml/editing/merge_identical_elements_command.cpp: Removed.
        * khtml/editing/merge_identical_elements_command.h: Removed.
        * khtml/editing/move_selection_command.cpp: Removed.
        * khtml/editing/move_selection_command.h: Removed.
        * khtml/editing/rebalance_whitespace_command.cpp: Removed.
        * khtml/editing/rebalance_whitespace_command.h: Removed.
        * khtml/editing/remove_css_property_command.cpp: Removed.
        * khtml/editing/remove_css_property_command.h: Removed.
        * khtml/editing/remove_node_attribute_command.cpp: Removed.
        * khtml/editing/remove_node_attribute_command.h: Removed.
        * khtml/editing/remove_node_command.cpp: Removed.
        * khtml/editing/remove_node_command.h: Removed.
        * khtml/editing/remove_node_preserving_children_command.cpp: Removed.
        * khtml/editing/remove_node_preserving_children_command.h: Removed.
        * khtml/editing/replace_selection_command.cpp: Removed.
        * khtml/editing/replace_selection_command.h: Removed.
        * khtml/editing/set_node_attribute_command.cpp: Removed.
        * khtml/editing/set_node_attribute_command.h: Removed.
        * khtml/editing/split_element_command.cpp: Removed.
        * khtml/editing/split_element_command.h: Removed.
        * khtml/editing/split_text_node_command.cpp: Removed.
        * khtml/editing/split_text_node_command.h: Removed.
        * khtml/editing/split_text_node_containing_element.cpp: Removed.
        * khtml/editing/split_text_node_containing_element_command.h: Removed.
        * khtml/editing/text_affinity.h: Removed.
        * khtml/editing/text_granularity.h: Removed.
        * khtml/editing/typing_command.cpp: Removed.
        * khtml/editing/typing_command.h: Removed.
        * khtml/editing/visible_position.cpp: Removed.
        * khtml/editing/visible_position.h: Removed.
        * khtml/editing/visible_range.cpp: Removed.
        * khtml/editing/visible_range.h: Removed.
        * khtml/editing/visible_text.cpp: Removed.
        * khtml/editing/visible_text.h: Removed.
        * khtml/editing/visible_units.cpp: Removed.
        * khtml/editing/visible_units.h: Removed.
        * khtml/editing/wrap_contents_in_dummy_span_command.cpp: Removed.
        * khtml/editing/wrap_contents_in_dummy_span_command.h: Removed.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@12803 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/editing/TypingCommand.cpp b/WebCore/editing/TypingCommand.cpp
new file mode 100644
index 0000000..33a38a3
--- /dev/null
+++ b/WebCore/editing/TypingCommand.cpp
@@ -0,0 +1,385 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "TypingCommand.h"
+
+#include "BreakBlockquoteCommand.h"
+#include "DocumentImpl.h"
+#include "Frame.h"
+#include "InsertLineBreakCommand.h"
+#include "InsertParagraphSeparatorCommand.h"
+#include "InsertTextCommand.h"
+#include "SelectionController.h"
+#include "VisiblePosition.h"
+#include "htmlediting.h"
+#include "visible_units.h"
+#include <kxmlcore/Assertions.h>
+
+namespace WebCore {
+
+TypingCommand::TypingCommand(DocumentImpl *document, ETypingCommand commandType, const DOMString &textToInsert, bool selectInsertedText)
+    : CompositeEditCommand(document), 
+      m_commandType(commandType), 
+      m_textToInsert(textToInsert), 
+      m_openForMoreTyping(true), 
+      m_applyEditing(false), 
+      m_selectInsertedText(selectInsertedText),
+      m_smartDelete(false)
+{
+}
+
+void TypingCommand::deleteKeyPressed(DocumentImpl *document, bool smartDelete)
+{
+    ASSERT(document);
+    
+    Frame *frame = document->frame();
+    ASSERT(frame);
+    
+    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    if (isOpenForMoreTypingCommand(lastEditCommand)) {
+        static_cast<TypingCommand *>(lastEditCommand.get())->deleteKeyPressed();
+        return;
+    }
+    
+    TypingCommand *typingCommand = new TypingCommand(document, DeleteKey);
+    typingCommand->setSmartDelete(smartDelete);
+    EditCommandPtr cmd(typingCommand);
+    cmd.apply();
+}
+
+void TypingCommand::forwardDeleteKeyPressed(DocumentImpl *document, bool smartDelete)
+{
+    ASSERT(document);
+    
+    Frame *frame = document->frame();
+    ASSERT(frame);
+    
+    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    if (isOpenForMoreTypingCommand(lastEditCommand)) {
+        static_cast<TypingCommand *>(lastEditCommand.get())->forwardDeleteKeyPressed();
+        return;
+    }
+
+    TypingCommand *typingCommand = new TypingCommand(document, ForwardDeleteKey);
+    typingCommand->setSmartDelete(smartDelete);
+    EditCommandPtr cmd(typingCommand);
+    cmd.apply();
+}
+
+void TypingCommand::insertText(DocumentImpl *document, const DOMString &text, bool selectInsertedText)
+{
+    ASSERT(document);
+    
+    Frame *frame = document->frame();
+    ASSERT(frame);
+    
+    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    if (isOpenForMoreTypingCommand(lastEditCommand)) {
+        static_cast<TypingCommand *>(lastEditCommand.get())->insertText(text, selectInsertedText);
+        return;
+    }
+
+    EditCommandPtr cmd(new TypingCommand(document, InsertText, text, selectInsertedText));
+    cmd.apply();
+}
+
+void TypingCommand::insertLineBreak(DocumentImpl *document)
+{
+    ASSERT(document);
+    
+    Frame *frame = document->frame();
+    ASSERT(frame);
+    
+    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    if (isOpenForMoreTypingCommand(lastEditCommand)) {
+        static_cast<TypingCommand *>(lastEditCommand.get())->insertLineBreak();
+        return;
+    }
+
+    EditCommandPtr cmd(new TypingCommand(document, InsertLineBreak));
+    cmd.apply();
+}
+
+void TypingCommand::insertParagraphSeparatorInQuotedContent(DocumentImpl *document)
+{
+    ASSERT(document);
+    
+    Frame *frame = document->frame();
+    ASSERT(frame);
+    
+    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    if (isOpenForMoreTypingCommand(lastEditCommand)) {
+        static_cast<TypingCommand *>(lastEditCommand.get())->insertParagraphSeparatorInQuotedContent();
+        return;
+    }
+
+    EditCommandPtr cmd(new TypingCommand(document, InsertParagraphSeparatorInQuotedContent));
+    cmd.apply();
+}
+
+void TypingCommand::insertParagraphSeparator(DocumentImpl *document)
+{
+    ASSERT(document);
+    
+    Frame *frame = document->frame();
+    ASSERT(frame);
+    
+    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    if (isOpenForMoreTypingCommand(lastEditCommand)) {
+        static_cast<TypingCommand *>(lastEditCommand.get())->insertParagraphSeparator();
+        return;
+    }
+
+    EditCommandPtr cmd(new TypingCommand(document, InsertParagraphSeparator));
+    cmd.apply();
+}
+
+bool TypingCommand::isOpenForMoreTypingCommand(const EditCommandPtr &cmd)
+{
+    return cmd.isTypingCommand() &&
+        static_cast<const TypingCommand *>(cmd.get())->openForMoreTyping();
+}
+
+void TypingCommand::closeTyping(const EditCommandPtr &cmd)
+{
+    if (isOpenForMoreTypingCommand(cmd))
+        static_cast<TypingCommand *>(cmd.get())->closeTyping();
+}
+
+void TypingCommand::doApply()
+{
+    if (endingSelection().isNone())
+        return;
+
+    switch (m_commandType) {
+        case DeleteKey:
+            deleteKeyPressed();
+            return;
+        case ForwardDeleteKey:
+            forwardDeleteKeyPressed();
+            return;
+        case InsertLineBreak:
+            insertLineBreak();
+            return;
+        case InsertParagraphSeparator:
+            insertParagraphSeparator();
+            return;
+        case InsertParagraphSeparatorInQuotedContent:
+            insertParagraphSeparatorInQuotedContent();
+            return;
+        case InsertText:
+            insertText(m_textToInsert, m_selectInsertedText);
+            return;
+    }
+
+    ASSERT_NOT_REACHED();
+}
+
+EditAction TypingCommand::editingAction() const
+{
+    return EditActionTyping;
+}
+
+void TypingCommand::markMisspellingsAfterTyping()
+{
+    // Take a look at the selection that results after typing and determine whether we need to spellcheck. 
+    // Since the word containing the current selection is never marked, this does a check to
+    // see if typing made a new word that is not in the current selection. Basically, you
+    // get this by being at the end of a word and typing a space.    
+    VisiblePosition start(endingSelection().start(), endingSelection().affinity());
+    VisiblePosition previous = start.previous();
+    if (previous.isNotNull()) {
+        VisiblePosition p1 = startOfWord(previous, LeftWordIfOnBoundary);
+        VisiblePosition p2 = startOfWord(start, LeftWordIfOnBoundary);
+        if (p1 != p2)
+            document()->frame()->markMisspellingsInAdjacentWords(p1);
+    }
+}
+
+void TypingCommand::typingAddedToOpenCommand()
+{
+    markMisspellingsAfterTyping();
+    // Do not apply editing to the frame on the first time through.
+    // The frame will get told in the same way as all other commands.
+    // But since this command stays open and is used for additional typing, 
+    // we need to tell the frame here as other commands are added.
+    if (m_applyEditing) {
+        EditCommandPtr cmd(this);
+        document()->frame()->appliedEditing(cmd);
+    }
+    m_applyEditing = true;
+}
+
+void TypingCommand::insertText(const DOMString &text, bool selectInsertedText)
+{
+    // FIXME: Need to implement selectInsertedText for cases where more than one insert is involved.
+    // This requires support from insertTextRunWithoutNewlines and insertParagraphSeparator for extending
+    // an existing selection; at the moment they can either put the caret after what's inserted or
+    // select what's inserted, but there's no way to "extend selection" to include both an old selection
+    // that ends just before where we want to insert text and the newly inserted text.
+    int offset = 0;
+    int newline;
+    while ((newline = text.find('\n', offset)) != -1) {
+        if (newline != offset)
+            insertTextRunWithoutNewlines(text.substring(offset, newline - offset), false);
+        insertParagraphSeparator();
+        offset = newline + 1;
+    }
+    if (offset == 0)
+        insertTextRunWithoutNewlines(text, selectInsertedText);
+    else {
+        int length = text.length();
+        if (length != offset) {
+            insertTextRunWithoutNewlines(text.substring(offset, length - offset), selectInsertedText);
+        }
+    }
+}
+
+void TypingCommand::insertTextRunWithoutNewlines(const DOMString &text, bool selectInsertedText)
+{
+    // FIXME: Improve typing style.
+    // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
+    if (document()->frame()->typingStyle() || m_cmds.count() == 0) {
+        InsertTextCommand *impl = new InsertTextCommand(document());
+        EditCommandPtr cmd(impl);
+        applyCommandToComposite(cmd);
+        impl->input(text, selectInsertedText);
+    } else {
+        EditCommandPtr lastCommand = m_cmds.last();
+        if (lastCommand.isInsertTextCommand()) {
+            InsertTextCommand *impl = static_cast<InsertTextCommand *>(lastCommand.get());
+            impl->input(text, selectInsertedText);
+        } else {
+            InsertTextCommand *impl = new InsertTextCommand(document());
+            EditCommandPtr cmd(impl);
+            applyCommandToComposite(cmd);
+            impl->input(text, selectInsertedText);
+        }
+    }
+    typingAddedToOpenCommand();
+}
+
+void TypingCommand::insertLineBreak()
+{
+    EditCommandPtr cmd(new InsertLineBreakCommand(document()));
+    applyCommandToComposite(cmd);
+    typingAddedToOpenCommand();
+}
+
+void TypingCommand::insertParagraphSeparator()
+{
+    EditCommandPtr cmd(new InsertParagraphSeparatorCommand(document()));
+    applyCommandToComposite(cmd);
+    typingAddedToOpenCommand();
+}
+
+void TypingCommand::insertParagraphSeparatorInQuotedContent()
+{
+    EditCommandPtr cmd(new BreakBlockquoteCommand(document()));
+    applyCommandToComposite(cmd);
+    typingAddedToOpenCommand();
+}
+
+void TypingCommand::deleteKeyPressed()
+{
+    Selection selectionToDelete;
+    
+    switch (endingSelection().state()) {
+        case khtml::Selection::RANGE:
+            selectionToDelete = endingSelection();
+            break;
+        case khtml::Selection::CARET: {
+            // Handle delete at beginning-of-block case.
+            // 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, CHARACTER);
+            selectionToDelete = sc.selection();
+            break;
+        }
+        case khtml::Selection::NONE:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+    
+    if (selectionToDelete.isCaretOrRange()) {
+        deleteSelection(selectionToDelete, m_smartDelete);
+        setSmartDelete(false);
+        typingAddedToOpenCommand();
+    }
+}
+
+void TypingCommand::forwardDeleteKeyPressed()
+{
+    Selection selectionToDelete;
+    
+    switch (endingSelection().state()) {
+        case khtml::Selection::RANGE:
+            selectionToDelete = endingSelection();
+            break;
+        case khtml::Selection::CARET: {
+            // Handle delete at beginning-of-block case.
+            // 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, CHARACTER);
+            selectionToDelete = sc.selection();
+            break;
+        }
+        case khtml::Selection::NONE:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+    
+    if (selectionToDelete.isCaretOrRange()) {
+        deleteSelection(selectionToDelete, m_smartDelete);
+        setSmartDelete(false);
+        typingAddedToOpenCommand();
+    }
+}
+
+bool TypingCommand::preservesTypingStyle() const
+{
+    switch (m_commandType) {
+        case DeleteKey:
+        case ForwardDeleteKey:
+        case InsertParagraphSeparator:
+        case InsertLineBreak:
+            return true;
+        case InsertParagraphSeparatorInQuotedContent:
+        case InsertText:
+            return false;
+    }
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
+bool TypingCommand::isTypingCommand() const
+{
+    return true;
+}
+
+} // namespace khtml