Bug 1377989 - part10: Rename local variables, |parent| which is set to container of nsRange to |container| r?mats draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 11 Jul 2017 23:52:39 +0900
changeset 606933 ff0bd446f41064ba2854f21081ce0d1390d0233e
parent 606932 cf3813815a3aa77005c5d9155145bf03068ea10d
child 606934 324c183c9ad74b7a5bd77dda9e54473c7a33d83d
push id67831
push usermasayuki@d-toybox.com
push dateTue, 11 Jul 2017 15:21:54 +0000
reviewersmats
bugs1377989
milestone56.0a1
Bug 1377989 - part10: Rename local variables, |parent| which is set to container of nsRange to |container| r?mats MozReview-Commit-ID: 9w3O7MJEDBS
dom/base/Selection.cpp
dom/base/nsRange.cpp
dom/events/ContentEventHandler.cpp
editor/libeditor/HTMLEditRules.cpp
layout/generic/nsFrameSelection.cpp
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -2454,18 +2454,18 @@ Selection::RemoveRange(nsRange& aRange, 
 
 
 /*
  * Collapse sets the whole selection to be one point.
  */
 NS_IMETHODIMP
 Selection::Collapse(nsIDOMNode* aContainer, int32_t aOffset)
 {
-  nsCOMPtr<nsINode> parentNode = do_QueryInterface(aContainer);
-  return Collapse(parentNode, aOffset);
+  nsCOMPtr<nsINode> container = do_QueryInterface(aContainer);
+  return Collapse(container, aOffset);
 }
 
 NS_IMETHODIMP
 Selection::CollapseNative(nsINode* aContainer, int32_t aOffset)
 {
   return Collapse(aContainer, aOffset);
 }
 
@@ -2496,76 +2496,76 @@ Selection::Collapse(nsINode* aContainer,
 void
 Selection::Collapse(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
 {
   if (!mFrameSelection) {
     aRv.Throw(NS_ERROR_NOT_INITIALIZED); // Can't do selection
     return;
   }
 
-  nsCOMPtr<nsINode> parentNode = &aContainer;
+  nsCOMPtr<nsINode> container = &aContainer;
 
   RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
   frameSelection->InvalidateDesiredPos();
-  if (!IsValidSelectionPoint(frameSelection, parentNode)) {
+  if (!IsValidSelectionPoint(frameSelection, container)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
   nsresult result;
 
   RefPtr<nsPresContext> presContext = GetPresContext();
-  if (!presContext || presContext->Document() != parentNode->OwnerDoc()) {
+  if (!presContext || presContext->Document() != container->OwnerDoc()) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   // Cache current range is if there is because it may be reusable.
   RefPtr<nsRange> oldRange = !mRanges.IsEmpty() ? mRanges[0].mRange : nullptr;
 
   // Delete all of the current ranges
   Clear(presContext);
 
   // Turn off signal for table selection
   frameSelection->ClearTableCellSelection();
 
   // Hack to display the caret on the right line (bug 1237236).
   if (frameSelection->GetHint() != CARET_ASSOCIATE_AFTER &&
-      parentNode->IsContent()) {
+      container->IsContent()) {
     int32_t frameOffset;
     nsTextFrame* f =
-      do_QueryFrame(nsCaret::GetFrameAndOffset(this, parentNode,
+      do_QueryFrame(nsCaret::GetFrameAndOffset(this, container,
                                                aOffset, &frameOffset));
     if (f && f->IsAtEndOfLine() && f->HasSignificantTerminalNewline()) {
-      if ((parentNode->AsContent() == f->GetContent() &&
+      if ((container->AsContent() == f->GetContent() &&
            f->GetContentEnd() == int32_t(aOffset)) ||
-          (parentNode == f->GetContent()->GetParentNode() &&
-           parentNode->IndexOf(f->GetContent()) + 1 == int32_t(aOffset))) {
+          (container == f->GetContent()->GetParentNode() &&
+           container->IndexOf(f->GetContent()) + 1 == int32_t(aOffset))) {
         frameSelection->SetHint(CARET_ASSOCIATE_AFTER);
       }
     }
   }
 
   RefPtr<nsRange> range;
   // If the old range isn't referred by anybody other than this method,
   // we should reuse it for reducing the recreation cost.
   if (oldRange && oldRange->GetRefCount() == 1) {
     range = oldRange;
   } else {
-    range = new nsRange(parentNode);
+    range = new nsRange(container);
   }
-  result = range->CollapseTo(parentNode, aOffset);
+  result = range->CollapseTo(container, aOffset);
   if (NS_FAILED(result)) {
     aRv.Throw(result);
     return;
   }
 
 #ifdef DEBUG_SELECTION
-  nsCOMPtr<nsIContent> content = do_QueryInterface(parentNode);
-  nsCOMPtr<nsIDocument> doc = do_QueryInterface(parentNode);
-  printf ("Sel. Collapse to %p %s %d\n", parentNode.get(),
+  nsCOMPtr<nsIContent> content = do_QueryInterface(container);
+  nsCOMPtr<nsIDocument> doc = do_QueryInterface(container);
+  printf ("Sel. Collapse to %p %s %d\n", container.get(),
           content ? nsAtomCString(content->NodeInfo()->NameAtom()).get()
                   : (doc ? "DOCUMENT" : "???"),
           aOffset);
 #endif
 
   int32_t rangeIndex = -1;
   result = AddItem(range, &rangeIndex);
   if (NS_FAILED(result)) {
@@ -2619,22 +2619,22 @@ Selection::CollapseToStart(ErrorResult& 
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   if (mFrameSelection) {
     int16_t reason = mFrameSelection->PopReason() | nsISelectionListener::COLLAPSETOSTART_REASON;
     mFrameSelection->PostReason(reason);
   }
-  nsINode* parent = firstRange->GetStartContainer();
-  if (!parent) {
+  nsINode* container = firstRange->GetStartContainer();
+  if (!container) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
-  Collapse(*parent, firstRange->StartOffset(), aRv);
+  Collapse(*container, firstRange->StartOffset(), aRv);
 }
 
 /*
  * Sets the whole selection to be one point
  * at the end of the current selection
  */
 NS_IMETHODIMP
 Selection::CollapseToEnd()
@@ -2668,22 +2668,22 @@ Selection::CollapseToEnd(ErrorResult& aR
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   if (mFrameSelection) {
     int16_t reason = mFrameSelection->PopReason() | nsISelectionListener::COLLAPSETOEND_REASON;
     mFrameSelection->PostReason(reason);
   }
-  nsINode* parent = lastRange->GetEndContainer();
-  if (!parent) {
+  nsINode* container = lastRange->GetEndContainer();
+  if (!container) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
-  Collapse(*parent, lastRange->EndOffset(), aRv);
+  Collapse(*container, lastRange->EndOffset(), aRv);
 }
 
 /*
  * IsCollapsed -- is the whole selection just one point, or unset?
  */
 bool
 Selection::IsCollapsed() const
 {
@@ -2839,18 +2839,18 @@ 2  1  a = continue selection from 2 to 1
 
 /*
  * Extend extends the selection away from the anchor.
  * We don't need to know the direction, because we always change the focus.
  */
 NS_IMETHODIMP
 Selection::Extend(nsIDOMNode* aContainer, int32_t aOffset)
 {
-  nsCOMPtr<nsINode> parentNode = do_QueryInterface(aContainer);
-  return Extend(parentNode, aOffset);
+  nsCOMPtr<nsINode> container = do_QueryInterface(aContainer);
+  return Extend(container, aOffset);
 }
 
 NS_IMETHODIMP
 Selection::ExtendNative(nsINode* aContainer, int32_t aOffset)
 {
   return Extend(aContainer, aOffset);
 }
 
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -750,23 +750,23 @@ nsRange::ParentChainChanged(nsIContent *
 }
 
 /******************************************************
  * Utilities for comparing points: API from nsIDOMRange
  ******************************************************/
 NS_IMETHODIMP
 nsRange::IsPointInRange(nsIDOMNode* aContainer, int32_t aOffset, bool* aResult)
 {
-  nsCOMPtr<nsINode> parent = do_QueryInterface(aContainer);
-  if (!parent) {
+  nsCOMPtr<nsINode> container = do_QueryInterface(aContainer);
+  if (!container) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
-  *aResult = IsPointInRange(*parent, aOffset, rv);
+  *aResult = IsPointInRange(*container, aOffset, rv);
   return rv.StealNSResult();
 }
 
 bool
 nsRange::IsPointInRange(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
 {
   uint16_t compareResult = ComparePoint(aContainer, aOffset, aRv);
   // If the node isn't in the range's document, it clearly isn't in the range.
@@ -778,21 +778,21 @@ nsRange::IsPointInRange(nsINode& aContai
   return compareResult == 0;
 }
 
 // returns -1 if point is before range, 0 if point is in range,
 // 1 if point is after range.
 NS_IMETHODIMP
 nsRange::ComparePoint(nsIDOMNode* aContainer, int32_t aOffset, int16_t* aResult)
 {
-  nsCOMPtr<nsINode> parent = do_QueryInterface(aContainer);
-  NS_ENSURE_TRUE(parent, NS_ERROR_DOM_HIERARCHY_REQUEST_ERR);
+  nsCOMPtr<nsINode> container = do_QueryInterface(aContainer);
+  NS_ENSURE_TRUE(container, NS_ERROR_DOM_HIERARCHY_REQUEST_ERR);
 
   ErrorResult rv;
-  *aResult = ComparePoint(*parent, aOffset, rv);
+  *aResult = ComparePoint(*container, aOffset, rv);
   return rv.StealNSResult();
 }
 
 int16_t
 nsRange::ComparePoint(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
 {
   // our range is in a good state?
   if (!mIsPositioned) {
@@ -1212,23 +1212,23 @@ nsRange::SetStart(nsINode& aNode, uint32
 
   AutoInvalidateSelection atEndOfBlock(this);
   aRv = SetStart(&aNode, aOffset);
 }
 
 NS_IMETHODIMP
 nsRange::SetStart(nsIDOMNode* aContainer, int32_t aOffset)
 {
-  nsCOMPtr<nsINode> parent = do_QueryInterface(aContainer);
-  if (!parent) {
+  nsCOMPtr<nsINode> container = do_QueryInterface(aContainer);
+  if (!container) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
-  SetStart(*parent, aOffset, rv);
+  SetStart(*container, aOffset, rv);
   return rv.StealNSResult();
 }
 
 /* virtual */ nsresult
 nsRange::SetStart(nsINode* aContainer, int32_t aOffset)
 {
   nsINode* newRoot = IsValidBoundary(aContainer);
   if (!newRoot) {
@@ -1268,18 +1268,18 @@ nsRange::SetStartBefore(nsINode& aNode, 
   if (!nsContentUtils::LegacyIsCallerNativeCode() &&
       !nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   AutoInvalidateSelection atEndOfBlock(this);
   int32_t offset = -1;
-  nsINode* parent = GetContainerAndOffsetBefore(&aNode, &offset);
-  aRv = SetStart(parent, offset);
+  nsINode* container = GetContainerAndOffsetBefore(&aNode, &offset);
+  aRv = SetStart(container, offset);
 }
 
 NS_IMETHODIMP
 nsRange::SetStartBefore(nsIDOMNode* aSibling)
 {
   nsCOMPtr<nsINode> sibling = do_QueryInterface(aSibling);
   if (!sibling) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
@@ -1304,18 +1304,18 @@ nsRange::SetStartAfter(nsINode& aNode, E
   if (!nsContentUtils::LegacyIsCallerNativeCode() &&
       !nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   AutoInvalidateSelection atEndOfBlock(this);
   int32_t offset = -1;
-  nsINode* parent = GetContainerAndOffsetAfter(&aNode, &offset);
-  aRv = SetStart(parent, offset);
+  nsINode* container = GetContainerAndOffsetAfter(&aNode, &offset);
+  aRv = SetStart(container, offset);
 }
 
 NS_IMETHODIMP
 nsRange::SetStartAfter(nsIDOMNode* aSibling)
 {
   nsCOMPtr<nsINode> sibling = do_QueryInterface(aSibling);
   if (!sibling) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
@@ -1344,23 +1344,23 @@ nsRange::SetEnd(nsINode& aNode, uint32_t
   }
   AutoInvalidateSelection atEndOfBlock(this);
   aRv = SetEnd(&aNode, aOffset);
 }
 
 NS_IMETHODIMP
 nsRange::SetEnd(nsIDOMNode* aContainer, int32_t aOffset)
 {
-  nsCOMPtr<nsINode> parent = do_QueryInterface(aContainer);
-  if (!parent) {
+  nsCOMPtr<nsINode> container = do_QueryInterface(aContainer);
+  if (!container) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
-  SetEnd(*parent, aOffset, rv);
+  SetEnd(*container, aOffset, rv);
   return rv.StealNSResult();
 }
 
 /* virtual */ nsresult
 nsRange::SetEnd(nsINode* aContainer, int32_t aOffset)
 {
   nsINode* newRoot = IsValidBoundary(aContainer);
   if (!newRoot) {
@@ -1462,18 +1462,18 @@ nsRange::SetEndBefore(nsINode& aNode, Er
   if (!nsContentUtils::LegacyIsCallerNativeCode() &&
       !nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   AutoInvalidateSelection atEndOfBlock(this);
   int32_t offset = -1;
-  nsINode* parent = GetContainerAndOffsetBefore(&aNode, &offset);
-  aRv = SetEnd(parent, offset);
+  nsINode* container = GetContainerAndOffsetBefore(&aNode, &offset);
+  aRv = SetEnd(container, offset);
 }
 
 NS_IMETHODIMP
 nsRange::SetEndBefore(nsIDOMNode* aSibling)
 {
   nsCOMPtr<nsINode> sibling = do_QueryInterface(aSibling);
   if (!sibling) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
@@ -1498,18 +1498,18 @@ nsRange::SetEndAfter(nsINode& aNode, Err
   if (!nsContentUtils::LegacyIsCallerNativeCode() &&
       !nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   AutoInvalidateSelection atEndOfBlock(this);
   int32_t offset = -1;
-  nsINode* parent = GetContainerAndOffsetAfter(&aNode, &offset);
-  aRv = SetEnd(parent, offset);
+  nsINode* container = GetContainerAndOffsetAfter(&aNode, &offset);
+  aRv = SetEnd(container, offset);
 }
 
 NS_IMETHODIMP
 nsRange::SetEndAfter(nsIDOMNode* aSibling)
 {
   nsCOMPtr<nsINode> sibling = do_QueryInterface(aSibling);
   if (!sibling) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
@@ -1569,31 +1569,31 @@ void
 nsRange::SelectNode(nsINode& aNode, ErrorResult& aRv)
 {
   if (!nsContentUtils::LegacyIsCallerNativeCode() &&
       !nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
-  nsINode* parent = aNode.GetParentNode();
-  nsINode* newRoot = IsValidBoundary(parent);
+  nsINode* container = aNode.GetParentNode();
+  nsINode* newRoot = IsValidBoundary(container);
   if (!newRoot) {
     aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
     return;
   }
 
-  int32_t index = parent->IndexOf(&aNode);
+  int32_t index = container->IndexOf(&aNode);
   if (index < 0) {
     aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
     return;
   }
 
   AutoInvalidateSelection atEndOfBlock(this);
-  DoSetRange(parent, index, parent, index + 1, newRoot);
+  DoSetRange(container, index, container, index + 1, newRoot);
 }
 
 NS_IMETHODIMP
 nsRange::SelectNodeContents(nsIDOMNode* aN)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aN);
   NS_ENSURE_TRUE(node, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
 
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -2850,42 +2850,42 @@ ContentEventHandler::AdjustCollapsedRang
 {
   MOZ_ASSERT(aRange);
   MOZ_ASSERT(aRange->Collapsed());
 
   if (!aRange || !aRange->Collapsed()) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  nsCOMPtr<nsINode> parentNode = aRange->GetStartContainer();
+  nsCOMPtr<nsINode> container = aRange->GetStartContainer();
   int32_t offsetInParentNode = aRange->StartOffset();
-  if (NS_WARN_IF(!parentNode) || NS_WARN_IF(offsetInParentNode < 0)) {
+  if (NS_WARN_IF(!container) || NS_WARN_IF(offsetInParentNode < 0)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   // If the node is text node, we don't need to modify aRange.
-  if (parentNode->IsNodeOfType(nsINode::eTEXT)) {
+  if (container->IsNodeOfType(nsINode::eTEXT)) {
     return NS_OK;
   }
 
-  // If the parent is not a text node but it has a text node at the offset,
+  // If the container is not a text node but it has a text node at the offset,
   // we should adjust the range into the text node.
   // NOTE: This is emulating similar situation of EditorBase.
   nsINode* childNode = nullptr;
   int32_t offsetInChildNode = -1;
-  if (!offsetInParentNode && parentNode->HasChildren()) {
-    // If the range is the start of the parent, adjusted the range to the
+  if (!offsetInParentNode && container->HasChildren()) {
+    // If the range is the start of the container, adjusted the range to the
     // start of the first child.
-    childNode = parentNode->GetFirstChild();
+    childNode = container->GetFirstChild();
     offsetInChildNode = 0;
   } else if (static_cast<uint32_t>(offsetInParentNode) <
-               parentNode->GetChildCount()) {
+               container->GetChildCount()) {
     // If the range is next to a child node, adjust the range to the end of
     // the previous child.
-    childNode = parentNode->GetChildAt(offsetInParentNode - 1);
+    childNode = container->GetChildAt(offsetInParentNode - 1);
     offsetInChildNode = childNode->Length();
   }
 
   // But if the found node isn't a text node, we cannot modify the range.
   if (!childNode || !childNode->IsNodeOfType(nsINode::eTEXT) ||
       NS_WARN_IF(offsetInChildNode < 0)) {
     return NS_OK;
   }
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -3224,31 +3224,32 @@ HTMLEditRules::WillMakeList(Selection* a
         NS_ENSURE_STATE(mHTMLEditor);
         rv = mHTMLEditor->DeleteNode(node);
         NS_ENSURE_SUCCESS(rv, rv);
       }
     }
 
     // get selection location
     NS_ENSURE_STATE(aSelection->RangeCount());
-    nsCOMPtr<nsINode> parent = aSelection->GetRangeAt(0)->GetStartContainer();
+    nsCOMPtr<nsINode> container =
+      aSelection->GetRangeAt(0)->GetStartContainer();
     int32_t offset = aSelection->GetRangeAt(0)->StartOffset();
-    NS_ENSURE_STATE(parent);
+    NS_ENSURE_STATE(container);
 
     // make sure we can put a list here
     NS_ENSURE_STATE(mHTMLEditor);
-    if (!mHTMLEditor->CanContainTag(*parent, listType)) {
+    if (!mHTMLEditor->CanContainTag(*container, listType)) {
       *aCancel = true;
       return NS_OK;
     }
-    rv = SplitAsNeeded(listType, parent, offset);
+    rv = SplitAsNeeded(listType, container, offset);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_STATE(mHTMLEditor);
     nsCOMPtr<Element> theList =
-      mHTMLEditor->CreateNode(listType, parent, offset);
+      mHTMLEditor->CreateNode(listType, container, offset);
     NS_ENSURE_STATE(theList);
 
     NS_ENSURE_STATE(mHTMLEditor);
     nsCOMPtr<Element> theListItem =
       mHTMLEditor->CreateNode(itemType, theList, 0);
     NS_ENSURE_STATE(theListItem);
 
     // remember our new block for postprocessing
@@ -3570,65 +3571,65 @@ HTMLEditRules::MakeBasicBlock(Selection&
                              arrayOfNodes);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If nothing visible in list, make an empty block
   if (ListIsEmptyLine(arrayOfNodes)) {
     // Get selection location
     NS_ENSURE_STATE(aSelection.GetRangeAt(0) &&
                     aSelection.GetRangeAt(0)->GetStartContainer());
-    OwningNonNull<nsINode> parent =
+    OwningNonNull<nsINode> container =
       *aSelection.GetRangeAt(0)->GetStartContainer();
     int32_t offset = aSelection.GetRangeAt(0)->StartOffset();
 
     if (&blockType == nsGkAtoms::normal ||
         &blockType == nsGkAtoms::_empty) {
       // We are removing blocks (going to "body text")
-      NS_ENSURE_TRUE(htmlEditor->GetBlock(parent), NS_ERROR_NULL_POINTER);
-      OwningNonNull<Element> curBlock = *htmlEditor->GetBlock(parent);
+      NS_ENSURE_TRUE(htmlEditor->GetBlock(container), NS_ERROR_NULL_POINTER);
+      OwningNonNull<Element> curBlock = *htmlEditor->GetBlock(container);
       if (HTMLEditUtils::IsFormatNode(curBlock)) {
         // If the first editable node after selection is a br, consume it.
         // Otherwise it gets pushed into a following block after the split,
         // which is visually bad.
         nsCOMPtr<nsIContent> brNode =
-          htmlEditor->GetNextHTMLNode(parent, offset);
+          htmlEditor->GetNextHTMLNode(container, offset);
         if (brNode && brNode->IsHTMLElement(nsGkAtoms::br)) {
           rv = htmlEditor->DeleteNode(brNode);
           NS_ENSURE_SUCCESS(rv, rv);
         }
         // Do the splits!
-        offset = htmlEditor->SplitNodeDeep(curBlock, *parent->AsContent(),
+        offset = htmlEditor->SplitNodeDeep(curBlock, *container->AsContent(),
                                             offset,
                                             HTMLEditor::EmptyContainers::no);
         NS_ENSURE_STATE(offset != -1);
         // Put a br at the split point
         brNode = htmlEditor->CreateBR(curBlock->GetParentNode(), offset);
         NS_ENSURE_STATE(brNode);
         // Put selection at the split point
         rv = aSelection.Collapse(curBlock->GetParentNode(), offset);
         // Don't restore the selection
         selectionRestorer.Abort();
         NS_ENSURE_SUCCESS(rv, rv);
       }
       // Else nothing to do!
     } else {
       // We are making a block.  Consume a br, if needed.
       nsCOMPtr<nsIContent> brNode =
-        htmlEditor->GetNextHTMLNode(parent, offset, true);
+        htmlEditor->GetNextHTMLNode(container, offset, true);
       if (brNode && brNode->IsHTMLElement(nsGkAtoms::br)) {
         rv = htmlEditor->DeleteNode(brNode);
         NS_ENSURE_SUCCESS(rv, rv);
         // We don't need to act on this node any more
         arrayOfNodes.RemoveElement(brNode);
       }
       // Make sure we can put a block here
-      rv = SplitAsNeeded(blockType, parent, offset);
+      rv = SplitAsNeeded(blockType, container, offset);
       NS_ENSURE_SUCCESS(rv, rv);
       nsCOMPtr<Element> block =
-        htmlEditor->CreateNode(&blockType, parent, offset);
+        htmlEditor->CreateNode(&blockType, container, offset);
       NS_ENSURE_STATE(block);
       // Remember our new block for postprocessing
       mNewBlock = block;
       // Delete anything that was in the list of nodes
       while (!arrayOfNodes.IsEmpty()) {
         OwningNonNull<nsINode> curNode = arrayOfNodes[0];
         rv = htmlEditor->DeleteNode(curNode);
         NS_ENSURE_SUCCESS(rv, rv);
@@ -3749,26 +3750,26 @@ HTMLEditRules::WillCSSIndent(Selection* 
     rv = GetNodesFromSelection(*aSelection, EditAction::indent, arrayOfNodes);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // if nothing visible in list, make an empty block
   if (ListIsEmptyLine(arrayOfNodes)) {
     // get selection location
     NS_ENSURE_STATE(aSelection->RangeCount());
-    nsCOMPtr<nsINode> parent = aSelection->GetRangeAt(0)->GetStartContainer();
+    nsCOMPtr<nsINode> container = aSelection->GetRangeAt(0)->GetStartContainer();
     int32_t offset = aSelection->GetRangeAt(0)->StartOffset();
-    NS_ENSURE_STATE(parent);
+    NS_ENSURE_STATE(container);
 
     // make sure we can put a block here
-    rv = SplitAsNeeded(*nsGkAtoms::div, parent, offset);
+    rv = SplitAsNeeded(*nsGkAtoms::div, container, offset);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_STATE(mHTMLEditor);
     nsCOMPtr<Element> theBlock = mHTMLEditor->CreateNode(nsGkAtoms::div,
-                                                         parent, offset);
+                                                         container, offset);
     NS_ENSURE_STATE(theBlock);
     // remember our new block for postprocessing
     mNewBlock = theBlock;
     ChangeIndentation(*theBlock, Change::plus);
     // delete anything that was in the list of nodes
     while (!arrayOfNodes.IsEmpty()) {
       OwningNonNull<nsINode> curNode = arrayOfNodes[0];
       NS_ENSURE_STATE(mHTMLEditor);
@@ -3936,26 +3937,27 @@ HTMLEditRules::WillHTMLIndent(Selection*
   nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
   rv = GetNodesForOperation(arrayOfRanges, arrayOfNodes, EditAction::indent);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // if nothing visible in list, make an empty block
   if (ListIsEmptyLine(arrayOfNodes)) {
     // get selection location
     NS_ENSURE_STATE(aSelection->RangeCount());
-    nsCOMPtr<nsINode> parent = aSelection->GetRangeAt(0)->GetStartContainer();
+    nsCOMPtr<nsINode> container =
+      aSelection->GetRangeAt(0)->GetStartContainer();
     int32_t offset = aSelection->GetRangeAt(0)->StartOffset();
-    NS_ENSURE_STATE(parent);
+    NS_ENSURE_STATE(container);
 
     // make sure we can put a block here
-    rv = SplitAsNeeded(*nsGkAtoms::blockquote, parent, offset);
+    rv = SplitAsNeeded(*nsGkAtoms::blockquote, container, offset);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_STATE(mHTMLEditor);
     nsCOMPtr<Element> theBlock = mHTMLEditor->CreateNode(nsGkAtoms::blockquote,
-                                                         parent, offset);
+                                                         container, offset);
     NS_ENSURE_STATE(theBlock);
     // remember our new block for postprocessing
     mNewBlock = theBlock;
     // delete anything that was in the list of nodes
     while (!arrayOfNodes.IsEmpty()) {
       OwningNonNull<nsINode> curNode = arrayOfNodes[0];
       NS_ENSURE_STATE(mHTMLEditor);
       rv = mHTMLEditor->DeleteNode(curNode);
--- a/layout/generic/nsFrameSelection.cpp
+++ b/layout/generic/nsFrameSelection.cpp
@@ -2381,24 +2381,27 @@ printf("HandleTableSelection: Unselectin
 #endif
         for( int32_t i = 0; i < rangeCount; i++)
         {
           // Strong reference, because sometimes we want to remove
           // this range, and then we might be the only owner.
           RefPtr<nsRange> range = mDomSelections[index]->GetRangeAt(i);
           if (!range) return NS_ERROR_NULL_POINTER;
 
-          nsINode* parent = range->GetStartContainer();
-          if (!parent) return NS_ERROR_NULL_POINTER;
+          nsINode* container = range->GetStartContainer();
+          if (!container) {
+            return NS_ERROR_NULL_POINTER;
+          }
 
           int32_t offset = range->StartOffset();
           // Be sure previous selection is a table cell
-          nsIContent* child = parent->GetChildAt(offset);
-          if (child && IsCell(child))
-            previousCellParent = parent;
+          nsIContent* child = container->GetChildAt(offset);
+          if (child && IsCell(child)) {
+            previousCellParent = container;
+          }
 
           // We're done if we didn't find parent of a previously-selected cell
           if (!previousCellParent) break;
 
           if (previousCellParent == aParentContent && offset == aContentOffset)
           {
             // Cell is already selected
             if (rangeCount == 1)