Bug 1414581 - Part 1. Require more nullptr check of parent node. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 06 Nov 2017 17:05:37 +0900
changeset 694752 8eb05064127e07fb465912b0ae395055ac69c02c
parent 693830 c2fe4b3b1b930b3e7fdb84eae44cec165394f322
child 694753 8f693ec7602db1185e229f6cf32440e90a7b58d0
push id88228
push userbmo:m_kato@ga2.so-net.ne.jp
push dateWed, 08 Nov 2017 06:53:02 +0000
reviewersmasayuki
bugs1414581, 1402904
milestone58.0a1
Bug 1414581 - Part 1. Require more nullptr check of parent node. r?masayuki Bug 1402904 added nullptr check for parent node, but I forgot to add this nullptr check of selected node for outdent command. So I need to add more nullptr check. MozReview-Commit-ID: Au9wrG6htk8
editor/libeditor/HTMLEditRules.cpp
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -4326,18 +4326,22 @@ HTMLEditRules::WillOutdent(Selection& aS
     bool curBlockQuoteIsIndentedWithCSS = false;
     for (uint32_t i = 0; i < arrayOfNodes.Length(); i++) {
       if (!arrayOfNodes[i]->IsContent()) {
         continue;
       }
       OwningNonNull<nsIContent> curNode = *arrayOfNodes[i]->AsContent();
 
       // Here's where we actually figure out what to do
-      nsCOMPtr<nsINode> curParent = curNode->GetParentNode();
-      int32_t offset = curParent ? curParent->IndexOf(curNode) : -1;
+      int32_t offset;
+      nsCOMPtr<nsINode> curParent =
+        EditorBase::GetNodeLocation(curNode, &offset);
+      if (!curParent) {
+        continue;
+      }
 
       // Is it a blockquote?
       if (curNode->IsHTMLElement(nsGkAtoms::blockquote)) {
         // If it is a blockquote, remove it.  So we need to finish up dealng
         // with any curBlockQuote first.
         if (curBlockQuote) {
           rv = OutdentPartOfBlock(*curBlockQuote, *firstBQChild, *lastBQChild,
                                   curBlockQuoteIsIndentedWithCSS,