[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:25:34 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit eb71c842561f45a61e327f7dcecf024852b24feb
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Feb 6 22:33:03 2004 +0000

            Reviewed by Chris
    
    	Steps no longer return int error codes. Steps are operations
    	that should succeed. (When was the last time that typing in
    	a text editor failed for reasons which could not have been
    	figured out ahead of time...like file permissions?).
    	If this does not work for the future, perhaps we can change
    	some or all of the many asserts in the code to throw C++
    	exceptions instead, which can be caught and handled at a
    	suitable level.
    
    	I also made some nice convenience functions to create and apply
    	EditStep objects, and moved the command code to use the new
    	functions.
    
            * khtml/editing/htmlediting.cpp:
            (EditStep::EditStep):
            (EditStep::~EditStep):
            (EditStep::reapply):
            (EditStep::beginApply):
            (EditStep::endApply):
            (EditStep::beginUnapply):
            (EditStep::endUnapply):
            (EditStep::beginReapply):
            (EditStep::endReapply):
            (CompositeEditStep::unapply):
            (CompositeEditStep::reapply):
            (CompositeEditStep::applyStep):
            (CompositeEditStep::insertNodeBefore):
            (CompositeEditStep::insertNodeAfter):
            (CompositeEditStep::appendNode):
            (CompositeEditStep::removeNode):
            (CompositeEditStep::splitTextNode):
            (CompositeEditStep::joinTextNodes):
            (CompositeEditStep::insertText):
            (CompositeEditStep::deleteText):
            (CompositeEditStep::moveSelectionTo):
            (CompositeEditStep::deleteSelection):
            (InsertNodeBeforeStep::InsertNodeBeforeStep):
            (InsertNodeBeforeStep::apply):
            (InsertNodeBeforeStep::unapply):
            (AppendNodeStep::AppendNodeStep):
            (AppendNodeStep::apply):
            (AppendNodeStep::unapply):
            (RemoveNodeStep::RemoveNodeStep):
            (RemoveNodeStep::apply):
            (RemoveNodeStep::unapply):
            (ModifyTextNodeStep::ModifyTextNodeStep):
            (ModifyTextNodeStep::splitTextNode):
            (ModifyTextNodeStep::joinTextNodes):
            (SplitTextNodeStep::apply):
            (SplitTextNodeStep::unapply):
            (JoinTextNodesStep::apply):
            (JoinTextNodesStep::unapply):
            (InsertTextStep::InsertTextStep):
            (InsertTextStep::apply):
            (InsertTextStep::unapply):
            (DeleteTextStep::DeleteTextStep):
            (DeleteTextStep::apply):
            (DeleteTextStep::unapply):
            (MoveSelectionToStep::MoveSelectionToStep):
            (MoveSelectionToStep::apply):
            (MoveSelectionToStep::unapply):
            (DeleteSelectionStep::apply):
            (EditCommand::EditCommand):
            (EditCommand::~EditCommand):
            (EditCommand::currentSelection):
            (InputTextCommand::apply):
            (DeleteTextCommand::apply):
            * khtml/editing/htmlediting.h:
            (khtml::MoveSelectionToStep::~MoveSelectionToStep):
            (khtml::EditCommand::cookie):
            * khtml/khtml_part.cpp:
            (KHTMLPart::applyCommand):
            (KHTMLPart::undoRedoEditing):
            (KHTMLPart::undoEditing):
            (KHTMLPart::redoEditing):
            * khtml/khtml_part.h:
            * khtml/xml/dom_elementimpl.cpp:
            (ElementImpl::defaultEventHandler):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6041 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index a27ccca..d471508 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,86 @@
+2004-02-06  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Chris
+
+	Steps no longer return int error codes. Steps are operations
+	that should succeed. (When was the last time that typing in
+	a text editor failed for reasons which could not have been
+	figured out ahead of time...like file permissions?).
+	If this does not work for the future, perhaps we can change 
+	some or all of the many asserts in the code to throw C++ 
+	exceptions instead, which can be caught and handled at a
+	suitable level.
+
+	I also made some nice convenience functions to create and apply
+	EditStep objects, and moved the command code to use the new
+	functions.
+
+        * khtml/editing/htmlediting.cpp:
+        (EditStep::EditStep):
+        (EditStep::~EditStep):
+        (EditStep::reapply):
+        (EditStep::beginApply):
+        (EditStep::endApply):
+        (EditStep::beginUnapply):
+        (EditStep::endUnapply):
+        (EditStep::beginReapply):
+        (EditStep::endReapply):
+        (CompositeEditStep::unapply):
+        (CompositeEditStep::reapply):
+        (CompositeEditStep::applyStep):
+        (CompositeEditStep::insertNodeBefore):
+        (CompositeEditStep::insertNodeAfter):
+        (CompositeEditStep::appendNode):
+        (CompositeEditStep::removeNode):
+        (CompositeEditStep::splitTextNode):
+        (CompositeEditStep::joinTextNodes):
+        (CompositeEditStep::insertText):
+        (CompositeEditStep::deleteText):
+        (CompositeEditStep::moveSelectionTo):
+        (CompositeEditStep::deleteSelection):
+        (InsertNodeBeforeStep::InsertNodeBeforeStep):
+        (InsertNodeBeforeStep::apply):
+        (InsertNodeBeforeStep::unapply):
+        (AppendNodeStep::AppendNodeStep):
+        (AppendNodeStep::apply):
+        (AppendNodeStep::unapply):
+        (RemoveNodeStep::RemoveNodeStep):
+        (RemoveNodeStep::apply):
+        (RemoveNodeStep::unapply):
+        (ModifyTextNodeStep::ModifyTextNodeStep):
+        (ModifyTextNodeStep::splitTextNode):
+        (ModifyTextNodeStep::joinTextNodes):
+        (SplitTextNodeStep::apply):
+        (SplitTextNodeStep::unapply):
+        (JoinTextNodesStep::apply):
+        (JoinTextNodesStep::unapply):
+        (InsertTextStep::InsertTextStep):
+        (InsertTextStep::apply):
+        (InsertTextStep::unapply):
+        (DeleteTextStep::DeleteTextStep):
+        (DeleteTextStep::apply):
+        (DeleteTextStep::unapply):
+        (MoveSelectionToStep::MoveSelectionToStep):
+        (MoveSelectionToStep::apply):
+        (MoveSelectionToStep::unapply):
+        (DeleteSelectionStep::apply):
+        (EditCommand::EditCommand):
+        (EditCommand::~EditCommand):
+        (EditCommand::currentSelection):
+        (InputTextCommand::apply):
+        (DeleteTextCommand::apply):
+        * khtml/editing/htmlediting.h:
+        (khtml::MoveSelectionToStep::~MoveSelectionToStep):
+        (khtml::EditCommand::cookie):
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::applyCommand):
+        (KHTMLPart::undoRedoEditing):
+        (KHTMLPart::undoEditing):
+        (KHTMLPart::redoEditing):
+        * khtml/khtml_part.h:
+        * khtml/xml/dom_elementimpl.cpp:
+        (ElementImpl::defaultEventHandler):
+
 2004-02-05  Ken Kocienda  <kocienda at apple.com>
 
         Reviewed by Hyatt
diff --git a/WebCore/khtml/editing/htmlediting.cpp b/WebCore/khtml/editing/htmlediting.cpp
index 3b84452..b2dc620 100644
--- a/WebCore/khtml/editing/htmlediting.cpp
+++ b/WebCore/khtml/editing/htmlediting.cpp
@@ -27,6 +27,7 @@
 
 #if APPLE_CHANGES
 #include "KWQAssertions.h"
+#include "KWQLogging.h"
 #endif
 
 #include "khtmlview.h"
@@ -40,7 +41,6 @@
 #include "xml/dom_textimpl.h"
 
 using DOM::DocumentImpl;
-using DOM::DOMException;
 using DOM::DOMPosition;
 using DOM::DOMString;
 using DOM::ElementImpl;
@@ -61,20 +61,20 @@ using khtml::InsertTextStep;
 using khtml::JoinTextNodesStep;
 using khtml::ModifyTextNodeStep;
 using khtml::RemoveNodeStep;
-using khtml::SetSelectionStep;
+using khtml::MoveSelectionToStep;
 using khtml::SplitTextNodeStep;
 
 using khtml::DeleteTextCommand;
 using khtml::EditCommand;
 using khtml::InputTextCommand;
 
-#define APPLY_STEP(s) do { \
-        int result = s->apply(); \
-        if (result) { \
-            return result; \
-        } \
-        m_steps.append(s); \
-    } while (0)
+#if !APPLE_CHANGES
+#define ASSERT(assertion) ((void)0)
+#define ASSERT_WITH_MESSAGE(assertion, formatAndArgs...) ((void)0)
+#define ASSERT_NOT_REACHED() ((void)0)
+#define LOG(channel, formatAndArgs...) ((void)0)
+#define ERROR(formatAndArgs...) ((void)0)
+#endif
 
 //------------------------------------------------------------------------------------------
 
@@ -85,8 +85,8 @@ using khtml::InputTextCommand;
 
 EditStep::EditStep(DocumentImpl *document) : m_document(document), m_state(NOT_APPLIED)
 {
-    assert(m_document);
-    assert(m_document->part());
+    ASSERT(m_document);
+    ASSERT(m_document->part());
     m_document->ref();
     m_startingSelection = m_document->part()->selection();
     m_endingSelection = m_startingSelection;
@@ -94,33 +94,51 @@ EditStep::EditStep(DocumentImpl *document) : m_document(document), m_state(NOT_A
 
 EditStep::~EditStep()
 {
-    assert(m_document);
+    ASSERT(m_document);
     m_document->deref();
 }
 
-int EditStep::apply()
+void EditStep::reapply()
+{
+    apply();
+}
+
+inline void EditStep::beginApply()
 {
-    assert(m_document);
-    assert(m_document->part());
+    ASSERT(state() == NOT_APPLIED);
+}
+
+inline void EditStep::endApply()
+{
+    ASSERT(m_document);
+    ASSERT(m_document->part());
 
     m_state = APPLIED;
     m_document->part()->setSelection(m_endingSelection);
-    return EditResultOK;
 }
 
-int EditStep::unapply()
+inline void EditStep::beginUnapply()
 {
-    assert(m_document);
-    assert(m_document->part());
+    ASSERT(state() == APPLIED);
+}
+
+inline void EditStep::endUnapply()
+{
+    ASSERT(m_document);
+    ASSERT(m_document->part());
 
     m_state = NOT_APPLIED;
     m_document->part()->setSelection(m_startingSelection);
-    return EditResultOK;
 }
 
-int EditStep::reapply()
+inline void EditStep::beginReapply()
 {
-    return apply();
+    beginApply();
+}
+
+inline void EditStep::endReapply()
+{
+    endApply();
 }
 
 //------------------------------------------------------------------------------------------
@@ -136,30 +154,106 @@ CompositeEditStep::~CompositeEditStep()
 {
 }
 
-int CompositeEditStep::unapply()
+void CompositeEditStep::unapply()
 {
+    if (m_steps.count() == 0) {
+        ERROR("Unapplying composite step containing zero steps");
+    }
     QPtrListIterator<EditStep> it(m_steps);
     for (it.toLast(); it.current(); --it) {
-        int result = it.current()->unapply();
-        if (result != EditResultOK)
-            return result;
+        it.current()->unapply();
     }
-
-    return EditStep::unapply();
 }
 
-int CompositeEditStep::reapply()
+void CompositeEditStep::reapply()
 {
+    if (m_steps.count() == 0) {
+        ERROR("Reapplying composite step containing zero steps");
+    }
     QPtrListIterator<EditStep> it(m_steps);
     for (; it.current(); ++it) {
-        int result = it.current()->reapply();
-        if (result != EditResultOK)
-            return result;
+        it.current()->reapply();
+    }
+}
+
+//
+// sugary-sweet convenience functions to help create and apply edit steps
+//
+void CompositeEditStep::applyStep(EditStep *step)
+{
+    step->apply();
+    m_steps.append(step);
+}
+
+void CompositeEditStep::insertNodeBefore(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild)
+{
+    applyStep(new InsertNodeBeforeStep(document(), insertChild, refChild));
+}
+
+void CompositeEditStep::insertNodeAfter(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild)
+{
+    if (refChild->parentNode()->lastChild() == refChild) {
+        appendNode(refChild->parentNode(), insertChild);
     }
+    else {
+        ASSERT(refChild->nextSibling());
+        insertNodeBefore(insertChild, refChild->nextSibling());
+    }
+}
+
+void CompositeEditStep::appendNode(DOM::NodeImpl *parent, DOM::NodeImpl *appendChild)
+{
+    applyStep(new AppendNodeStep(document(), parent, appendChild));
+}
+
+void CompositeEditStep::removeNode(DOM::NodeImpl *removeChild)
+{
+    applyStep(new RemoveNodeStep(document(), removeChild));
+}
+
+void CompositeEditStep::splitTextNode(DOM::TextImpl *text, long offset)
+{
+    applyStep(new SplitTextNodeStep(document(), text, offset));
+}
+
+void CompositeEditStep::joinTextNodes(DOM::TextImpl *text1, DOM::TextImpl *text2)
+{
+    applyStep(new JoinTextNodesStep(document(), text1, text2));
+}
+
+void CompositeEditStep::insertText(DOM::TextImpl *node, long offset, const DOM::DOMString &text)
+{
+    applyStep(new InsertTextStep(document(), node, offset, text));
+}
+
+void CompositeEditStep::deleteText(DOM::TextImpl *node, long offset, long count)
+{
+    applyStep(new DeleteTextStep(document(), node, offset, count));
+}
+
+void CompositeEditStep::moveSelectionTo(const KHTMLSelection &selection)
+{
+    applyStep(new MoveSelectionToStep(document(), selection));
+}
+
+void CompositeEditStep::moveSelectionTo(DOM::NodeImpl *node, long offset)
+{
+    applyStep(new MoveSelectionToStep(document(), node, offset));
+}
+
+void CompositeEditStep::moveSelectionTo(const DOM::DOMPosition &pos)
+{
+    applyStep(new MoveSelectionToStep(document(), pos));
+}
+
+void CompositeEditStep::deleteSelection()
+{
+    applyStep(new DeleteSelectionStep(document()));
+}
 
-    // Calls apply() and not reapply(), given that the default implementation of
-    // EditStep::reapply() calls apply(), which dispatches virtually.
-    return EditStep::apply();
+void CompositeEditStep::deleteSelection(const KHTMLSelection &selection)
+{
+    applyStep(new DeleteSelectionStep(document(), selection));
 }
 
 //------------------------------------------------------------------------------------------
@@ -168,10 +262,10 @@ int CompositeEditStep::reapply()
 InsertNodeBeforeStep::InsertNodeBeforeStep(DocumentImpl *document, NodeImpl *insertChild, NodeImpl *refChild)
     : EditStep(document), m_insertChild(insertChild), m_refChild(refChild)
 {
-    assert(m_insertChild);
+    ASSERT(m_insertChild);
     m_insertChild->ref();
 
-    assert(m_refChild);
+    ASSERT(m_refChild);
     m_refChild->ref();
 }
 
@@ -183,34 +277,34 @@ InsertNodeBeforeStep::~InsertNodeBeforeStep()
         m_refChild->deref();
 }
 
-int InsertNodeBeforeStep::apply()
+void InsertNodeBeforeStep::apply()
 {
-    assert(m_insertChild);
-    assert(m_refChild);
-    assert(m_refChild->parent());
-    assert(state() == NOT_APPLIED);
+    beginApply();
+
+    ASSERT(m_insertChild);
+    ASSERT(m_refChild);
+    ASSERT(m_refChild->parent());
 
     int exceptionCode;
     m_refChild->parent()->insertBefore(m_insertChild, m_refChild, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
-    return EditStep::apply();
+    endApply();
 }
 
-int InsertNodeBeforeStep::unapply()
+void InsertNodeBeforeStep::unapply()
 {
-    assert(m_insertChild);
-    assert(m_refChild);
-    assert(m_refChild->parent());
-    assert(state() == APPLIED);
+    beginUnapply();
+
+    ASSERT(m_insertChild);
+    ASSERT(m_refChild);
+    ASSERT(m_refChild->parent());
 
     int exceptionCode;
     m_refChild->parent()->removeChild(m_insertChild, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
-    return EditStep::unapply();
+    endUnapply();
 }
 
 //------------------------------------------------------------------------------------------
@@ -219,10 +313,10 @@ int InsertNodeBeforeStep::unapply()
 AppendNodeStep::AppendNodeStep(DocumentImpl *document, NodeImpl *parent, NodeImpl *appendChild)
     : EditStep(document), m_parent(parent), m_appendChild(appendChild)
 {
-    assert(m_parent);
+    ASSERT(m_parent);
     m_parent->ref();
 
-    assert(m_appendChild);
+    ASSERT(m_appendChild);
     m_appendChild->ref();
 }
 
@@ -234,32 +328,33 @@ AppendNodeStep::~AppendNodeStep()
         m_appendChild->deref();
 }
 
-int AppendNodeStep::apply()
+void AppendNodeStep::apply()
 {
-    assert(m_parent);
-    assert(m_appendChild);
-    assert(state() == NOT_APPLIED);
+    beginApply();
+
+    ASSERT(m_parent);
+    ASSERT(m_appendChild);
 
     int exceptionCode;
     m_parent->appendChild(m_appendChild, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
-    return EditStep::apply();
+    endApply();
 }
 
-int AppendNodeStep::unapply()
+void AppendNodeStep::unapply()
 {
-    assert(m_parent);
-    assert(m_appendChild);
-    assert(state() == APPLIED);
+    beginUnapply();
+
+    ASSERT(m_parent);
+    ASSERT(m_appendChild);
+    ASSERT(state() == APPLIED);
 
     int exceptionCode;
     m_parent->removeChild(m_appendChild, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
-    return EditStep::unapply();
+    endUnapply();
 }
 
 //------------------------------------------------------------------------------------------
@@ -268,11 +363,11 @@ int AppendNodeStep::unapply()
 RemoveNodeStep::RemoveNodeStep(DocumentImpl *document, NodeImpl *removeChild)
     : EditStep(document), m_parent(0), m_removeChild(removeChild), m_refChild(0)
 {
-    assert(m_removeChild);
+    ASSERT(m_removeChild);
     m_removeChild->ref();
 
     m_parent = m_removeChild->parentNode();
-    assert(m_parent);
+    ASSERT(m_parent);
     m_parent->ref();
     
     NodeListImpl *children = m_parent->childNodes();
@@ -297,35 +392,35 @@ RemoveNodeStep::~RemoveNodeStep()
         m_refChild->deref();
 }
 
-int RemoveNodeStep::apply()
+void RemoveNodeStep::apply()
 {
-    assert(m_parent);
-    assert(m_removeChild);
-    assert(state() == NOT_APPLIED);
+    beginApply();
+
+    ASSERT(m_parent);
+    ASSERT(m_removeChild);
 
     int exceptionCode;
     m_parent->removeChild(m_removeChild, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
-    return EditStep::apply();
+    endApply();
 }
 
-int RemoveNodeStep::unapply()
+void RemoveNodeStep::unapply()
 {
-    assert(m_parent);
-    assert(m_removeChild);
-    assert(state() == APPLIED);
+    beginUnapply();
+
+    ASSERT(m_parent);
+    ASSERT(m_removeChild);
 
     int exceptionCode;
     if (m_refChild)
         m_parent->insertBefore(m_removeChild, m_refChild, exceptionCode);
     else
         m_parent->appendChild(m_removeChild, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
-    return EditStep::unapply();
+    endUnapply();
 }
 
 //------------------------------------------------------------------------------------------
@@ -334,9 +429,9 @@ int RemoveNodeStep::unapply()
 ModifyTextNodeStep::ModifyTextNodeStep(DocumentImpl *document, TextImpl *text, long offset)
     : EditStep(document), m_text1(0), m_text2(text), m_offset(offset)
 {
-    assert(m_text2);
-    assert(m_text2->length() > 0);
-    assert(m_offset >= 0);
+    ASSERT(m_text2);
+    ASSERT(m_text2->length() > 0);
+    ASSERT(m_offset >= 0);
 
     m_text2->ref();
 }
@@ -344,11 +439,11 @@ ModifyTextNodeStep::ModifyTextNodeStep(DocumentImpl *document, TextImpl *text, l
 ModifyTextNodeStep::ModifyTextNodeStep(DocumentImpl *document, TextImpl *text1, TextImpl *text2)
     : EditStep(document), m_text1(text1), m_text2(text2), m_offset(0)
 {
-    assert(m_text1);
-    assert(m_text2);
-    assert(m_text1->nextSibling() == m_text2);
-    assert(m_text1->length() > 0);
-    assert(m_text2->length() > 0);
+    ASSERT(m_text1);
+    ASSERT(m_text2);
+    ASSERT(m_text1->nextSibling() == m_text2);
+    ASSERT(m_text1->length() > 0);
+    ASSERT(m_text2->length() > 0);
 
     m_text1->ref();
     m_text2->ref();
@@ -362,64 +457,49 @@ ModifyTextNodeStep::~ModifyTextNodeStep()
         m_text1->deref();
 }
 
-int ModifyTextNodeStep::splitTextNode()
+void ModifyTextNodeStep::splitTextNode()
 {
-    assert(m_text2);
-    assert(m_text1 == 0);
-    assert(m_offset > 0);
-    assert(state() == splitState());
-
-    RenderObject *textRenderer = m_text2->renderer();
-    if (!textRenderer)
-        return EditResultFailed;
+    ASSERT(m_text2);
+    ASSERT(m_text1 == 0);
+    ASSERT(m_offset > 0);
+    ASSERT(state() == splitState());
 
-    if (m_offset <= textRenderer->caretMinOffset() || m_offset >= textRenderer->caretMaxOffset())
-        return EditResultNoActionTaken;
+    ASSERT(m_offset >= m_text2->caretMinOffset() && m_offset <= m_text2->caretMaxOffset());
 
     int exceptionCode;
     TextImpl *m_text1 = document()->createTextNode(m_text2->substringData(0, m_offset, exceptionCode));
-    if (exceptionCode)
-        return exceptionCode;
-    assert(m_text1);
+    ASSERT(exceptionCode == 0);
+    ASSERT(m_text1);
     m_text1->ref();
 
     m_text2->deleteData(0, m_offset, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
     m_text2->parentNode()->insertBefore(m_text1, m_text2, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
         
-    assert(m_text2->previousSibling()->isTextNode());
+    ASSERT(m_text2->previousSibling()->isTextNode());
     m_text1 = static_cast<TextImpl *>(m_text2->previousSibling());
-    
-    return EditResultOK;
 }
 
-int ModifyTextNodeStep::joinTextNodes()
+void ModifyTextNodeStep::joinTextNodes()
 {
-    assert(m_text1);
-    assert(m_text2);
-    assert(state() == joinState());
+    ASSERT(m_text1);
+    ASSERT(m_text2);
+    ASSERT(state() == joinState());
     
-    if (m_text1->nextSibling() != m_text2)
-        return EditResultFailed;
+    ASSERT(m_text1->nextSibling() == m_text2);
 
     int exceptionCode;
     m_text2->insertData(0, m_text1->data(), exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
     m_text2->parent()->removeChild(m_text2, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
     m_offset = m_text1->length();
     m_text1->deref();
     m_text1 = 0;
-
-    return EditResultOK;
 }
 
 //------------------------------------------------------------------------------------------
@@ -434,22 +514,18 @@ SplitTextNodeStep::~SplitTextNodeStep()
 {
 }
 
-int SplitTextNodeStep::apply()
+void SplitTextNodeStep::apply()
 {
-    int result = splitTextNode();
-    if (result != EditResultOK)
-        return result;
-    else
-        return EditStep::apply(); // skips unimplemented ModifyTextNodeStep::apply()
+    beginApply();
+    splitTextNode();
+    endApply();
 }
 
-int SplitTextNodeStep::unapply()
+void SplitTextNodeStep::unapply()
 {
-    int result = joinTextNodes();
-    if (result != EditResultOK)
-        return result;
-    else
-        return EditStep::unapply(); // skips unimplemented ModifyTextNodeStep::unapply()
+    beginUnapply();
+    joinTextNodes();
+    endUnapply();
 }
 
 //------------------------------------------------------------------------------------------
@@ -464,22 +540,18 @@ JoinTextNodesStep::~JoinTextNodesStep()
 {
 }
 
-int JoinTextNodesStep::apply()
+void JoinTextNodesStep::apply()
 {
-    int result = joinTextNodes();
-    if (result != EditResultOK)
-        return result;
-    else
-        return EditStep::apply(); // skips unimplemented ModifyTextNodeStep::apply()
+    beginApply();
+    joinTextNodes();
+    endApply();
 }
 
-int JoinTextNodesStep::unapply()
+void JoinTextNodesStep::unapply()
 {
-    int result = splitTextNode();
-    if (result != EditResultOK)
-        return result;
-    else
-        return EditStep::unapply(); // skips unimplemented ModifyTextNodeStep::unapply()
+    beginUnapply();
+    splitTextNode();
+    endUnapply();
 }
 
 //------------------------------------------------------------------------------------------
@@ -488,9 +560,9 @@ int JoinTextNodesStep::unapply()
 InsertTextStep::InsertTextStep(DocumentImpl *document, TextImpl *node, long offset, const DOMString &text)
     : EditStep(document), m_node(node), m_offset(offset)
 {
-    assert(m_node);
-    assert(m_offset >= 0);
-    assert(text.length() > 0);
+    ASSERT(m_node);
+    ASSERT(m_offset >= 0);
+    ASSERT(text.length() > 0);
     
     m_node->ref();
     m_text = text.copy(); // make a copy to ensure that the string never changes
@@ -502,32 +574,32 @@ InsertTextStep::~InsertTextStep()
         m_node->deref();
 }
 
-int InsertTextStep::apply()
+void InsertTextStep::apply()
 {
-    assert(m_node);
-    assert(!m_text.isEmpty());
-    assert(state() == NOT_APPLIED);
+    beginApply();
+
+    ASSERT(m_node);
+    ASSERT(!m_text.isEmpty());
 
     int exceptionCode;
     m_node->insertData(m_offset, m_text, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
-    return EditStep::apply();
+    endApply();
 }
 
-int InsertTextStep::unapply()
+void InsertTextStep::unapply()
 {
-    assert(m_node);
-    assert(!m_text.isEmpty());
-    assert(state() == APPLIED);
+    beginUnapply();
+
+    ASSERT(m_node);
+    ASSERT(!m_text.isEmpty());
 
     int exceptionCode;
     m_node->deleteData(m_offset, m_text.length(), exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
-    return EditStep::unapply();
+    endUnapply();
 }
 
 //------------------------------------------------------------------------------------------
@@ -536,9 +608,9 @@ int InsertTextStep::unapply()
 DeleteTextStep::DeleteTextStep(DocumentImpl *document, TextImpl *node, long offset, long count)
     : EditStep(document), m_node(node), m_offset(offset), m_count(count)
 {
-    assert(m_node);
-    assert(m_offset >= 0);
-    assert(m_count >= 0);
+    ASSERT(m_node);
+    ASSERT(m_offset >= 0);
+    ASSERT(m_count >= 0);
     
     m_node->ref();
 }
@@ -549,70 +621,69 @@ DeleteTextStep::~DeleteTextStep()
         m_node->deref();
 }
 
-int DeleteTextStep::apply()
+void DeleteTextStep::apply()
 {
-    assert(m_node);
-    assert(state() == NOT_APPLIED);
+    beginApply();
+
+    ASSERT(m_node);
 
     int exceptionCode;
     m_text = m_node->substringData(m_offset, m_count, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
     
     m_node->deleteData(m_offset, m_count, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
-    return EditStep::apply();
+    endApply();
 }
 
-int DeleteTextStep::unapply()
+void DeleteTextStep::unapply()
 {
-    assert(m_node);
-    assert(!m_text.isEmpty());
-    assert(state() == APPLIED);
+    beginUnapply();
+
+    ASSERT(m_node);
+    ASSERT(!m_text.isEmpty());
 
     int exceptionCode;
     m_node->insertData(m_offset, m_text, exceptionCode);
-    if (exceptionCode)
-        return exceptionCode;
+    ASSERT(exceptionCode == 0);
 
-    return EditStep::unapply();
+    endUnapply();
 }
 
 //------------------------------------------------------------------------------------------
-// SetSelectionStep
+// MoveSelectionToStep
 
-SetSelectionStep::SetSelectionStep(DocumentImpl *document, const KHTMLSelection &selection)
+MoveSelectionToStep::MoveSelectionToStep(DocumentImpl *document, const KHTMLSelection &selection)
     : EditStep(document)
 {
     setEndingSelection(selection);
 }
 
-SetSelectionStep::SetSelectionStep(DocumentImpl *document, DOM::NodeImpl *node, long offset)
+MoveSelectionToStep::MoveSelectionToStep(DocumentImpl *document, DOM::NodeImpl *node, long offset)
     : EditStep(document)
 {
     KHTMLSelection selection(node, offset);
     setEndingSelection(selection);
 }
 
-SetSelectionStep::SetSelectionStep(DOM::DocumentImpl *document, const DOM::DOMPosition &pos)
+MoveSelectionToStep::MoveSelectionToStep(DOM::DocumentImpl *document, const DOM::DOMPosition &pos)
     : EditStep(document)
 {
     KHTMLSelection selection(pos);
     setEndingSelection(selection);
 }
 
-int SetSelectionStep::apply()
+void MoveSelectionToStep::apply()
 {
-    assert(state() == NOT_APPLIED);
-    return EditStep::apply();
+    beginApply();
+    endApply();
 }
 
-int SetSelectionStep::unapply()
+void MoveSelectionToStep::unapply()
 {
-    assert(state() == APPLIED);
-    return EditStep::unapply();
+    beginUnapply();
+    endUnapply();
 }
 
 //------------------------------------------------------------------------------------------
@@ -633,12 +704,14 @@ DeleteSelectionStep::~DeleteSelectionStep()
 {
 }
 	
-int DeleteSelectionStep::apply()
+void DeleteSelectionStep::apply()
 {
-    assert(state() == NOT_APPLIED);
+    beginApply();
 
-    if (startingSelection().isEmpty())
-        return EditStep::apply();
+    if (startingSelection().isEmpty()) {
+        endApply();
+        return;
+    }
 
     KHTMLSelection selection = startingSelection();
 
@@ -705,25 +778,21 @@ int DeleteSelectionStep::apply()
     //
     // Do the delete
     //
-    EditStep *step;
     NodeImpl *n = deleteStart.node()->nextLeafNode();
 
     // work on start node
     if (startIsCompletelySelected) {
-        step = new RemoveNodeStep(document(), deleteStart.node());
-        APPLY_STEP(step);
+        removeNode(deleteStart.node());
     }
     else if (deleteStart.node()->isTextNode()) {
         TextImpl *text = static_cast<TextImpl *>(deleteStart.node());
         int endOffset = text == deleteEnd.node() ? deleteEnd.offset() : text->length();
         if (endOffset > deleteStart.offset()) {
-            step = new DeleteTextStep(document(), text, deleteStart.offset(), endOffset - deleteStart.offset());
-            APPLY_STEP(step);
+            deleteText(text, deleteStart.offset(), endOffset - deleteStart.offset());
         }
     }
     else {
-        // never should reach this code
-        assert(0);
+        ASSERT_NOT_REACHED();
     }
 
     if (deleteStart.node() != deleteEnd.node()) {
@@ -731,26 +800,22 @@ int DeleteSelectionStep::apply()
         while (n != deleteEnd.node()) {
             NodeImpl *d = n;
             n = n->nextLeafNode();
-            step = new RemoveNodeStep(document(), d);
-            APPLY_STEP(step);
+            removeNode(d);
         }
         
         // work on end node
-        assert(n == deleteEnd.node());
+        ASSERT(n == deleteEnd.node());
         if (endIsCompletelySelected) {
-            step = new RemoveNodeStep(document(), deleteEnd.node());
-            APPLY_STEP(step);
+            removeNode(deleteEnd.node());
         }
         else if (deleteEnd.node()->isTextNode()) {
             if (deleteEnd.offset() > 0) {
                 TextImpl *text = static_cast<TextImpl *>(deleteEnd.node());
-                step = new DeleteTextStep(document(), text, 0, deleteEnd.offset());
-                APPLY_STEP(step);
+                deleteText(text, 0, deleteEnd.offset());
             }
         }
         else {
-            // never should reach this code
-            assert(0);
+            ASSERT_NOT_REACHED();
         }
     }
 
@@ -761,7 +826,7 @@ int DeleteSelectionStep::apply()
     selection.moveToRenderedContent();
     setEndingSelection(selection);
 
-    return CompositeEditStep::apply();
+    endApply();
 }
 
 //------------------------------------------------------------------------------------------
@@ -773,53 +838,20 @@ int DeleteSelectionStep::apply()
 
 static int cookieCounter = 0;
 
-EditCommand::EditCommand(DocumentImpl *document) : m_document(document)
+EditCommand::EditCommand(DocumentImpl *document) : CompositeEditStep(document)
 {
-    assert(m_document);
-    m_document->ref();
     m_cookie = cookieCounter++;
-    m_steps.setAutoDelete(true);
 }
 
 EditCommand::~EditCommand()
 {
-    assert(m_document);
-    m_document->deref();
 }
 
-const KHTMLSelection &EditCommand::selection() const
+const KHTMLSelection &EditCommand::currentSelection() const
 {
-    assert(m_document);
-    assert(m_document->part());
-    return m_document->part()->selection();
-}
-
-int EditCommand::unapply()
-{
-    assert(m_steps.count() > 0);
-    
-    QPtrListIterator<EditStep> it(m_steps);
-    for (it.toLast(); it.current(); --it) {
-        int result = it.current()->unapply();
-        if (result != EditResultOK)
-            return result;
-    }
-
-    return EditResultOK;
-}
-
-int EditCommand::reapply()
-{
-    assert(m_steps.count() > 0);
-    
-    QPtrListIterator<EditStep> it(m_steps);
-    for (; it.current(); ++it) {
-        int result = it.current()->reapply();
-        if (result != EditResultOK)
-            return result;
-    }
-
-    return EditResultOK;
+    ASSERT(document());
+    ASSERT(document()->part());
+    return document()->part()->selection();
 }
 
 //------------------------------------------------------------------------------------------
@@ -849,22 +881,18 @@ bool InputTextCommand::isSpace() const
     return m_text.length() == 1 && (m_text[0] == ' ');
 }
 
-int InputTextCommand::apply()
+void InputTextCommand::apply()
 {
-    KHTMLPart *part = document()->part();
-    assert(part);
+    KHTMLSelection selection = startingSelection();
 
-    KHTMLSelection selection = part->selection();
     if (!selection.startNode()->isTextNode())
-        return EditResultFailed;
-
-    EditStep *step;
+        return;
 
     // Delete the current selection
     if (selection.state() == KHTMLSelection::RANGE) {
-        step = new DeleteSelectionStep(document());
-        APPLY_STEP(step);
+        deleteSelection();
     }
+    selection = currentSelection();
     
     TextImpl *textNode = static_cast<TextImpl *>(selection.startNode());
     
@@ -876,53 +904,30 @@ int InputTextCommand::apply()
         bool atEnd = selection.startOffset() == textNode->renderer()->caretMaxOffset();
         if (atStart) {
             // Set the cursor at the beginning of text node now following the new BR.
-            step = new InsertNodeBeforeStep(document(), breakNode, textNode);
-            APPLY_STEP(step);
-
-            step = new SetSelectionStep(document(), textNode, 0);
-            APPLY_STEP(step);
+            insertNodeBefore(breakNode, textNode);
+            moveSelectionTo(textNode, 0);
         }
         else if (atEnd) {
-            if (textNode->parentNode()->lastChild() == textNode) {
-                step = new AppendNodeStep(document(), textNode->parentNode(), breakNode);
-                APPLY_STEP(step);
-            }
-            else {
-                step = new InsertNodeBeforeStep(document(), breakNode, textNode->nextSibling());
-                APPLY_STEP(step);
-            }
+            insertNodeAfter(breakNode, textNode);
             // Set the cursor at the beginning of the the BR.
-            step = new SetSelectionStep(document(), selection.nextCharacterPosition());
-            APPLY_STEP(step);
+            moveSelectionTo(selection.nextCharacterPosition());
         }
         else {
             TextImpl *textBeforeNode = document()->createTextNode(textNode->substringData(0, selection.startOffset(), exceptionCode));
-            step = new DeleteTextStep(document(), textNode, 0, selection.startOffset());
-            APPLY_STEP(step);
-
-            step = new InsertNodeBeforeStep(document(), textBeforeNode, textNode);
-            APPLY_STEP(step);
-
-            step = new InsertNodeBeforeStep(document(), breakNode, textNode);
-            APPLY_STEP(step);
-
+            deleteText(textNode, 0, selection.startOffset());
+            insertNodeBefore(textBeforeNode, textNode);
+            insertNodeBefore(breakNode, textNode);
             textBeforeNode->deref();
             // Set the cursor at the beginning of the node after the BR.
-            step = new SetSelectionStep(document(), textNode, 0);
-            APPLY_STEP(step);
+            moveSelectionTo(textNode, 0);
         }
         
         breakNode->deref();
     }
     else {
-        step = new InsertTextStep(document(), textNode, selection.startOffset(), text());
-        APPLY_STEP(step);
-
-        step = new SetSelectionStep(document(), selection.startNode(), selection.startOffset() + text().length());
-        APPLY_STEP(step);
+        insertText(textNode, selection.startOffset(), text());
+        moveSelectionTo(selection.startNode(), selection.startOffset() + text().length());
     }
-
-    return EditResultOK;
 }
 
 //------------------------------------------------------------------------------------------
@@ -933,44 +938,37 @@ DeleteTextCommand::DeleteTextCommand(DocumentImpl *document)
 {
 }
 
-int DeleteTextCommand::apply()
+void DeleteTextCommand::apply()
 {
     KHTMLPart *part = document()->part();
-    assert(part);
+    ASSERT(part);
 
     KHTMLSelection selection = part->selection();
-    EditStep *step;
+    ASSERT(!selection.isEmpty());
 
     // Delete the current selection
     if (selection.state() == KHTMLSelection::RANGE) {
-        step = new DeleteSelectionStep(document());
-        APPLY_STEP(step);
-        return EditResultOK;
+        deleteSelection();
+        return;
     }
 
-    if (!selection.startNode())
-        return EditResultFailed;
-
     NodeImpl *caretNode = selection.startNode();
 
     if (caretNode->isTextNode()) {
-        int exceptionCode;
-
         // Check if we can delete character at cursor
         int offset = selection.startOffset() - 1;
-        if (offset >= 0) {
+        if (offset >= caretNode->caretMinOffset()) {
             TextImpl *textNode = static_cast<TextImpl *>(caretNode);
-            textNode->deleteData(offset, 1, exceptionCode);
-            selection.moveTo(textNode, offset);
-            return true;
+            deleteText(textNode, offset, 1);
+            moveSelectionTo(textNode, offset);
+            return;
         }
         
         // Check if previous sibling is a BR element
         NodeImpl *previousSibling = caretNode->previousSibling();
         if (previousSibling->renderer() && previousSibling->renderer()->isBR()) {
-            caretNode->parentNode()->removeChild(previousSibling, exceptionCode);
-            // EDIT FIXME: adjust selection position
-            return true;
+            removeNode(previousSibling);
+            return;
         }
         
         // Check if previous leaf node is a text node
@@ -978,11 +976,9 @@ int DeleteTextCommand::apply()
         if (previousLeafNode->isTextNode()) {
             TextImpl *textNode = static_cast<TextImpl *>(previousLeafNode);
             offset = previousLeafNode->caretMaxOffset() - 1;
-            textNode->deleteData(offset, 1, exceptionCode);
-            selection.moveTo(textNode, offset);
-            return true;
+            deleteText(textNode, offset, 1);
+            moveSelectionTo(textNode, offset);
+            return;
         }
     }
-
-    return false;
 }
diff --git a/WebCore/khtml/editing/htmlediting.h b/WebCore/khtml/editing/htmlediting.h
index 4305b31..ffffd90 100644
--- a/WebCore/khtml/editing/htmlediting.h
+++ b/WebCore/khtml/editing/htmlediting.h
@@ -27,7 +27,6 @@
 #define __htmlediting_h__
 
 #include <khtml_selection.h>
-#include <dom_doc.h>
 #include <dom_position.h>
 #include <dom_string.h>
 
@@ -36,7 +35,6 @@
 class KHTMLSelection;
 
 namespace DOM {
-    class DocumentFragment;
     class DocumentImpl;
     class DOMPosition;
     class DOMString;
@@ -66,17 +64,24 @@ public:
 	
     enum EditStepState { NOT_APPLIED, APPLIED };
     
-	virtual int apply();	
-	virtual int unapply();
-	virtual int reapply();
-    
+	virtual void apply() = 0;	
+	virtual void unapply() = 0;
+	virtual void reapply();  // calls apply()
+        
     DOM::DocumentImpl * const document() const { return m_document; }
     EditStepState state() const { return m_state; }
 
     const KHTMLSelection &startingSelection() const { return m_startingSelection; }
     const KHTMLSelection &endingSelection() const { return m_endingSelection; }
-
+    
 protected:
+    void beginApply();
+    void endApply();
+    void beginUnapply();
+    void endUnapply();
+    void beginReapply();
+    void endReapply();
+
     void setStartingSelection(const KHTMLSelection &s) { m_startingSelection = s; }
     void setEndingSelection(const KHTMLSelection &s) { m_endingSelection = s; }
 
@@ -93,10 +98,29 @@ public:
 	CompositeEditStep(DOM::DocumentImpl *);
 	virtual ~CompositeEditStep();
 	
-	virtual int unapply();
-	virtual int reapply();
+	virtual void apply() = 0;	
+	virtual void unapply();
+	virtual void reapply();
     
 protected:
+    //
+    // sugary-sweet convenience functions to help create and apply edit steps
+    //
+    void applyStep(EditStep *step);
+    void insertNodeBefore(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
+    void insertNodeAfter(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
+    void appendNode(DOM::NodeImpl *parent, DOM::NodeImpl *appendChild);
+    void removeNode(DOM::NodeImpl *removeChild);
+    void splitTextNode(DOM::TextImpl *text, long offset);
+    void joinTextNodes(DOM::TextImpl *text1, DOM::TextImpl *text2);
+    void insertText(DOM::TextImpl *node, long offset, const DOM::DOMString &text);
+    void deleteText(DOM::TextImpl *node, long offset, long count);
+    void moveSelectionTo(const KHTMLSelection &selection);
+	void moveSelectionTo(DOM::NodeImpl *, long);
+	void moveSelectionTo(const DOM::DOMPosition &);
+    void deleteSelection();
+    void deleteSelection(const KHTMLSelection &selection);
+
     QPtrList<EditStep> m_steps;
 };
 
@@ -106,8 +130,8 @@ public:
     InsertNodeBeforeStep(DOM::DocumentImpl *, DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
 	virtual ~InsertNodeBeforeStep();
 
-	virtual int apply();
-	virtual int unapply();
+	virtual void apply();
+	virtual void unapply();
 
 private:
     DOM::NodeImpl *m_insertChild;
@@ -120,8 +144,8 @@ public:
     AppendNodeStep(DOM::DocumentImpl *, DOM::NodeImpl *parent, DOM::NodeImpl *appendChild);
 	virtual ~AppendNodeStep();
 
-	virtual int apply();
-	virtual int unapply();
+	virtual void apply();
+	virtual void unapply();
 
 private:
     DOM::NodeImpl *m_parent;    
@@ -134,8 +158,8 @@ public:
 	RemoveNodeStep(DOM::DocumentImpl *, DOM::NodeImpl *);
 	virtual ~RemoveNodeStep();
 	
-	virtual int apply();
-	virtual int unapply();
+	virtual void apply();
+	virtual void unapply();
 
 private:
     DOM::NodeImpl *m_parent;    
@@ -153,8 +177,8 @@ public:
 	virtual ~ModifyTextNodeStep();
 	
 protected:
-    int splitTextNode();
-    int joinTextNodes();
+    void splitTextNode();
+    void joinTextNodes();
 
     virtual EditStepState joinState() = 0;
     virtual EditStepState splitState() = 0;
@@ -170,8 +194,8 @@ public:
 	SplitTextNodeStep(DOM::DocumentImpl *, DOM::TextImpl *, long);
 	virtual ~SplitTextNodeStep();
 	
-	virtual int apply();
-	virtual int unapply();
+	virtual void apply();
+	virtual void unapply();
 
     virtual EditStepState joinState() { return APPLIED; }
     virtual EditStepState splitState() { return NOT_APPLIED; }
@@ -183,8 +207,8 @@ public:
 	JoinTextNodesStep(DOM::DocumentImpl *, DOM::TextImpl *, DOM::TextImpl *);
 	virtual ~JoinTextNodesStep();
 	
-	virtual int apply();
-	virtual int unapply();
+	virtual void apply();
+	virtual void unapply();
 
     virtual EditStepState joinState() { return NOT_APPLIED; }
     virtual EditStepState splitState() { return APPLIED; }
@@ -196,8 +220,8 @@ public:
 	InsertTextStep(DOM::DocumentImpl *document, DOM::TextImpl *, long, const DOM::DOMString &);
 	virtual ~InsertTextStep();
 	
-	virtual int apply();
-	virtual int unapply();
+	virtual void apply();
+	virtual void unapply();
 
 private:
     DOM::TextImpl *m_node;
@@ -211,8 +235,8 @@ public:
 	DeleteTextStep(DOM::DocumentImpl *document, DOM::TextImpl *, long offset, long count);
 	virtual ~DeleteTextStep();
 	
-	virtual int apply();
-	virtual int unapply();
+	virtual void apply();
+	virtual void unapply();
 
 private:
     DOM::TextImpl *m_node;
@@ -221,16 +245,16 @@ private:
     DOM::DOMString m_text;
 };
 
-class SetSelectionStep : public EditStep
+class MoveSelectionToStep : public EditStep
 {
 public:
-	SetSelectionStep(DOM::DocumentImpl *document, const KHTMLSelection &selection);
-	SetSelectionStep(DOM::DocumentImpl *document, DOM::NodeImpl *, long);
-	SetSelectionStep(DOM::DocumentImpl *document, const DOM::DOMPosition &);
-	virtual ~SetSelectionStep() {};
+	MoveSelectionToStep(DOM::DocumentImpl *document, const KHTMLSelection &selection);
+	MoveSelectionToStep(DOM::DocumentImpl *document, DOM::NodeImpl *, long);
+	MoveSelectionToStep(DOM::DocumentImpl *document, const DOM::DOMPosition &);
+	virtual ~MoveSelectionToStep() {};
 	
-	virtual int apply();
-	virtual int unapply();
+	virtual void apply();
+	virtual void unapply();
 };
 
 class DeleteSelectionStep : public CompositeEditStep
@@ -240,57 +264,35 @@ public:
 	DeleteSelectionStep(DOM::DocumentImpl *document, const KHTMLSelection &);
 	virtual ~DeleteSelectionStep();
 	
-	virtual int apply();
-};
-
-#if 0
-
-class ClearSelectionStep : public EditStep
-{
-public:
-	ClearSelectionStep(DOM::DocumentImpl *document) : EditStep(document) {};
-	virtual ~ClearSelectionStep() {};
-	
-	virtual int apply() { return EditResultOK; }	
-	virtual int unapply() { return EditResultOK; }
+	virtual void apply();
 };
 
-#endif
-
 //------------------------------------------------------------------------------------------
 // EditCommand
 
-class EditCommand
+class EditCommand : public CompositeEditStep
 {
 public:    
     EditCommand(DOM::DocumentImpl *document);
     virtual ~EditCommand();
 
-    DOM::DocumentImpl *document() const { return m_document; }
-    const KHTMLSelection &selection() const;
+    const KHTMLSelection &currentSelection() const;
 
-    virtual int apply() = 0;
-    int unapply();
-    int reapply();
+    virtual void apply() = 0;
 
     int cookie() const { return m_cookie; }
-
-protected:
-    QPtrList<EditStep> m_steps;
     
 private:
     int m_cookie;
-    DOM::DocumentImpl *m_document;
 };
 
-
 class InputTextCommand : public EditCommand
 {
 public:
     InputTextCommand(DOM::DocumentImpl *document, const DOM::DOMString &text);
     virtual ~InputTextCommand() {};
     
-    virtual int apply();
+    virtual void apply();
 
     DOM::DOMString text() const { return m_text; }
     bool isLineBreak() const;
@@ -306,7 +308,7 @@ public:
     DeleteTextCommand(DOM::DocumentImpl *document);
     virtual ~DeleteTextCommand() {};
     
-    virtual int apply();
+    virtual void apply();
 };
 
 }; // end namespace khtml
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index a8c15b2..e808a65 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -5049,12 +5049,9 @@ bool KHTMLPart::isEditingAtCaret() const
     return false;
 }
 
-int KHTMLPart::applyCommand(EditCommand *cmd)
+void KHTMLPart::applyCommand(EditCommand *cmd)
 {
-    int result = cmd->apply();
-    if (result) {
-        return result;
-    }
+    cmd->apply();
     
     // clear redo commands
     QPtrListIterator<EditCommand> it(d->m_redoEditCommands);
@@ -5067,36 +5064,33 @@ int KHTMLPart::applyCommand(EditCommand *cmd)
 #if APPLE_CHANGES
     KWQ(this)->registerCommandForUndo(cmd->cookie());
 #endif
-
-    return khtml::EditResultOK;
 }
 
 #if APPLE_CHANGES
-int KHTMLPart::undoRedoEditing(int cookie)
+void KHTMLPart::undoRedoEditing(int cookie)
 {
     EditCommand *undoCommand = d->m_undoEditCommands.last();
-    if (undoCommand && undoCommand->cookie() == cookie)
-        return undoEditing();
+    if (undoCommand && undoCommand->cookie() == cookie) {
+        undoEditing();
+        return;
+    }
     
     EditCommand *redoCommand = d->m_redoEditCommands.last();
-    if (redoCommand && redoCommand->cookie() == cookie)
-        return redoEditing();
+    if (redoCommand && redoCommand->cookie() == cookie) {
+        redoEditing();
+        return;
+    }
 
-    return khtml::EditResultFailed;
+    // should not reach this code
+    assert(0);
 }
 #endif
 
-int KHTMLPart::undoEditing()
+void KHTMLPart::undoEditing()
 {
     EditCommand *cmd = d->m_undoEditCommands.last();
-    if (!cmd) {
-        return khtml::EditResultFailed;
-    }
 
-    int result = cmd->unapply();
-    if (result) {
-        return result;
-    }
+    cmd->unapply();
 
     d->m_undoEditCommands.removeLast();
     d->m_redoEditCommands.append(cmd);
@@ -5104,21 +5098,13 @@ int KHTMLPart::undoEditing()
 #if APPLE_CHANGES
     KWQ(this)->registerCommandForUndo(cmd->cookie());
 #endif
-
-    return khtml::EditResultOK;
 }
 
-int KHTMLPart::redoEditing()
+void KHTMLPart::redoEditing()
 {
     EditCommand *cmd = d->m_redoEditCommands.last();
-    if (!cmd) {
-        return khtml::EditResultFailed;
-    }
 
-    int result = cmd->reapply();
-    if (result) {
-        return result;
-    }
+    cmd->reapply();
 
     d->m_redoEditCommands.removeLast();
     d->m_undoEditCommands.append(cmd);
@@ -5126,8 +5112,6 @@ int KHTMLPart::redoEditing()
 #if APPLE_CHANGES
     KWQ(this)->registerCommandForUndo(cmd->cookie());
 #endif
-
-    return khtml::EditResultOK;
 }
 
 
diff --git a/WebCore/khtml/khtml_part.h b/WebCore/khtml/khtml_part.h
index f10dc5f..5f305d5 100644
--- a/WebCore/khtml/khtml_part.h
+++ b/WebCore/khtml/khtml_part.h
@@ -620,7 +620,7 @@ public:
   /**
    * Applies the give edit command.
    */
-  int applyCommand(khtml::EditCommand *);
+  void applyCommand(khtml::EditCommand *);
 
 #if APPLE_CHANGES
   /**
@@ -629,18 +629,18 @@ public:
    * matching the top item against the cookie passed in.
    * A hack, but it helps us to hook into Cocoa undo/redo.
    */
-  int undoRedoEditing(int cookie);
+  void undoRedoEditing(int cookie);
 #endif
 
   /**
    * Performs an undo of the edit.
    */
-  int undoEditing();
+  void undoEditing();
 
   /**
    * Performs a redo of the edit.
    */
-  int redoEditing();
+  void redoEditing();
 
   /**
    * Convenience method to show the document's view.
diff --git a/WebCore/khtml/xml/dom_elementimpl.cpp b/WebCore/khtml/xml/dom_elementimpl.cpp
index 00c6b28..a2c119c 100644
--- a/WebCore/khtml/xml/dom_elementimpl.cpp
+++ b/WebCore/khtml/xml/dom_elementimpl.cpp
@@ -410,11 +410,10 @@ void ElementImpl::defaultEventHandler(EventImpl *evt)
         }
         if (cmd) {
             KHTMLPart *part = getDocument()->part();
-            int result = EditResultNoActionTaken;
-            if (part)
-                result = part->applyCommand(cmd);
-            if (result == EditResultOK)
+            if (part) {
+                part->applyCommand(cmd);
                 evt->setDefaultHandled();
+            }
         }
     }
     NodeBaseImpl::defaultEventHandler(evt);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list