Bug 1406215 - Part 1: Remove a useless bounds check for a selection range offset; r=masayuki
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 05 Oct 2017 19:37:38 -0400
changeset 427364 756a3fa73513fdddaa4cbc03f3af2464cee6c5ff
parent 427363 80d704c6678142343050bb95e630a24727a240a7
child 427365 3edd962139b648d3b8b22e70d5a17af3414de6e4
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersmasayuki
bugs1406215
milestone58.0a1
Bug 1406215 - Part 1: Remove a useless bounds check for a selection range offset; r=masayuki This offset is obtained from a Range, so it doesn't need to be validated.
editor/txtsvc/nsTextServicesDocument.cpp
--- a/editor/txtsvc/nsTextServicesDocument.cpp
+++ b/editor/txtsvc/nsTextServicesDocument.cpp
@@ -2387,23 +2387,16 @@ nsTextServicesDocument::GetCollapsedSele
     //      children are in the text block.
 
     // If the parent has children, position the iterator
     // on the child that is to the left of the offset.
 
     uint32_t childIndex = offset;
 
     if (childIndex > 0) {
-      uint32_t numChildren = parent->GetChildCount();
-      NS_ASSERTION(childIndex <= numChildren, "Invalid selection offset!");
-
-      if (childIndex > numChildren) {
-        childIndex = numChildren;
-      }
-
       childIndex -= 1;
     }
 
     nsIContent* content = parent->GetChildAt(childIndex);
     NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
 
     rv = iter->PositionAt(content);
     NS_ENSURE_SUCCESS(rv, rv);