Bug 1369252 - Don't use nsISelection::CollapseNative / ExtendNative. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 02 Jun 2017 17:25:17 +0900
changeset 588162 f6775f0beeafcee76306791797180faea0686483
parent 588052 aeb3d0ca558f034cbef1c5a68bd07dd738611494
child 631484 764003ae569078866c571adff1e95039374a41fe
push id61935
push userm_kato@ga2.so-net.ne.jp
push dateFri, 02 Jun 2017 08:28:53 +0000
reviewersmasayuki
bugs1369252
milestone55.0a1
Bug 1369252 - Don't use nsISelection::CollapseNative / ExtendNative. r?masayuki Editor still uses CollapseNative and ExtendNative even if it uses Selection, not nsISelection. CollapseNative and ExtendNative is virtual method, but Selection::Collapse and Extend is non-virtual. So, we should use Selection::Collapse and Extend instead. MozReview-Commit-ID: 1AEaaJRbkIm
editor/libeditor/CreateElementTransaction.cpp
editor/libeditor/EditorBase.cpp
editor/libeditor/HTMLEditor.cpp
editor/libeditor/TextEditRules.cpp
--- a/editor/libeditor/CreateElementTransaction.cpp
+++ b/editor/libeditor/CreateElementTransaction.cpp
@@ -94,17 +94,17 @@ CreateElementTransaction::DoTransaction(
   if (!mEditorBase->GetShouldTxnSetSelection()) {
     // Do nothing - DOM range gravity will adjust selection
     return NS_OK;
   }
 
   RefPtr<Selection> selection = mEditorBase->GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
-  rv = selection->CollapseNative(mParent, mParent->IndexOf(mNewNode) + 1);
+  rv = selection->Collapse(mParent, mParent->IndexOf(mNewNode) + 1);
   NS_ASSERTION(!rv.Failed(),
                "selection could not be collapsed after insert");
   return NS_OK;
 }
 
 NS_IMETHODIMP
 CreateElementTransaction::UndoTransaction()
 {
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -1065,32 +1065,32 @@ EditorBase::BeginningOfDocument()
   // get the root element
   dom::Element* rootElement = GetRoot();
   NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
 
   // find first editable thingy
   nsCOMPtr<nsINode> firstNode = GetFirstEditableNode(rootElement);
   if (!firstNode) {
     // just the root node, set selection to inside the root
-    return selection->CollapseNative(rootElement, 0);
+    return selection->Collapse(rootElement, 0);
   }
 
   if (firstNode->NodeType() == nsIDOMNode::TEXT_NODE) {
     // If firstNode is text, set selection to beginning of the text node.
-    return selection->CollapseNative(firstNode, 0);
+    return selection->Collapse(firstNode, 0);
   }
 
   // Otherwise, it's a leaf node and we set the selection just in front of it.
   nsCOMPtr<nsIContent> parent = firstNode->GetParent();
   if (!parent) {
     return NS_ERROR_NULL_POINTER;
   }
 
   int32_t offsetInParent = parent->IndexOf(firstNode);
-  return selection->CollapseNative(parent, offsetInParent);
+  return selection->Collapse(parent, offsetInParent);
 }
 
 NS_IMETHODIMP
 EditorBase::EndOfDocument()
 {
   NS_ENSURE_TRUE(mDocWeak, NS_ERROR_NOT_INITIALIZED);
 
   // get selection
@@ -1103,17 +1103,17 @@ EditorBase::EndOfDocument()
   nsINode* child = node->GetLastChild();
 
   while (child && IsContainer(child->AsDOMNode())) {
     node = child;
     child = node->GetLastChild();
   }
 
   uint32_t length = node->Length();
-  return selection->CollapseNative(node, int32_t(length));
+  return selection->Collapse(node, int32_t(length));
 }
 
 NS_IMETHODIMP
 EditorBase::GetDocumentModified(bool* outDocModified)
 {
   NS_ENSURE_TRUE(outDocModified, NS_ERROR_NULL_POINTER);
 
   int32_t  modCount = 0;
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3375,22 +3375,22 @@ SetSelectionAroundHeadChildren(Selection
   // Set selection around <head> node
   nsCOMPtr<nsIDocument> doc = do_QueryReferent(aDocWeak);
   NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
 
   dom::Element* headNode = doc->GetHeadElement();
   NS_ENSURE_STATE(headNode);
 
   // Collapse selection to before first child of the head,
-  nsresult rv = aSelection->CollapseNative(headNode, 0);
+  nsresult rv = aSelection->Collapse(headNode, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Then extend it to just after.
   uint32_t childCount = headNode->GetChildCount();
-  return aSelection->ExtendNative(headNode, childCount + 1);
+  return aSelection->Extend(headNode, childCount + 1);
 }
 
 NS_IMETHODIMP
 HTMLEditor::GetHeadContentsAsHTML(nsAString& aOutputString)
 {
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
@@ -3712,17 +3712,17 @@ HTMLEditor::SetCaretInTableCell(nsIDOMEl
   while (node->HasChildren()) {
     node = node->GetFirstChild();
   }
 
   // Set selection at beginning of the found node
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, false);
 
-  return NS_SUCCEEDED(selection->CollapseNative(node, 0));
+  return NS_SUCCEEDED(selection->Collapse(node, 0));
 }
 
 /**
  * GetEnclosingTable() finds ancestor who is a table, if any.
  */
 Element*
 HTMLEditor::GetEnclosingTable(nsINode* aNode)
 {
@@ -3815,17 +3815,17 @@ HTMLEditor::CollapseAdjacentTextNodes(ns
 }
 
 nsresult
 HTMLEditor::SetSelectionAtDocumentStart(Selection* aSelection)
 {
   dom::Element* rootElement = GetRoot();
   NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
 
-  return aSelection->CollapseNative(rootElement, 0);
+  return aSelection->Collapse(rootElement, 0);
 }
 
 /**
  * Remove aNode, reparenting any children into the parent of aNode.  In
  * addition, insert any br's needed to preserve identity of removed block.
  */
 nsresult
 HTMLEditor::RemoveBlockContainer(nsIContent& aNode)
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -1354,17 +1354,17 @@ TextEditRules::CreateBogusNodeIfNeeded(S
   newContent->SetAttr(kNameSpaceID_None, kMOZEditorBogusNodeAttrAtom,
                       kMOZEditorBogusNodeValue, false);
 
   // Put the node in the document.
   nsresult rv = mTextEditor->InsertNode(*mBogusNode, *body, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Set selection.
-  aSelection->CollapseNative(body, 0);
+  aSelection->Collapse(body, 0);
   return NS_OK;
 }
 
 
 nsresult
 TextEditRules::TruncateInsertionIfNeeded(Selection* aSelection,
                                          const nsAString* aInString,
                                          nsAString* aOutString,