Bug 1414581 - Part 1. Require more nullptr check of parent node. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 06 Nov 2017 17:05:37 +0900
changeset 443949 c95fd22b6a4f4741e38aa1a1a68e944ccf31400d
parent 443948 901652a2298bb1e2a436dfbeba959899eb84adf8
child 443950 9903b9dbd27f2b5183c2a4c3bf6b9ed7b4d34fbd
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1414581, 1402904
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 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
@@ -4356,18 +4356,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,