Bug 700538 part 1 - Name some nsEditor methods more consistently; r=ehsan
authorAryeh Gregor <ayg@aryeh.name>
Tue, 01 May 2012 13:01:28 +0300
changeset 95745 18c27249fc7ffcec7e192f1184ba742a98b54d88
parent 95744 730cc501c93998549560a2900b1c0ba37d37937e
child 95746 edebd9b79fe51d15d0ad947a3b634a348322b847
push id1439
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 20:19:22 +0000
treeherdermozilla-aurora@ea74834dccd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs700538
milestone15.0a1
Bug 700538 part 1 - Name some nsEditor methods more consistently; r=ehsan
editor/libeditor/base/nsEditor.cpp
editor/libeditor/base/nsEditor.h
editor/libeditor/html/nsHTMLEditRules.cpp
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -3245,17 +3245,17 @@ nsEditor::GetNextNode(nsINode* aParentNo
       return child;
     }
 
     nsIContent* resultNode = GetLeftmostChild(child, aNoBlockCrossing);
     if (!resultNode) {
       return child;
     }
 
-    if (!IsDescendantOfBody(resultNode)) {
+    if (!IsDescendantOfRoot(resultNode)) {
       return nsnull;
     }
 
     if (!aEditableNode || IsEditable(resultNode)) {
       return resultNode;
     }
 
     // restart the search from the non-editable node we just found
@@ -3295,17 +3295,17 @@ nsEditor::GetPriorNode(nsIDOMNode  *aCur
 
 nsIContent*
 nsEditor::GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
                        bool aNoBlockCrossing /* = false */,
                        nsIContent* aActiveEditorRoot /* = null */)
 {
   MOZ_ASSERT(aCurrentNode);
 
-  if (!IsDescendantOfBody(aCurrentNode) ||
+  if (!IsDescendantOfRoot(aCurrentNode) ||
       (aActiveEditorRoot &&
        !nsContentUtils::ContentIsDescendantOf(aCurrentNode,
                                               aActiveEditorRoot))) {
     return nsnull;
   }
 
   return FindNode(aCurrentNode, false, aEditableNode, aNoBlockCrossing,
                   aActiveEditorRoot);
@@ -3313,17 +3313,18 @@ nsEditor::GetPriorNode(nsINode* aCurrent
 
 nsIContent*
 nsEditor::FindNextLeafNode(nsINode  *aCurrentNode, 
                            bool      aGoForward,
                            bool      bNoBlockCrossing,
                            nsIContent *aActiveEditorRoot)
 {
   // called only by GetPriorNode so we don't need to check params.
-  NS_PRECONDITION(IsDescendantOfBody(aCurrentNode) && !IsRootNode(aCurrentNode) &&
+  NS_PRECONDITION(IsDescendantOfRoot(aCurrentNode) &&
+                  !IsRoot(aCurrentNode) &&
                   (!aActiveEditorRoot ||
                    nsContentUtils::ContentIsDescendantOf(aCurrentNode,
                                                          aActiveEditorRoot)),
                   "Bogus arguments");
 
   nsINode* cur = aCurrentNode;
   for (;;) {
     // if aCurrentNode has a sibling in the right direction, return
@@ -3345,21 +3346,21 @@ nsEditor::FindNextLeafNode(nsINode  *aCu
       return leaf;
     }
 
     nsINode *parent = cur->GetNodeParent();
     if (!parent) {
       return nsnull;
     }
 
-    NS_ASSERTION(IsDescendantOfBody(parent),
+    NS_ASSERTION(IsDescendantOfRoot(parent),
                  "We started with a proper descendant of root, and should stop "
                  "if we ever hit the root, so we better have a descendant of "
                  "root now!");
-    if (IsRootNode(parent) ||
+    if (IsRoot(parent) ||
         (bNoBlockCrossing && IsBlockNode(parent)) ||
         parent == aActiveEditorRoot) {
       return nsnull;
     }
 
     cur = parent;
   }
 
@@ -3388,17 +3389,17 @@ nsEditor::GetNextNode(nsIDOMNode* aCurre
 nsIContent*
 nsEditor::GetNextNode(nsINode* aCurrentNode,
                       bool aEditableNode,
                       bool bNoBlockCrossing,
                       nsIContent* aActiveEditorRoot)
 {
   MOZ_ASSERT(aCurrentNode);
 
-  if (!IsDescendantOfBody(aCurrentNode) ||
+  if (!IsDescendantOfRoot(aCurrentNode) ||
       (aActiveEditorRoot &&
        !nsContentUtils::ContentIsDescendantOf(aCurrentNode,
                                               aActiveEditorRoot))) {
     return nsnull;
   }
 
   return FindNode(aCurrentNode, true, aEditableNode, bNoBlockCrossing,
                   aActiveEditorRoot);
@@ -3406,18 +3407,17 @@ nsEditor::GetNextNode(nsINode* aCurrentN
 
 nsIContent*
 nsEditor::FindNode(nsINode *aCurrentNode,
                    bool     aGoForward,
                    bool     aEditableNode,
                    bool     bNoBlockCrossing,
                    nsIContent *aActiveEditorRoot)
 {
-  if (IsRootNode(aCurrentNode) || aCurrentNode == aActiveEditorRoot)
-  {
+  if (IsRoot(aCurrentNode) || aCurrentNode == aActiveEditorRoot) {
     // Don't allow traversal above the root node! This helps
     // prevent us from accidentally editing browser content
     // when the editor is in a text widget.
 
     return nsnull;
   }
 
   nsIContent* candidate =
@@ -3584,44 +3584,44 @@ nsEditor::TagCanContain(nsIAtom* aParent
 
 bool 
 nsEditor::TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag)
 {
   return true;
 }
 
 bool
-nsEditor::IsRootNode(nsIDOMNode *inNode)
+nsEditor::IsRoot(nsIDOMNode* inNode)
 {
   NS_ENSURE_TRUE(inNode, false);
 
   nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(GetRoot());
 
   return inNode == rootNode;
 }
 
 bool 
-nsEditor::IsRootNode(nsINode *inNode) 
+nsEditor::IsRoot(nsINode* inNode)
 {
   NS_ENSURE_TRUE(inNode, false);
 
   nsCOMPtr<nsINode> rootNode = GetRoot();
 
   return inNode == rootNode;
 }
 
 bool 
-nsEditor::IsDescendantOfBody(nsIDOMNode *inNode) 
+nsEditor::IsDescendantOfRoot(nsIDOMNode* inNode)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
-  return IsDescendantOfBody(node);
+  return IsDescendantOfRoot(node);
 }
 
 bool
-nsEditor::IsDescendantOfBody(nsINode *inNode)
+nsEditor::IsDescendantOfRoot(nsINode* inNode)
 {
   NS_ENSURE_TRUE(inNode, false);
   nsCOMPtr<nsIContent> root = GetRoot();
   NS_ENSURE_TRUE(root, false);
 
   return nsContentUtils::ContentIsDescendantOf(inNode, root);
 }
 
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -572,22 +572,22 @@ public:
 
   /** returns true if aParent can contain a child of type aTag */
   bool CanContain(nsIDOMNode* aParent, nsIDOMNode* aChild);
   bool CanContainTag(nsIDOMNode* aParent, nsIAtom* aTag);
   bool TagCanContain(nsIAtom* aParentTag, nsIDOMNode* aChild);
   virtual bool TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag);
 
   /** returns true if aNode is our root node */
-  bool IsRootNode(nsIDOMNode *inNode);
-  bool IsRootNode(nsINode *inNode);
+  bool IsRoot(nsIDOMNode* inNode);
+  bool IsRoot(nsINode* inNode);
 
   /** returns true if aNode is a descendant of our root node */
-  bool IsDescendantOfBody(nsIDOMNode *inNode);
-  bool IsDescendantOfBody(nsINode *inNode);
+  bool IsDescendantOfRoot(nsIDOMNode* inNode);
+  bool IsDescendantOfRoot(nsINode* inNode);
 
   /** returns true if aNode is a container */
   virtual bool IsContainer(nsIDOMNode *aNode);
 
   /** returns true if aNode is an editable node */
   bool IsEditable(nsIDOMNode *aNode);
   bool IsEditable(nsIContent *aNode);
 
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -8351,18 +8351,17 @@ nsHTMLEditRules::UpdateDocChangeRange(ns
 
   // first make sure aRange is in the document.  It might not be if
   // portions of our editting action involved manipulating nodes
   // prior to placing them in the document (e.g., populating a list item
   // before placing it in its list)
   nsCOMPtr<nsIDOMNode> startNode;
   res = aRange->GetStartContainer(getter_AddRefs(startNode));
   NS_ENSURE_SUCCESS(res, res);
-  if (!mHTMLEditor->IsDescendantOfBody(startNode))
-  {
+  if (!mHTMLEditor->IsDescendantOfRoot(startNode)) {
     // just return - we don't need to adjust mDocChangeRange in this case
     return NS_OK;
   }
   
   if (!mDocChangeRange)
   {
     // clone aRange.
     nsCOMPtr<nsIDOMRange> range;