Bug 1391978 - Part 2. Replace nsISelection::SelectAllChildren with Selection::SelectAllChildren. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 25 Aug 2017 16:12:38 +0900
changeset 654193 47aa2e674a8f6615989b25ddb2b11b6614587b7b
parent 654192 03c8a5b49e2929b0ce6c6af8b78c9677a55a14c4
child 654194 2c45cffa7d526a9e07126c90f17232b02b1612ea
push id76495
push userbmo:m_kato@ga2.so-net.ne.jp
push dateMon, 28 Aug 2017 10:39:27 +0000
reviewersmasayuki
bugs1391978
milestone57.0a1
Bug 1391978 - Part 2. Replace nsISelection::SelectAllChildren with Selection::SelectAllChildren. r?masayuki MozReview-Commit-ID: m9bLHIIfy9
editor/libeditor/EditorBase.cpp
editor/libeditor/HTMLEditor.cpp
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -2637,22 +2637,24 @@ EditorBase::InsertTextIntoTextNodeImpl(c
 
 nsresult
 EditorBase::SelectEntireDocument(Selection* aSelection)
 {
   if (!aSelection) {
     return NS_ERROR_NULL_POINTER;
   }
 
-  nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
+  Element* rootElement = GetRoot();
   if (!rootElement) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
-  return aSelection->SelectAllChildren(rootElement);
+  ErrorResult errorResult;
+  aSelection->SelectAllChildren(*rootElement, errorResult);
+  return errorResult.StealNSResult();
 }
 
 nsINode*
 EditorBase::GetFirstEditableNode(nsINode* aRoot)
 {
   MOZ_ASSERT(aRoot);
 
   nsIContent* node = GetLeftmostChild(aRoot);
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3609,24 +3609,23 @@ HTMLEditor::SelectAll()
     rootContent = mRootElement;
   } else {
     nsCOMPtr<nsIPresShell> ps = GetPresShell();
     rootContent = anchorContent->GetSelectionRootContent(ps);
   }
 
   NS_ENSURE_TRUE(rootContent, NS_ERROR_UNEXPECTED);
 
-  nsCOMPtr<nsIDOMNode> rootElement = do_QueryInterface(rootContent, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   Maybe<mozilla::dom::Selection::AutoUserInitiated> userSelection;
   if (!rootContent->IsEditable()) {
     userSelection.emplace(selection);
   }
-  return selection->SelectAllChildren(rootElement);
+  ErrorResult errorResult;
+  selection->SelectAllChildren(*rootContent, errorResult);
+  return errorResult.StealNSResult();
 }
 
 // this will NOT find aAttribute unless aAttribute has a non-null value
 // so singleton attributes like <Table border> will not be matched!
 bool
 HTMLEditor::IsTextPropertySetByContent(nsINode* aNode,
                                        nsIAtom* aProperty,
                                        const nsAString* aAttribute,