Bug 1436285 - Part 2. Get a rid of nsIDOMNode version of GetNodeLocation, GetStartNodeAndOffset, GetEndNodeAndOffset and etc. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 28 Feb 2018 11:33:16 +0900
changeset 760738 274494edc2c5705dc1fb36a658005c78090a8a33
parent 760737 0912b22cf75bb7e0178d97fd868a9dba7cb35170
push id100743
push userbmo:m_kato@ga2.so-net.ne.jp
push dateWed, 28 Feb 2018 02:37:03 +0000
reviewersmasayuki
bugs1436285
milestone60.0a1
Bug 1436285 - Part 2. Get a rid of nsIDOMNode version of GetNodeLocation, GetStartNodeAndOffset, GetEndNodeAndOffset and etc. r?masayuki Remove unused methods... MozReview-Commit-ID: 4A8924wsEq3
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
editor/libeditor/WSRunObject.cpp
editor/libeditor/WSRunObject.h
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -3529,34 +3529,16 @@ EditorBase::GetChildOffset(nsINode* aChi
   }
 
   int32_t index = aParent->ComputeIndexOf(aChild);
   MOZ_ASSERT(index != -1);
   return index;
 }
 
 // static
-already_AddRefed<nsIDOMNode>
-EditorBase::GetNodeLocation(nsIDOMNode* aChild,
-                            int32_t* outOffset)
-{
-  MOZ_ASSERT(aChild && outOffset);
-  NS_ENSURE_TRUE(aChild && outOffset, nullptr);
-  *outOffset = -1;
-
-  nsCOMPtr<nsINode> child = do_QueryInterface(aChild);
-  nsCOMPtr<nsIDOMNode> parent = do_QueryInterface(child->GetParentNode());
-
-  if (parent) {
-    *outOffset = GetChildOffset(aChild, parent);
-  }
-
-  return parent.forget();
-}
-
 nsINode*
 EditorBase::GetNodeLocation(nsINode* aChild,
                             int32_t* aOffset)
 {
   MOZ_ASSERT(aChild);
   MOZ_ASSERT(aOffset);
 
   nsINode* parent = aChild->GetParentNode();
@@ -4075,38 +4057,16 @@ EditorBase::GetNodeAtRangeOffsetPoint(co
 }
 
 /**
  * GetStartNodeAndOffset() returns whatever the start parent & offset is of
  * the first range in the selection.
  */
 nsresult
 EditorBase::GetStartNodeAndOffset(Selection* aSelection,
-                                  nsIDOMNode** outStartNode,
-                                  int32_t* outStartOffset)
-{
-  NS_ENSURE_TRUE(outStartNode && outStartOffset && aSelection, NS_ERROR_NULL_POINTER);
-
-  nsCOMPtr<nsINode> startNode;
-  nsresult rv = GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode),
-                                      outStartOffset);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  if (startNode) {
-    NS_ADDREF(*outStartNode = startNode->AsDOMNode());
-  } else {
-    *outStartNode = nullptr;
-  }
-  return NS_OK;
-}
-
-nsresult
-EditorBase::GetStartNodeAndOffset(Selection* aSelection,
                                   nsINode** aStartContainer,
                                   int32_t* aStartOffset)
 {
   MOZ_ASSERT(aSelection);
   MOZ_ASSERT(aStartContainer);
   MOZ_ASSERT(aStartOffset);
 
   *aStartContainer = nullptr;
@@ -4142,36 +4102,16 @@ EditorBase::GetStartPoint(Selection* aSe
 }
 
 /**
  * GetEndNodeAndOffset() returns whatever the end parent & offset is of
  * the first range in the selection.
  */
 nsresult
 EditorBase::GetEndNodeAndOffset(Selection* aSelection,
-                                nsIDOMNode** outEndNode,
-                                int32_t* outEndOffset)
-{
-  NS_ENSURE_TRUE(outEndNode && outEndOffset && aSelection, NS_ERROR_NULL_POINTER);
-
-  nsCOMPtr<nsINode> endNode;
-  nsresult rv = GetEndNodeAndOffset(aSelection, getter_AddRefs(endNode),
-                                    outEndOffset);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (endNode) {
-    NS_ADDREF(*outEndNode = endNode->AsDOMNode());
-  } else {
-    *outEndNode = nullptr;
-  }
-  return NS_OK;
-}
-
-nsresult
-EditorBase::GetEndNodeAndOffset(Selection* aSelection,
                                 nsINode** aEndContainer,
                                 int32_t* aEndOffset)
 {
   MOZ_ASSERT(aSelection);
   MOZ_ASSERT(aEndContainer);
   MOZ_ASSERT(aEndOffset);
 
   *aEndContainer = nullptr;
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -802,18 +802,16 @@ public:
                                 nsIDOMNode* aParent);
   static int32_t GetChildOffset(nsINode* aChild,
                                 nsINode* aParent);
 
   /**
    * Set outOffset to the offset of aChild in the parent.
    * Returns the parent of aChild.
    */
-  static already_AddRefed<nsIDOMNode> GetNodeLocation(nsIDOMNode* aChild,
-                                                      int32_t* outOffset);
   static nsINode* GetNodeLocation(nsINode* aChild, int32_t* aOffset);
 
   /**
    * Get the previous node.
    */
   nsIContent* GetPreviousNode(const EditorRawDOMPoint& aPoint)
   {
     return GetPreviousNodeInternal(aPoint, false, true, false);
@@ -1102,26 +1100,20 @@ public:
   static nsIContent* GetNodeAtRangeOffsetPoint(nsINode* aContainer,
                                                int32_t aOffset)
   {
     return GetNodeAtRangeOffsetPoint(RawRangeBoundary(aContainer, aOffset));
   }
   static nsIContent* GetNodeAtRangeOffsetPoint(const RawRangeBoundary& aPoint);
 
   static nsresult GetStartNodeAndOffset(Selection* aSelection,
-                                        nsIDOMNode** outStartNode,
-                                        int32_t* outStartOffset);
-  static nsresult GetStartNodeAndOffset(Selection* aSelection,
                                         nsINode** aStartContainer,
                                         int32_t* aStartOffset);
   static EditorRawDOMPoint GetStartPoint(Selection* aSelection);
   static nsresult GetEndNodeAndOffset(Selection* aSelection,
-                                      nsIDOMNode** outEndNode,
-                                      int32_t* outEndOffset);
-  static nsresult GetEndNodeAndOffset(Selection* aSelection,
                                       nsINode** aEndContainer,
                                       int32_t* aEndOffset);
   static EditorRawDOMPoint GetEndPoint(Selection* aSelection);
 
   static nsresult GetEndChildNode(Selection* aSelection,
                                   nsIContent** aEndNode);
 
   Selection* GetSelection(SelectionType aSelectionType =
--- a/editor/libeditor/WSRunObject.cpp
+++ b/editor/libeditor/WSRunObject.cpp
@@ -18,17 +18,16 @@
 
 #include "nsAString.h"
 #include "nsCRT.h"
 #include "nsContentUtils.h"
 #include "nsDebug.h"
 #include "nsError.h"
 #include "nsIContent.h"
 #include "nsIDOMDocument.h"
-#include "nsIDOMNode.h"
 #include "nsISupportsImpl.h"
 #include "nsRange.h"
 #include "nsString.h"
 #include "nsTextFragment.h"
 
 namespace mozilla {
 
 using namespace dom;
@@ -48,34 +47,16 @@ WSRunObject::WSRunObject(HTMLEditor* aHT
   , mStartRun(nullptr)
   , mEndRun(nullptr)
   , mHTMLEditor(aHTMLEditor)
 {
   GetWSNodes();
   GetRuns();
 }
 
-WSRunObject::WSRunObject(HTMLEditor* aHTMLEditor,
-                         nsIDOMNode* aNode,
-                         int32_t aOffset)
-  : mNode(do_QueryInterface(aNode))
-  , mOffset(aOffset)
-  , mPRE(false)
-  , mStartOffset(0)
-  , mEndOffset(0)
-  , mFirstNBSPOffset(0)
-  , mLastNBSPOffset(0)
-  , mStartRun(nullptr)
-  , mEndRun(nullptr)
-  , mHTMLEditor(aHTMLEditor)
-{
-  GetWSNodes();
-  GetRuns();
-}
-
 WSRunObject::~WSRunObject()
 {
   ClearRuns();
 }
 
 nsresult
 WSRunObject::ScrubBlockBoundary(HTMLEditor* aHTMLEditor,
                                 BlockBoundary aBoundary,
--- a/editor/libeditor/WSRunObject.h
+++ b/editor/libeditor/WSRunObject.h
@@ -9,18 +9,16 @@
 #include "nsCOMPtr.h"
 #include "nsIEditor.h" // for EDirection
 #include "nsINode.h"
 #include "nscore.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Text.h"
 #include "mozilla/EditorDOMPoint.h" // for EditorDOMPoint
 
-class nsIDOMNode;
-
 namespace mozilla {
 
 class HTMLEditor;
 class HTMLEditRules;
 
 // class WSRunObject represents the entire whitespace situation
 // around a given point.  It collects up a list of nodes that contain
 // whitespace and categorizes in up to 3 different WSFragments (detailed
@@ -161,17 +159,16 @@ public:
     kAfterBlock
   };
 
   enum {eBefore = 1};
   enum {eAfter  = 1 << 1};
   enum {eBoth   = eBefore | eAfter};
 
   WSRunObject(HTMLEditor* aHTMLEditor, nsINode* aNode, int32_t aOffset);
-  WSRunObject(HTMLEditor* aHTMLEditor, nsIDOMNode* aNode, int32_t aOffset);
   ~WSRunObject();
 
   // ScrubBlockBoundary removes any non-visible whitespace at the specified
   // location relative to a block node.
   static nsresult ScrubBlockBoundary(HTMLEditor* aHTMLEditor,
                                      BlockBoundary aBoundary,
                                      nsINode* aBlock,
                                      int32_t aOffset = -1);