Bug 1015433: Backout bug 828169 for regressing text editing
authorDavid Zbarsky <dzbarsky@gmail.com>
Wed, 04 Jun 2014 23:51:34 -0400
changeset 207048 e7b0ccbaa5a45a93ed461af811a0bf5fe2ef9818
parent 207047 ccc885c8f4ac40d3f1de740d4f8d98af9fa167c2
child 207049 8406a2b981c58de5a466dbb482a4f4c5ebd70f11
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1015433, 828169
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1015433: Backout bug 828169 for regressing text editing
editor/libeditor/base/ChangeAttributeTxn.cpp
editor/libeditor/base/ChangeAttributeTxn.h
editor/libeditor/base/CreateElementTxn.cpp
editor/libeditor/base/CreateElementTxn.h
editor/libeditor/base/InsertElementTxn.cpp
editor/libeditor/base/InsertElementTxn.h
editor/libeditor/base/JoinElementTxn.cpp
editor/libeditor/base/JoinElementTxn.h
editor/libeditor/base/SplitElementTxn.cpp
editor/libeditor/base/SplitElementTxn.h
editor/libeditor/base/nsEditor.cpp
editor/libeditor/base/nsEditor.h
--- a/editor/libeditor/base/ChangeAttributeTxn.cpp
+++ b/editor/libeditor/base/ChangeAttributeTxn.cpp
@@ -2,105 +2,99 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ChangeAttributeTxn.h"
 #include "nsAString.h"
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsError.h"                    // for NS_ERROR_NOT_INITIALIZED, etc
-#include "nsEditor.h"                   // for nsEditor
+#include "nsIDOMElement.h"              // for nsIDOMElement
+#include "nsIEditor.h"                  // for nsIEditor
 #include "nsString.h"                   // for nsString
-#include "mozilla/dom/Element.h"
-
-using namespace mozilla;
 
 ChangeAttributeTxn::ChangeAttributeTxn()
   : EditTxn()
 {
 }
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(ChangeAttributeTxn, EditTxn,
                                    mElement)
 
 NS_IMPL_ADDREF_INHERITED(ChangeAttributeTxn, EditTxn)
 NS_IMPL_RELEASE_INHERITED(ChangeAttributeTxn, EditTxn)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ChangeAttributeTxn)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
-NS_IMETHODIMP ChangeAttributeTxn::Init(nsEditor      *aEditor,
-                                       dom::Element *aElement,
+NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor      *aEditor,
+                                       nsIDOMElement  *aElement,
                                        const nsAString& aAttribute,
                                        const nsAString& aValue,
                                        bool aRemoveAttribute)
 {
   NS_ASSERTION(aEditor && aElement, "bad arg");
   if (!aEditor || !aElement) { return NS_ERROR_NULL_POINTER; }
 
   mEditor = aEditor;
-  mElement = aElement;
+  mElement = do_QueryInterface(aElement);
   mAttribute = aAttribute;
   mValue = aValue;
   mRemoveAttribute = aRemoveAttribute;
   mAttributeWasSet=false;
   mUndoValue.Truncate();
   return NS_OK;
 }
 
 NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void)
 {
   NS_ASSERTION(mEditor && mElement, "bad state");
   if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
 
-  nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mElement);
   // need to get the current value of the attribute and save it, and set mAttributeWasSet
-  nsresult result = mEditor->GetAttributeValue(element, mAttribute, mUndoValue, &mAttributeWasSet);
-  NS_ENSURE_SUCCESS(result, result);
-
+  nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, &mAttributeWasSet);
   // XXX: hack until attribute-was-set code is implemented
   if (!mUndoValue.IsEmpty())
     mAttributeWasSet = true;
   // XXX: end hack
-
-  ErrorResult rv;
+  
   // now set the attribute to the new value
   if (!mRemoveAttribute)
-    mElement->SetAttribute(mAttribute, mValue, rv);
+    result = mElement->SetAttribute(mAttribute, mValue);
   else
-    mElement->RemoveAttribute(mAttribute, rv);
+    result = mElement->RemoveAttribute(mAttribute);
 
-  return rv.ErrorCode();
+  return result;
 }
 
 NS_IMETHODIMP ChangeAttributeTxn::UndoTransaction(void)
 {
   NS_ASSERTION(mEditor && mElement, "bad state");
   if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
 
-  ErrorResult rv;
+  nsresult result;
   if (mAttributeWasSet)
-    mElement->SetAttribute(mAttribute, mUndoValue, rv);
+    result = mElement->SetAttribute(mAttribute, mUndoValue);
   else
-    mElement->RemoveAttribute(mAttribute, rv);
+    result = mElement->RemoveAttribute(mAttribute);
 
-  return rv.ErrorCode();
+  return result;
 }
 
 NS_IMETHODIMP ChangeAttributeTxn::RedoTransaction(void)
 {
   NS_ASSERTION(mEditor && mElement, "bad state");
   if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
 
-  ErrorResult rv;
+  nsresult result;
   if (!mRemoveAttribute)
-    mElement->SetAttribute(mAttribute, mValue, rv);
+    result = mElement->SetAttribute(mAttribute, mValue);
   else
-    mElement->RemoveAttribute(mAttribute, rv);
+    result = mElement->RemoveAttribute(mAttribute);
 
-  return rv.ErrorCode();
+  return result;
 }
 
 NS_IMETHODIMP ChangeAttributeTxn::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("ChangeAttributeTxn: [mRemoveAttribute == ");
 
   if (!mRemoveAttribute)
     aString.AppendLiteral("false] ");
--- a/editor/libeditor/base/ChangeAttributeTxn.h
+++ b/editor/libeditor/base/ChangeAttributeTxn.h
@@ -4,65 +4,60 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef ChangeAttributeTxn_h__
 #define ChangeAttributeTxn_h__
 
 #include "EditTxn.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsIDOMElement.h"
 #include "nsISupportsImpl.h"
 #include "nsString.h"
 #include "nscore.h"
 
-class nsEditor;
-
-namespace mozilla {
-namespace dom {
-class Element;
-}
-}
+class nsIEditor;
 
 /**
- * A transaction that changes an attribute of a content node.
+ * A transaction that changes an attribute of a content node. 
  * This transaction covers add, remove, and change attribute.
  */
 class ChangeAttributeTxn : public EditTxn
 {
 public:
   /** Initialize the transaction.
     * @param aEditor the object providing core editing operations
     * @param aNode   the node whose attribute will be changed
     * @param aAttribute the name of the attribute to change
     * @param aValue     the new value for aAttribute, if aRemoveAttribute is false
     * @param aRemoveAttribute if true, remove aAttribute from aNode
     */
-  NS_IMETHOD Init(nsEditor      *aEditor,
-                  mozilla::dom::Element *aNode,
+  NS_IMETHOD Init(nsIEditor      *aEditor,
+                  nsIDOMElement  *aNode,
                   const nsAString& aAttribute,
                   const nsAString& aValue,
                   bool aRemoveAttribute);
 
   ChangeAttributeTxn();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeAttributeTxn, EditTxn)
 
   NS_DECL_EDITTXN
 
   NS_IMETHOD RedoTransaction();
 
 protected:
 
   /** the editor that created this transaction */
-  nsEditor*  mEditor;
-
+  nsIEditor*  mEditor;
+  
   /** the element to operate upon */
-  nsCOMPtr<mozilla::dom::Element> mElement;
-
+  nsCOMPtr<nsIDOMElement> mElement;
+  
   /** the attribute to change */
   nsString mAttribute;
 
   /** the value to set the attribute to (ignored if mRemoveAttribute==true) */
   nsString mValue;
 
   /** the value to set the attribute to for undo */
   nsString mUndoValue;
--- a/editor/libeditor/base/CreateElementTxn.cpp
+++ b/editor/libeditor/base/CreateElementTxn.cpp
@@ -8,16 +8,17 @@
 #include "CreateElementTxn.h"
 #include "mozilla/dom/Element.h"
 #include "nsAlgorithm.h"
 #include "nsDebug.h"
 #include "nsEditor.h"
 #include "nsError.h"
 #include "nsIContent.h"
 #include "nsIDOMCharacterData.h"
+#include "nsIEditor.h"
 #include "nsINode.h"
 #include "nsISelection.h"
 #include "nsISupportsUtils.h"
 #include "nsMemory.h"
 #include "nsReadableUtils.h"
 #include "nsStringFwd.h"
 #include "nsString.h"
 #include "nsAString.h"
@@ -37,17 +38,17 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(Creat
                                    mRefNode)
 
 NS_IMPL_ADDREF_INHERITED(CreateElementTxn, EditTxn)
 NS_IMPL_RELEASE_INHERITED(CreateElementTxn, EditTxn)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CreateElementTxn)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 NS_IMETHODIMP CreateElementTxn::Init(nsEditor      *aEditor,
                                      const nsAString &aTag,
-                                     nsINode       *aParent,
+                                     nsIDOMNode     *aParent,
                                      uint32_t        aOffsetInParent)
 {
   NS_ASSERTION(aEditor&&aParent, "null args");
   if (!aEditor || !aParent) { return NS_ERROR_NULL_POINTER; }
 
   mEditor = aEditor;
   mTag = aTag;
   mParent = do_QueryInterface(aParent);
@@ -61,45 +62,49 @@ NS_IMETHODIMP CreateElementTxn::DoTransa
   NS_ASSERTION(mEditor && mParent, "bad state");
   NS_ENSURE_TRUE(mEditor && mParent, NS_ERROR_NOT_INITIALIZED);
 
   ErrorResult rv;
   nsCOMPtr<Element> newContent = mEditor->CreateHTMLContent(mTag, rv);
   NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
   NS_ENSURE_STATE(newContent);
 
-  mNewNode = newContent;
+  mNewNode = newContent->AsDOMNode();
   // Try to insert formatting whitespace for the new node:
   mEditor->MarkNodeDirty(mNewNode);
 
   // insert the new node
   if (CreateElementTxn::eAppend == int32_t(mOffsetInParent)) {
-    mParent->AppendChild(*mNewNode, rv);
-    return rv.ErrorCode();
+    nsCOMPtr<nsIDOMNode> resultNode;
+    return mParent->AppendChild(mNewNode, getter_AddRefs(resultNode));
   }
 
+  nsCOMPtr<nsINode> parent = do_QueryInterface(mParent);
+  NS_ENSURE_STATE(parent);
 
-  mOffsetInParent = std::min(mOffsetInParent, mParent->GetChildCount());
+  mOffsetInParent = std::min(mOffsetInParent, parent->GetChildCount());
 
   // note, it's ok for mRefNode to be null.  that means append
-  mRefNode = mParent->GetChildAt(mOffsetInParent);
+  nsIContent* refNode = parent->GetChildAt(mOffsetInParent);
+  mRefNode = refNode ? refNode->AsDOMNode() : nullptr;
 
-  mParent->InsertBefore(*mNewNode, mRefNode, rv);
-  NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
+  nsCOMPtr<nsIDOMNode> resultNode;
+  nsresult result = mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode));
+  NS_ENSURE_SUCCESS(result, result); 
 
   // only set selection to insertion point if editor gives permission
   bool bAdjustSelection;
   mEditor->ShouldTxnSetSelection(&bAdjustSelection);
   if (!bAdjustSelection) {
     // do nothing - dom range gravity will adjust selection
     return NS_OK;
   }
 
   nsCOMPtr<nsISelection> selection;
-  nsresult result = mEditor->GetSelection(getter_AddRefs(selection));
+  result = mEditor->GetSelection(getter_AddRefs(selection));
   NS_ENSURE_SUCCESS(result, result);
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIContent> parentContent = do_QueryInterface(mParent);
   NS_ENSURE_STATE(parentContent);
 
   result = selection->CollapseNative(parentContent,
                                      parentContent->IndexOf(newContent) + 1);
@@ -107,46 +112,44 @@ NS_IMETHODIMP CreateElementTxn::DoTransa
   return result;
 }
 
 NS_IMETHODIMP CreateElementTxn::UndoTransaction(void)
 {
   NS_ASSERTION(mEditor && mParent, "bad state");
   NS_ENSURE_TRUE(mEditor && mParent, NS_ERROR_NOT_INITIALIZED);
 
-  ErrorResult rv;
-  mParent->RemoveChild(*mNewNode, rv);
-  return rv.ErrorCode();
+  nsCOMPtr<nsIDOMNode> resultNode;
+  return mParent->RemoveChild(mNewNode, getter_AddRefs(resultNode));
 }
 
 NS_IMETHODIMP CreateElementTxn::RedoTransaction(void)
 {
   NS_ASSERTION(mEditor && mParent, "bad state");
   NS_ENSURE_TRUE(mEditor && mParent, NS_ERROR_NOT_INITIALIZED);
 
   // first, reset mNewNode so it has no attributes or content
   nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(mNewNode);
   if (nodeAsText)
   {
     nodeAsText->SetData(EmptyString());
   }
-
+  
   // now, reinsert mNewNode
-  ErrorResult rv;
-  mParent->InsertBefore(*mNewNode, mRefNode, rv);
-  return rv.ErrorCode();
+  nsCOMPtr<nsIDOMNode> resultNode;
+  return mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode));
 }
 
 NS_IMETHODIMP CreateElementTxn::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("CreateElementTxn: ");
   aString += mTag;
   return NS_OK;
 }
 
-NS_IMETHODIMP CreateElementTxn::GetNewNode(nsINode **aNewNode)
+NS_IMETHODIMP CreateElementTxn::GetNewNode(nsIDOMNode **aNewNode)
 {
   NS_ENSURE_TRUE(aNewNode, NS_ERROR_NULL_POINTER);
   NS_ENSURE_TRUE(mNewNode, NS_ERROR_NOT_INITIALIZED);
   *aNewNode = mNewNode;
   NS_ADDREF(*aNewNode);
   return NS_OK;
 }
--- a/editor/libeditor/base/CreateElementTxn.h
+++ b/editor/libeditor/base/CreateElementTxn.h
@@ -4,22 +4,22 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef CreateElementTxn_h__
 #define CreateElementTxn_h__
 
 #include "EditTxn.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsIDOMNode.h"
 #include "nsISupportsImpl.h"
 #include "nsString.h"
 #include "nscore.h"
 
 class nsEditor;
-class nsINode;
 
 /**
  * A transaction that creates a new node in the content tree.
  */
 class CreateElementTxn : public EditTxn
 {
 public:
   enum { eAppend=-1 };
@@ -28,44 +28,44 @@ public:
     * @param aEditor the provider of basic editing functionality
     * @param aTag    the tag (P, HR, TABLE, etc.) for the new element
     * @param aParent the node into which the new element will be inserted
     * @param aOffsetInParent the location in aParent to insert the new element
     *                        if eAppend, the new element is appended as the last child
     */
   NS_IMETHOD Init(nsEditor *aEditor,
                   const nsAString& aTag,
-                  nsINode *aParent,
+                  nsIDOMNode *aParent,
                   uint32_t aOffsetInParent);
 
   CreateElementTxn();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CreateElementTxn, EditTxn)
 
   NS_DECL_EDITTXN
 
   NS_IMETHOD RedoTransaction();
 
-  NS_IMETHOD GetNewNode(nsINode **aNewNode);
+  NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
 
 protected:
-
+  
   /** the document into which the new node will be inserted */
   nsEditor* mEditor;
-
+  
   /** the tag (mapping to object type) for the new element */
   nsString mTag;
 
   /** the node into which the new node will be inserted */
-  nsCOMPtr<nsINode> mParent;
+  nsCOMPtr<nsIDOMNode> mParent;
 
   /** the index in mParent for the new node */
   uint32_t mOffsetInParent;
 
   /** the new node to insert */
-  nsCOMPtr<nsINode> mNewNode;
+  nsCOMPtr<nsIDOMNode> mNewNode;  
 
   /** the node we will insert mNewNode before.  We compute this ourselves. */
-  nsCOMPtr<nsINode> mRefNode;
+  nsCOMPtr<nsIDOMNode> mRefNode;
 };
 
 #endif
--- a/editor/libeditor/base/InsertElementTxn.cpp
+++ b/editor/libeditor/base/InsertElementTxn.cpp
@@ -28,20 +28,20 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(Inser
                                    mNode,
                                    mParent)
 
 NS_IMPL_ADDREF_INHERITED(InsertElementTxn, EditTxn)
 NS_IMPL_RELEASE_INHERITED(InsertElementTxn, EditTxn)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InsertElementTxn)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
-NS_IMETHODIMP InsertElementTxn::Init(nsINode *aNode,
-                                     nsINode *aParent,
+NS_IMETHODIMP InsertElementTxn::Init(nsIDOMNode *aNode,
+                                     nsIDOMNode *aParent,
                                      int32_t     aOffset,
-                                     nsEditor  *aEditor)
+                                     nsIEditor  *aEditor)
 {
   NS_ASSERTION(aNode && aParent && aEditor, "bad arg");
   NS_ENSURE_TRUE(aNode && aParent && aEditor, NS_ERROR_NULL_POINTER);
 
   mNode = do_QueryInterface(aNode);
   mParent = do_QueryInterface(aParent);
   mOffset = aOffset;
   mEditor = aEditor;
@@ -60,48 +60,49 @@ NS_IMETHODIMP InsertElementTxn::DoTransa
   uint32_t count = parent->GetChildCount();
   if (mOffset > int32_t(count) || mOffset == -1) {
     // -1 is sentinel value meaning "append at end"
     mOffset = count;
   }
 
   // note, it's ok for refContent to be null.  that means append
   nsCOMPtr<nsIContent> refContent = parent->GetChildAt(mOffset);
+  nsCOMPtr<nsIDOMNode> refNode = refContent ? refContent->AsDOMNode() : nullptr;
 
   mEditor->MarkNodeDirty(mNode);
 
-  ErrorResult rv;
-  mParent->InsertBefore(*mNode, refContent, rv);
-  NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
+  nsCOMPtr<nsIDOMNode> resultNode;
+  nsresult result = mParent->InsertBefore(mNode, refNode, getter_AddRefs(resultNode));
+  NS_ENSURE_SUCCESS(result, result);
+  NS_ENSURE_TRUE(resultNode, NS_ERROR_NULL_POINTER);
 
   // only set selection to insertion point if editor gives permission
   bool bAdjustSelection;
   mEditor->ShouldTxnSetSelection(&bAdjustSelection);
   if (bAdjustSelection)
   {
     nsCOMPtr<nsISelection> selection;
-    rv = mEditor->GetSelection(getter_AddRefs(selection));
-    NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
+    result = mEditor->GetSelection(getter_AddRefs(selection));
+    NS_ENSURE_SUCCESS(result, result);
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
     // place the selection just after the inserted element
-    selection->Collapse(mParent->AsDOMNode(), mOffset+1);
+    selection->Collapse(mParent, mOffset+1);
   }
   else
   {
     // do nothing - dom range gravity will adjust selection
   }
-  return NS_OK;
+  return result;
 }
 
 NS_IMETHODIMP InsertElementTxn::UndoTransaction(void)
 {
   NS_ENSURE_TRUE(mNode && mParent, NS_ERROR_NOT_INITIALIZED);
 
-  ErrorResult rv;
-  mParent->RemoveChild(*mNode, rv);
-  return rv.ErrorCode();
+  nsCOMPtr<nsIDOMNode> resultNode;
+  return mParent->RemoveChild(mNode, getter_AddRefs(resultNode));
 }
 
 NS_IMETHODIMP InsertElementTxn::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("InsertElementTxn");
   return NS_OK;
 }
--- a/editor/libeditor/base/InsertElementTxn.h
+++ b/editor/libeditor/base/InsertElementTxn.h
@@ -4,53 +4,53 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef InsertElementTxn_h__
 #define InsertElementTxn_h__
 
 #include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
 #include "nsCOMPtr.h"                   // for nsCOMPtr
 #include "nsCycleCollectionParticipant.h"
+#include "nsIDOMNode.h"                 // for nsIDOMNode
 #include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED
 #include "nscore.h"                     // for NS_IMETHOD
 
-class nsEditor;
-class nsINode;
+class nsIEditor;
 
 /**
  * A transaction that inserts a single element
  */
 class InsertElementTxn : public EditTxn
 {
 public:
   /** initialize the transaction.
     * @param aNode   the node to insert
     * @param aParent the node to insert into
     * @param aOffset the offset in aParent to insert aNode
     */
-  NS_IMETHOD Init(nsINode *aNode,
-                  nsINode *aParent,
+  NS_IMETHOD Init(nsIDOMNode *aNode,
+                  nsIDOMNode *aParent,
                   int32_t     aOffset,
-                  nsEditor  *aEditor);
+                  nsIEditor  *aEditor);
 
   InsertElementTxn();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertElementTxn, EditTxn)
 
   NS_DECL_EDITTXN
 
 protected:
-
+  
   /** the element to insert */
-  nsCOMPtr<nsINode> mNode;
+  nsCOMPtr<nsIDOMNode> mNode;
 
   /** the node into which the new node will be inserted */
-  nsCOMPtr<nsINode> mParent;
+  nsCOMPtr<nsIDOMNode> mParent;
 
   /** the editor for this transaction */
-  nsEditor*           mEditor;
+  nsIEditor*           mEditor;
 
   /** the index in mParent for the new node */
   int32_t mOffset;
 };
 
 #endif
--- a/editor/libeditor/base/JoinElementTxn.cpp
+++ b/editor/libeditor/base/JoinElementTxn.cpp
@@ -26,85 +26,95 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(JoinE
                                    mLeftNode,
                                    mRightNode,
                                    mParent)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JoinElementTxn)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
 NS_IMETHODIMP JoinElementTxn::Init(nsEditor   *aEditor,
-                                   nsINode *aLeftNode,
-                                   nsINode *aRightNode)
+                                   nsIDOMNode *aLeftNode,
+                                   nsIDOMNode *aRightNode)
 {
   NS_PRECONDITION((aEditor && aLeftNode && aRightNode), "null arg");
   if (!aEditor || !aLeftNode || !aRightNode) { return NS_ERROR_NULL_POINTER; }
   mEditor = aEditor;
-  mLeftNode = aLeftNode;
-  nsCOMPtr<nsINode> leftParent = mLeftNode->GetParentNode();
+  mLeftNode = do_QueryInterface(aLeftNode);
+  nsCOMPtr<nsIDOMNode>leftParent;
+  nsresult result = mLeftNode->GetParentNode(getter_AddRefs(leftParent));
+  NS_ENSURE_SUCCESS(result, result);
   if (!mEditor->IsModifiableNode(leftParent)) {
     return NS_ERROR_FAILURE;
   }
-  mRightNode = aRightNode;
+  mRightNode = do_QueryInterface(aRightNode);
   mOffset = 0;
   return NS_OK;
 }
 
 // After DoTransaction() and RedoTransaction(), the left node is removed from the content tree and right node remains.
 NS_IMETHODIMP JoinElementTxn::DoTransaction(void)
 {
   NS_PRECONDITION((mEditor && mLeftNode && mRightNode), "null arg");
   if (!mEditor || !mLeftNode || !mRightNode) { return NS_ERROR_NOT_INITIALIZED; }
 
   // get the parent node
-  nsCOMPtr<nsINode> leftParent = mLeftNode->GetParentNode();
+  nsCOMPtr<nsINode> leftNode = do_QueryInterface(mLeftNode);
+  nsCOMPtr<nsINode> leftParent = leftNode->GetParentNode();
   NS_ENSURE_TRUE(leftParent, NS_ERROR_NULL_POINTER);
 
   // verify that mLeftNode and mRightNode have the same parent
-  nsCOMPtr<nsINode> rightParent = mRightNode->GetParentNode();
+  nsCOMPtr<nsINode> rightNode = do_QueryInterface(mRightNode);
+  nsCOMPtr<nsINode> rightParent = rightNode->GetParentNode();
   NS_ENSURE_TRUE(rightParent, NS_ERROR_NULL_POINTER);
 
   if (leftParent != rightParent) {
     NS_ASSERTION(false, "2 nodes do not have same parent");
     return NS_ERROR_INVALID_ARG;
   }
 
   // set this instance mParent. 
   // Other methods will see a non-null mParent and know all is well
-  mParent = leftParent;
-  mOffset = mLeftNode->Length();
+  mParent = leftParent->AsDOMNode();
+  mOffset = leftNode->Length();
 
-  return mEditor->JoinNodesImpl(mRightNode, mLeftNode, mParent);
+  nsCOMPtr<nsINode> parent = do_QueryInterface(mParent);
+  return mEditor->JoinNodesImpl(rightNode, leftNode, parent);
 }
 
 //XXX: what if instead of split, we just deleted the unneeded children of mRight
 //     and re-inserted mLeft?
 NS_IMETHODIMP JoinElementTxn::UndoTransaction(void)
 {
   NS_ASSERTION(mRightNode && mLeftNode && mParent, "bad state");
   if (!mRightNode || !mLeftNode || !mParent) { return NS_ERROR_NOT_INITIALIZED; }
   // first, massage the existing node so it is in its post-split state
+  nsresult result;
+  nsCOMPtr<nsIDOMNode>resultNode;
   nsCOMPtr<nsIDOMCharacterData>rightNodeAsText = do_QueryInterface(mRightNode);
-  ErrorResult rv;
   if (rightNodeAsText)
   {
-    rv = rightNodeAsText->DeleteData(0, mOffset);
-    NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
+    result = rightNodeAsText->DeleteData(0, mOffset);
   }
   else
   {
-    for (nsCOMPtr<nsINode> child = mRightNode->GetFirstChild();
-         child;
-         child = child->GetNextSibling())
+    nsCOMPtr<nsIDOMNode>child;
+    result = mRightNode->GetFirstChild(getter_AddRefs(child));
+    nsCOMPtr<nsIDOMNode>nextSibling;
+    uint32_t i;
+    for (i=0; i<mOffset; i++)
     {
-      mLeftNode->AppendChild(*child, rv);
-      NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
+      if (NS_FAILED(result)) {return result;}
+      if (!child) {return NS_ERROR_NULL_POINTER;}
+      child->GetNextSibling(getter_AddRefs(nextSibling));
+      result = mLeftNode->AppendChild(child, getter_AddRefs(resultNode));
+      child = do_QueryInterface(nextSibling);
     }
   }
   // second, re-insert the left node into the tree
-  mParent->InsertBefore(*mLeftNode, mRightNode, rv);
-  return rv.ErrorCode();
+  result = mParent->InsertBefore(mLeftNode, mRightNode, getter_AddRefs(resultNode));
+  return result;
 }
 
 NS_IMETHODIMP JoinElementTxn::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("JoinElementTxn");
   return NS_OK;
 }
--- a/editor/libeditor/base/JoinElementTxn.h
+++ b/editor/libeditor/base/JoinElementTxn.h
@@ -5,59 +5,59 @@
 
 #ifndef JoinElementTxn_h__
 #define JoinElementTxn_h__
 
 #include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
 #include "nsCOMPtr.h"                   // for nsCOMPtr
 #include "nsCycleCollectionParticipant.h"
 #include "nsID.h"                       // for REFNSIID
+#include "nsIDOMNode.h"                 // for nsIDOMNode
 #include "nscore.h"                     // for NS_IMETHOD
 
 class nsEditor;
-class nsINode;
 
 /**
  * A transaction that joins two elements E1 (left node) and E2 (right node)
- * into a single node E.
+ * into a single node E.  
  * The children of E are the children of E1 followed by the children of E2.
  * After DoTransaction() and RedoTransaction(), E1 is removed from the content
  * tree and E2 remains.
  */
 class JoinElementTxn : public EditTxn
 {
 public:
   /** initialize the transaction
     * @param aEditor    the provider of core editing operations
     * @param aLeftNode  the first of two nodes to join
     * @param aRightNode the second of two nodes to join
     */
   NS_IMETHOD Init(nsEditor   *aEditor,
-                  nsINode    *aLeftNode,
-                  nsINode    *aRightNode);
+                  nsIDOMNode *aLeftNode,
+                  nsIDOMNode *aRightNode);
 
   JoinElementTxn();
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinElementTxn, EditTxn)
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
 
   NS_DECL_EDITTXN
 
 protected:
-
-  /** the elements to operate upon.
+  
+  /** the elements to operate upon.  
     * After the merge, mRightNode remains and mLeftNode is removed from the content tree.
     */
-  nsCOMPtr<nsINode> mLeftNode;
-  nsCOMPtr<nsINode> mRightNode;
+  nsCOMPtr<nsIDOMNode> mLeftNode;
+  nsCOMPtr<nsIDOMNode> mRightNode;
 
   /** the offset into mNode where the children of mElement are split (for undo).<BR>
-    * mOffset is the index of the first child in the right node.
+    * mOffset is the index of the first child in the right node. 
     * -1 means the left node had no children.
     */
   uint32_t  mOffset;
 
   /** the parent node containing mLeftNode and mRightNode */
-  nsCOMPtr<nsINode> mParent;
+  nsCOMPtr<nsIDOMNode> mParent;
   nsEditor*  mEditor;
 };
 
 #endif
--- a/editor/libeditor/base/SplitElementTxn.cpp
+++ b/editor/libeditor/base/SplitElementTxn.cpp
@@ -29,17 +29,17 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(Split
                                    mNewLeftNode)
 
 NS_IMPL_ADDREF_INHERITED(SplitElementTxn, EditTxn)
 NS_IMPL_RELEASE_INHERITED(SplitElementTxn, EditTxn)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SplitElementTxn)
 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
 
 NS_IMETHODIMP SplitElementTxn::Init(nsEditor   *aEditor,
-                                    nsINode    *aNode,
+                                    nsIDOMNode *aNode,
                                     int32_t     aOffset)
 {
   NS_ASSERTION(aEditor && aNode, "bad args");
   if (!aEditor || !aNode) { return NS_ERROR_NOT_INITIALIZED; }
 
   mEditor = aEditor;
   mExistingRightNode = do_QueryInterface(aNode);
   mOffset = aOffset;
@@ -47,43 +47,38 @@ NS_IMETHODIMP SplitElementTxn::Init(nsEd
 }
 
 NS_IMETHODIMP SplitElementTxn::DoTransaction(void)
 {
   NS_ASSERTION(mExistingRightNode && mEditor, "bad state");
   if (!mExistingRightNode || !mEditor) { return NS_ERROR_NOT_INITIALIZED; }
 
   // create a new node
-  ErrorResult rv;
-  mNewLeftNode = mExistingRightNode->CloneNode(false, rv);
-  NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
-  NS_ASSERTION(mNewLeftNode, "could not create element.");
-  NS_ENSURE_TRUE(mNewLeftNode, NS_ERROR_NULL_POINTER);
+  nsresult result = mExistingRightNode->CloneNode(false, 1, getter_AddRefs(mNewLeftNode));
+  NS_ASSERTION(((NS_SUCCEEDED(result)) && (mNewLeftNode)), "could not create element.");
+  NS_ENSURE_SUCCESS(result, result);
   mEditor->MarkNodeDirty(mExistingRightNode);
 
   // get the parent node
-  mParent = mExistingRightNode->GetParentNode();
+  result = mExistingRightNode->GetParentNode(getter_AddRefs(mParent));
+  NS_ENSURE_SUCCESS(result, result);
   NS_ENSURE_TRUE(mParent, NS_ERROR_NULL_POINTER);
 
   // insert the new node
-  nsresult result = mEditor->SplitNodeImpl(mExistingRightNode->AsDOMNode(),
-                                           mOffset,
-                                           mNewLeftNode->AsDOMNode(),
-                                           mParent->AsDOMNode());
-  NS_ENSURE_SUCCESS(result, result);
+  result = mEditor->SplitNodeImpl(mExistingRightNode, mOffset, mNewLeftNode, mParent);
   if (mNewLeftNode) {
     bool bAdjustSelection;
     mEditor->ShouldTxnSetSelection(&bAdjustSelection);
     if (bAdjustSelection)
     {
       nsCOMPtr<nsISelection> selection;
       result = mEditor->GetSelection(getter_AddRefs(selection));
       NS_ENSURE_SUCCESS(result, result);
       NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
-      result = selection->Collapse(mNewLeftNode->AsDOMNode(), mOffset);
+      result = selection->Collapse(mNewLeftNode, mOffset);
     }
     else
     {
       // do nothing - dom range gravity will adjust selection
     }
   }
   return result;
 }
@@ -91,65 +86,72 @@ NS_IMETHODIMP SplitElementTxn::DoTransac
 NS_IMETHODIMP SplitElementTxn::UndoTransaction(void)
 {
   NS_ASSERTION(mEditor && mExistingRightNode && mNewLeftNode && mParent, "bad state");
   if (!mEditor || !mExistingRightNode || !mNewLeftNode || !mParent) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // this assumes Do inserted the new node in front of the prior existing node
-  return mEditor->JoinNodesImpl(mExistingRightNode, mNewLeftNode, mParent);
+  nsCOMPtr<nsINode> right = do_QueryInterface(mExistingRightNode);
+  nsCOMPtr<nsINode> left = do_QueryInterface(mNewLeftNode);
+  nsCOMPtr<nsINode> parent = do_QueryInterface(mParent);
+  return mEditor->JoinNodesImpl(right, left, parent);
 }
 
 /* redo cannot simply resplit the right node, because subsequent transactions
  * on the redo stack may depend on the left node existing in its previous state.
  */
 NS_IMETHODIMP SplitElementTxn::RedoTransaction(void)
 {
   NS_ASSERTION(mEditor && mExistingRightNode && mNewLeftNode && mParent, "bad state");
   if (!mEditor || !mExistingRightNode || !mNewLeftNode || !mParent) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
+  nsresult result;
+  nsCOMPtr<nsIDOMNode>resultNode;
   // first, massage the existing node so it is in its post-split state
   nsCOMPtr<nsIDOMCharacterData>rightNodeAsText = do_QueryInterface(mExistingRightNode);
   if (rightNodeAsText)
   {
     nsresult result = rightNodeAsText->DeleteData(0, mOffset);
     NS_ENSURE_SUCCESS(result, result);
   }
   else
   {
-    nsCOMPtr<nsINode> child = mExistingRightNode->GetFirstChild();
-    for (int32_t i=0; i<mOffset; i++)
+    nsCOMPtr<nsIDOMNode>child;
+    nsCOMPtr<nsIDOMNode>nextSibling;
+    result = mExistingRightNode->GetFirstChild(getter_AddRefs(child));
+    int32_t i;
+    for (i=0; i<mOffset; i++)
     {
+      if (NS_FAILED(result)) {return result;}
       if (!child) {return NS_ERROR_NULL_POINTER;}
-      ErrorResult rv;
-      mExistingRightNode->RemoveChild(*child, rv);
-      if (NS_SUCCEEDED(rv.ErrorCode()))
+      child->GetNextSibling(getter_AddRefs(nextSibling));
+      result = mExistingRightNode->RemoveChild(child, getter_AddRefs(resultNode));
+      if (NS_SUCCEEDED(result))
       {
-        mNewLeftNode->AppendChild(*child, rv);
-        NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
+        result = mNewLeftNode->AppendChild(child, getter_AddRefs(resultNode));
       }
-      child = child->GetNextSibling();
+      child = do_QueryInterface(nextSibling);
     }
   }
   // second, re-insert the left node into the tree
-  ErrorResult rv;
-  mParent->InsertBefore(*mNewLeftNode, mExistingRightNode, rv);
-  return rv.ErrorCode();
+  result = mParent->InsertBefore(mNewLeftNode, mExistingRightNode, getter_AddRefs(resultNode));
+  return result;
 }
 
 
 NS_IMETHODIMP SplitElementTxn::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("SplitElementTxn");
   return NS_OK;
 }
 
-NS_IMETHODIMP SplitElementTxn::GetNewNode(nsINode **aNewNode)
+NS_IMETHODIMP SplitElementTxn::GetNewNode(nsIDOMNode **aNewNode)
 {
   NS_ENSURE_TRUE(aNewNode, NS_ERROR_NULL_POINTER);
   NS_ENSURE_TRUE(mNewLeftNode, NS_ERROR_NOT_INITIALIZED);
   *aNewNode = mNewLeftNode;
   NS_ADDREF(*aNewNode);
   return NS_OK;
 }
--- a/editor/libeditor/base/SplitElementTxn.h
+++ b/editor/libeditor/base/SplitElementTxn.h
@@ -4,63 +4,63 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef SplitElementTxn_h__
 #define SplitElementTxn_h__
 
 #include "EditTxn.h"                    // for EditTxn, NS_DECL_EDITTXN
 #include "nsCOMPtr.h"                   // for nsCOMPtr
 #include "nsCycleCollectionParticipant.h"
+#include "nsIDOMNode.h"                 // for nsIDOMNode
 #include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS_INHERITED
 #include "nscore.h"                     // for NS_IMETHOD
 
 class nsEditor;
-class nsINode;
 
 /**
  * A transaction that splits an element E into two identical nodes, E1 and E2
  * with the children of E divided between E1 and E2.
  */
 class SplitElementTxn : public EditTxn
 {
 public:
   /** initialize the transaction.
     * @param aEditor  the provider of core editing operations
     * @param aNode    the node to split
     * @param aOffset  the location within aNode to do the split.
     *                 aOffset may refer to children of aNode, or content of aNode.
     *                 The left node will have child|content 0..aOffset-1.
     */
   NS_IMETHOD Init (nsEditor   *aEditor,
-                   nsINode *aNode,
+                   nsIDOMNode *aNode,
                    int32_t     aOffset);
 
   SplitElementTxn();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitElementTxn, EditTxn)
 
   NS_DECL_EDITTXN
 
   NS_IMETHOD RedoTransaction(void);
 
-  NS_IMETHOD GetNewNode(nsINode **aNewNode);
+  NS_IMETHOD GetNewNode(nsIDOMNode **aNewNode);
 
 protected:
-
+  
   /** the element to operate upon */
-  nsCOMPtr<nsINode> mExistingRightNode;
+  nsCOMPtr<nsIDOMNode> mExistingRightNode;
 
   /** the offset into mElement where the children of mElement are split.<BR>
     * mOffset is the index of the first child in the right node. 
     * -1 means the new node gets no children.
     */
   int32_t  mOffset;
 
   /** the element we create when splitting mElement */
-  nsCOMPtr<nsINode> mNewLeftNode;
+  nsCOMPtr<nsIDOMNode> mNewLeftNode;
 
   /** the parent shared by mExistingRightNode and mNewLeftNode */
-  nsCOMPtr<nsINode> mParent;
+  nsCOMPtr<nsIDOMNode> mParent;
   nsEditor*  mEditor;
 };
 
 #endif
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -1169,25 +1169,24 @@ nsEditor::CanPaste(int32_t aSelectionTyp
 }
 
 NS_IMETHODIMP
 nsEditor::CanPasteTransferable(nsITransferable *aTransferable, bool *aCanPaste)
 {
   return NS_ERROR_NOT_IMPLEMENTED; 
 }
 
-NS_IMETHODIMP
+NS_IMETHODIMP 
 nsEditor::SetAttribute(nsIDOMElement *aElement, const nsAString & aAttribute, const nsAString & aValue)
 {
   nsRefPtr<ChangeAttributeTxn> txn;
-  nsCOMPtr<Element> element = do_QueryInterface(aElement);
-  nsresult result = CreateTxnForSetAttribute(element, aAttribute, aValue,
+  nsresult result = CreateTxnForSetAttribute(aElement, aAttribute, aValue,
                                              getter_AddRefs(txn));
   if (NS_SUCCEEDED(result))  {
-    result = DoTransaction(txn);
+    result = DoTransaction(txn);  
   }
   return result;
 }
 
 NS_IMETHODIMP 
 nsEditor::GetAttributeValue(nsIDOMElement *aElement, 
                             const nsAString & aAttribute, 
                             nsAString & aResultValue, 
@@ -1203,25 +1202,24 @@ nsEditor::GetAttributeValue(nsIDOMElemen
   NS_ENSURE_SUCCESS(rv, rv);
   if (!DOMStringIsNull(value)) {
     *aResultIsSet = true;
     aResultValue = value;
   }
   return rv;
 }
 
-NS_IMETHODIMP
+NS_IMETHODIMP 
 nsEditor::RemoveAttribute(nsIDOMElement *aElement, const nsAString& aAttribute)
 {
   nsRefPtr<ChangeAttributeTxn> txn;
-  nsCOMPtr<Element> element = do_QueryInterface(aElement);
-  nsresult result = CreateTxnForRemoveAttribute(element, aAttribute,
+  nsresult result = CreateTxnForRemoveAttribute(aElement, aAttribute,
                                                 getter_AddRefs(txn));
   if (NS_SUCCEEDED(result))  {
-    result = DoTransaction(txn);
+    result = DoTransaction(txn);  
   }
   return result;
 }
 
 
 bool
 nsEditor::OutputsMozDirty()
 {
@@ -1229,31 +1227,25 @@ nsEditor::OutputsMozDirty()
   // (eEditorMailMask), but false for webpages.
   return !(mFlags & nsIPlaintextEditor::eEditorAllowInteraction) ||
           (mFlags & nsIPlaintextEditor::eEditorMailMask);
 }
 
 
 NS_IMETHODIMP
 nsEditor::MarkNodeDirty(nsIDOMNode* aNode)
-{
-  nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
-  return MarkNodeDirty(node);
-}
-
-nsresult
-nsEditor::MarkNodeDirty(nsINode* aNode)
-{
+{  
   // Mark the node dirty, but not for webpages (bug 599983)
   if (!OutputsMozDirty()) {
     return NS_OK;
   }
-  if (aNode->IsElement()) {
-    aNode->AsElement()->SetAttr(kNameSpaceID_None, nsEditProperty::mozdirty,
-                                EmptyString(), false);
+  nsCOMPtr<dom::Element> element = do_QueryInterface(aNode);
+  if (element) {
+    element->SetAttr(kNameSpaceID_None, nsEditProperty::mozdirty,
+                     EmptyString(), false);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsEditor::GetInlineSpellChecker(bool autoCreate,
                                               nsIInlineSpellChecker ** aInlineSpellChecker)
 {
   NS_ENSURE_ARG_POINTER(aInlineSpellChecker);
@@ -1351,27 +1343,24 @@ NS_IMETHODIMP nsEditor::CreateNode(const
   int32_t i;
 
   nsAutoRules beginRulesSniffing(this, EditAction::createNode, nsIEditor::eNext);
 
   for (i = 0; i < mActionListeners.Count(); i++)
     mActionListeners[i]->WillCreateNode(aTag, aParent, aPosition);
 
   nsRefPtr<CreateElementTxn> txn;
-  nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
-  nsresult result = CreateTxnForCreateElement(aTag, parent, aPosition,
+  nsresult result = CreateTxnForCreateElement(aTag, aParent, aPosition,
                                               getter_AddRefs(txn));
   if (NS_SUCCEEDED(result))
   {
     result = DoTransaction(txn);
     if (NS_SUCCEEDED(result))
     {
-      nsCOMPtr<nsINode> newNode;
-      result = txn->GetNewNode(getter_AddRefs(newNode));
-      CallQueryInterface(newNode, aNewNode);
+      result = txn->GetNewNode(aNewNode);
       NS_ASSERTION((NS_SUCCEEDED(result)), "GetNewNode can't fail if txn::DoTransaction succeeded.");
     }
   }
 
   mRangeUpdater.SelAdjCreateNode(aParent, aPosition);
 
   for (i = 0; i < mActionListeners.Count(); i++)
     mActionListeners[i]->DidCreateNode(aTag, *aNewNode, aParent, aPosition, result);
@@ -1395,18 +1384,18 @@ NS_IMETHODIMP nsEditor::InsertNode(nsIDO
   nsAutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
 
   for (i = 0; i < mActionListeners.Count(); i++)
     mActionListeners[i]->WillInsertNode(aNode, aParent, aPosition);
 
   nsRefPtr<InsertElementTxn> txn;
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
-  nsresult result = CreateTxnForInsertElement(node, parent, aPosition,
-                                              getter_AddRefs(txn));
+  nsresult result = CreateTxnForInsertElement(node->AsDOMNode(), parent->AsDOMNode(),
+                                              aPosition, getter_AddRefs(txn));
   if (NS_SUCCEEDED(result))  {
     result = DoTransaction(txn);
   }
 
   mRangeUpdater.SelAdjInsertNode(aParent, aPosition);
 
   for (i = 0; i < mActionListeners.Count(); i++)
     mActionListeners[i]->DidInsertNode(aNode, aParent, aPosition, result);
@@ -1422,26 +1411,23 @@ nsEditor::SplitNode(nsIDOMNode * aNode,
 {
   int32_t i;
   nsAutoRules beginRulesSniffing(this, EditAction::splitNode, nsIEditor::eNext);
 
   for (i = 0; i < mActionListeners.Count(); i++)
     mActionListeners[i]->WillSplitNode(aNode, aOffset);
 
   nsRefPtr<SplitElementTxn> txn;
-  nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
-  nsresult result = CreateTxnForSplitNode(node, aOffset, getter_AddRefs(txn));
+  nsresult result = CreateTxnForSplitNode(aNode, aOffset, getter_AddRefs(txn));
   if (NS_SUCCEEDED(result))
   {
     result = DoTransaction(txn);
     if (NS_SUCCEEDED(result))
     {
-      nsCOMPtr<nsINode> leftNode;
-      result = txn->GetNewNode(getter_AddRefs(leftNode));
-      CallQueryInterface(leftNode, aNewLeftNode);
+      result = txn->GetNewNode(aNewLeftNode);
       NS_ASSERTION((NS_SUCCEEDED(result)), "result must succeeded for GetNewNode");
     }
   }
 
   mRangeUpdater.SelAdjSplitNode(aNode, aOffset, *aNewLeftNode);
 
   for (i = 0; i < mActionListeners.Count(); i++)
   {
@@ -1482,25 +1468,23 @@ nsEditor::JoinNodes(nsIDOMNode * aLeftNo
   uint32_t oldLeftNodeLen;
   nsresult result = GetLengthOfDOMNode(aLeftNode, oldLeftNodeLen);
   NS_ENSURE_SUCCESS(result, result);
 
   for (i = 0; i < mActionListeners.Count(); i++)
     mActionListeners[i]->WillJoinNodes(aLeftNode, aRightNode, aParent);
 
   nsRefPtr<JoinElementTxn> txn;
-  nsCOMPtr<nsINode> leftNode = do_QueryInterface(aLeftNode);
-  nsCOMPtr<nsINode> rightNode = do_QueryInterface(aRightNode);
-  result = CreateTxnForJoinNode(leftNode, rightNode, getter_AddRefs(txn));
+  result = CreateTxnForJoinNode(aLeftNode, aRightNode, getter_AddRefs(txn));
   if (NS_SUCCEEDED(result))  {
-    result = DoTransaction(txn);
+    result = DoTransaction(txn);  
   }
 
   mRangeUpdater.SelAdjJoinNodes(aLeftNode, aRightNode, aParent, offset, (int32_t)oldLeftNodeLen);
-
+  
   for (i = 0; i < mActionListeners.Count(); i++)
     mActionListeners[i]->DidJoinNodes(aLeftNode, aRightNode, aParent, result);
 
   return result;
 }
 
 
 NS_IMETHODIMP
@@ -2683,35 +2667,35 @@ nsEditor::CreateTxnForDeleteText(nsIDOMC
 
   txn.forget(aTxn);
   return NS_OK;
 }
 
 
 
 
-NS_IMETHODIMP nsEditor::CreateTxnForSplitNode(nsINode *aNode,
+NS_IMETHODIMP nsEditor::CreateTxnForSplitNode(nsIDOMNode *aNode,
                                          uint32_t    aOffset,
                                          SplitElementTxn **aTxn)
 {
   NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
 
   nsRefPtr<SplitElementTxn> txn = new SplitElementTxn();
 
   nsresult rv = txn->Init(this, aNode, aOffset);
   if (NS_SUCCEEDED(rv))
   {
     txn.forget(aTxn);
   }
 
   return rv;
 }
 
-NS_IMETHODIMP nsEditor::CreateTxnForJoinNode(nsINode  *aLeftNode,
-                                             nsINode  *aRightNode,
+NS_IMETHODIMP nsEditor::CreateTxnForJoinNode(nsIDOMNode  *aLeftNode,
+                                             nsIDOMNode  *aRightNode,
                                              JoinElementTxn **aTxn)
 {
   NS_ENSURE_TRUE(aLeftNode && aRightNode, NS_ERROR_NULL_POINTER);
 
   nsRefPtr<JoinElementTxn> txn = new JoinElementTxn();
 
   nsresult rv = txn->Init(this, aLeftNode, aRightNode);
   if (NS_SUCCEEDED(rv))
@@ -4324,19 +4308,19 @@ nsEditor::DoAfterUndoTransaction()
 void
 nsEditor::DoAfterRedoTransaction()
 {
   // all redoable transactions are non-transient
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
     IncrementModificationCount(1)));
 }
 
-NS_IMETHODIMP
-nsEditor::CreateTxnForSetAttribute(Element *aElement,
-                                   const nsAString& aAttribute,
+NS_IMETHODIMP 
+nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement, 
+                                   const nsAString& aAttribute, 
                                    const nsAString& aValue,
                                    ChangeAttributeTxn ** aTxn)
 {
   NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);
 
   nsRefPtr<ChangeAttributeTxn> txn = new ChangeAttributeTxn();
 
   nsresult rv = txn->Init(this, aElement, aAttribute, aValue, false);
@@ -4344,18 +4328,18 @@ nsEditor::CreateTxnForSetAttribute(Eleme
   {
     txn.forget(aTxn);
   }
 
   return rv;
 }
 
 
-NS_IMETHODIMP
-nsEditor::CreateTxnForRemoveAttribute(Element *aElement,
+NS_IMETHODIMP 
+nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement, 
                                       const nsAString& aAttribute,
                                       ChangeAttributeTxn ** aTxn)
 {
   NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);
 
   nsRefPtr<ChangeAttributeTxn> txn = new ChangeAttributeTxn();
 
   nsresult rv = txn->Init(this, aElement, aAttribute, EmptyString(), true);
@@ -4364,17 +4348,17 @@ nsEditor::CreateTxnForRemoveAttribute(El
     txn.forget(aTxn);
   }
 
   return rv;
 }
 
 
 NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsAString& aTag,
-                                                  nsINode        *aParent,
+                                                  nsIDOMNode     *aParent,
                                                   int32_t         aPosition,
                                                   CreateElementTxn ** aTxn)
 {
   NS_ENSURE_TRUE(aParent, NS_ERROR_NULL_POINTER);
 
   nsRefPtr<CreateElementTxn> txn = new CreateElementTxn();
 
   nsresult rv = txn->Init(this, aTag, aParent, aPosition);
@@ -4382,18 +4366,18 @@ NS_IMETHODIMP nsEditor::CreateTxnForCrea
   {
     txn.forget(aTxn);
   }
 
   return rv;
 }
 
 
-NS_IMETHODIMP nsEditor::CreateTxnForInsertElement(nsINode    * aNode,
-                                                  nsINode    * aParent,
+NS_IMETHODIMP nsEditor::CreateTxnForInsertElement(nsIDOMNode * aNode,
+                                                  nsIDOMNode * aParent,
                                                   int32_t      aPosition,
                                                   InsertElementTxn ** aTxn)
 {
   NS_ENSURE_TRUE(aNode && aParent, NS_ERROR_NULL_POINTER);
 
   nsRefPtr<InsertElementTxn> txn = new InsertElementTxn();
 
   nsresult rv = txn->Init(aNode, aParent, aPosition, this);
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -259,38 +259,38 @@ public:
   void SwitchTextDirectionTo(uint32_t aDirection);
 
 protected:
   nsresult DetermineCurrentDirection();
   void FireInputEvent();
 
   /** create a transaction for setting aAttribute to aValue on aElement
     */
-  NS_IMETHOD CreateTxnForSetAttribute(mozilla::dom::Element *aElement,
+  NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement,
                                       const nsAString &  aAttribute,
                                       const nsAString &  aValue,
                                       ChangeAttributeTxn ** aTxn);
 
   /** create a transaction for removing aAttribute on aElement
     */
-  NS_IMETHOD CreateTxnForRemoveAttribute(mozilla::dom::Element *aElement,
+  NS_IMETHOD CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
                                          const nsAString &  aAttribute,
                                          ChangeAttributeTxn ** aTxn);
 
   /** create a transaction for creating a new child node of aParent of type aTag.
     */
   NS_IMETHOD CreateTxnForCreateElement(const nsAString & aTag,
-                                       nsINode         *aParent,
+                                       nsIDOMNode      *aParent,
                                        int32_t         aPosition,
                                        CreateElementTxn ** aTxn);
 
   /** create a transaction for inserting aNode as a child of aParent.
     */
-  NS_IMETHOD CreateTxnForInsertElement(nsINode    * aNode,
-                                       nsINode    * aParent,
+  NS_IMETHOD CreateTxnForInsertElement(nsIDOMNode * aNode,
+                                       nsIDOMNode * aParent,
                                        int32_t      aOffset,
                                        InsertElementTxn ** aTxn);
 
   /** create a transaction for removing aNode from its parent.
     */
   nsresult CreateTxnForDeleteNode(nsINode* aNode, DeleteNodeTxn** aTxn);
 
 
@@ -345,22 +345,22 @@ protected:
                                   uint32_t             aLength,
                                   DeleteTextTxn**      aTxn);
 
   nsresult CreateTxnForDeleteCharacter(nsIDOMCharacterData* aData,
                                        uint32_t             aOffset,
                                        EDirection           aDirection,
                                        DeleteTextTxn**      aTxn);
 	
-  NS_IMETHOD CreateTxnForSplitNode(nsINode *aNode,
+  NS_IMETHOD CreateTxnForSplitNode(nsIDOMNode *aNode,
                                    uint32_t    aOffset,
                                    SplitElementTxn **aTxn);
 
-  NS_IMETHOD CreateTxnForJoinNode(nsINode  *aLeftNode,
-                                  nsINode  *aRightNode,
+  NS_IMETHOD CreateTxnForJoinNode(nsIDOMNode  *aLeftNode,
+                                  nsIDOMNode  *aRightNode,
                                   JoinElementTxn **aTxn);
 
   /**
    * This method first deletes the selection, if it's not collapsed.  Then if
    * the selection lies in a CharacterData node, it splits it.  If the
    * selection is at this point collapsed in a CharacterData node, it's
    * adjusted to be collapsed right before or after the node instead (which is
    * always possible, since the node was split).