Bug 1405419 - Part 1: Remove the HTMLEditor::GetPriorHTMLSibling() overload accepting a parent and an offset; r=masayuki
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 03 Oct 2017 16:18:08 -0400
changeset 384523 b38062303696ee1af70b51e45910620c4e9c7aad
parent 384522 055d22104ccd2cd04aa4ca004994850df0d87115
child 384524 f8bc133f9a07759010bdbc60e92499de396f11dd
push id32629
push userkwierso@gmail.com
push dateWed, 04 Oct 2017 23:38:17 +0000
treeherdermozilla-central@dedd9a48da69 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1405419
milestone58.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 1405419 - Part 1: Remove the HTMLEditor::GetPriorHTMLSibling() overload accepting a parent and an offset; r=masayuki
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditor.h
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -7454,29 +7454,34 @@ HTMLEditRules::CheckInterlinePosition(Se
   RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
 
   // Get the (collapsed) selection location
   NS_ENSURE_TRUE_VOID(aSelection.GetRangeAt(0) &&
                       aSelection.GetRangeAt(0)->GetStartContainer());
   OwningNonNull<nsINode> selNode =
     *aSelection.GetRangeAt(0)->GetStartContainer();
   int32_t selOffset = aSelection.GetRangeAt(0)->StartOffset();
+  nsIContent* child = aSelection.GetRangeAt(0)->GetChildAtStartOffset();
 
   // First, let's check to see if we are after a <br>.  We take care of this
   // special-case first so that we don't accidentally fall through into one of
   // the other conditionals.
   nsCOMPtr<nsIContent> node =
     htmlEditor->GetPriorHTMLNode(selNode, selOffset, true);
   if (node && node->IsHTMLElement(nsGkAtoms::br)) {
     aSelection.SetInterlinePosition(true);
     return;
   }
 
   // Are we after a block?  If so try set caret to following content
-  node = htmlEditor->GetPriorHTMLSibling(selNode, selOffset);
+  if (child) {
+    node = htmlEditor->GetPriorHTMLSibling(child);
+  } else {
+    node = nullptr;
+  }
   if (node && IsBlockNode(*node)) {
     aSelection.SetInterlinePosition(true);
     return;
   }
 
   // Are we before a block?  If so try set caret to prior content
   node = htmlEditor->GetNextHTMLSibling(selNode, selOffset);
   if (node && IsBlockNode(*node)) {
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3818,47 +3818,31 @@ HTMLEditor::GetPriorHTMLSibling(nsIDOMNo
 
   nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
 
   *outNode = do_QueryInterface(GetPriorHTMLSibling(node));
   return NS_OK;
 }
 
-/**
- * GetPriorHTMLSibling() returns the previous editable sibling, if there is
- * one within the parent.  just like above routine but takes a parent/offset
- * instead of a node.
- */
-nsIContent*
-HTMLEditor::GetPriorHTMLSibling(nsINode* aParent,
-                                int32_t aOffset)
-{
-  MOZ_ASSERT(aParent);
-
-  nsIContent* node = aParent->GetChildAt(aOffset - 1);
-  if (!node || IsEditable(node)) {
-    return node;
-  }
-
-  return GetPriorHTMLSibling(node);
-}
-
 nsresult
 HTMLEditor::GetPriorHTMLSibling(nsIDOMNode* inParent,
                                 int32_t inOffset,
                                 nsCOMPtr<nsIDOMNode>* outNode)
 {
   NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
   *outNode = nullptr;
 
   nsCOMPtr<nsINode> parent = do_QueryInterface(inParent);
   NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
 
-  *outNode = do_QueryInterface(GetPriorHTMLSibling(parent, inOffset));
+  nsCOMPtr<nsINode> child = parent->GetChildAt(inOffset);
+  NS_ENSURE_TRUE(child, NS_ERROR_NULL_POINTER);
+
+  *outNode = do_QueryInterface(GetPriorHTMLSibling(child));
   return NS_OK;
 }
 
 /**
  * GetNextHTMLSibling() returns the next editable sibling, if there is
  * one within the parent.
  */
 nsIContent*
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -765,17 +765,16 @@ protected:
   bool IsAtEndOfNode(nsINode& aNode, int32_t aOffset);
   bool IsOnlyAttribute(const nsIContent* aElement, const nsAString& aAttribute);
 
   nsresult RemoveBlockContainer(nsIContent& aNode);
 
   nsIContent* GetPriorHTMLSibling(nsINode* aNode);
   nsresult GetPriorHTMLSibling(nsIDOMNode*inNode,
                                nsCOMPtr<nsIDOMNode>* outNode);
-  nsIContent* GetPriorHTMLSibling(nsINode* aParent, int32_t aOffset);
   nsresult GetPriorHTMLSibling(nsIDOMNode* inParent, int32_t inOffset,
                                nsCOMPtr<nsIDOMNode>* outNode);
 
   nsIContent* GetNextHTMLSibling(nsINode* aNode);
   nsresult GetNextHTMLSibling(nsIDOMNode* inNode,
                               nsCOMPtr<nsIDOMNode>* outNode);
   nsIContent* GetNextHTMLSibling(nsINode* aParent, int32_t aOffset);
   nsresult GetNextHTMLSibling(nsIDOMNode* inParent, int32_t inOffset,