Bug 1367683 - Optimize initializing nsRange

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 05:28:43 -04:00 committed by Roy Tam
commit 9d8343e19c
16 changed files with 330 additions and 205 deletions

View file

@ -758,7 +758,12 @@ nsTextControlFrame::SetSelectionInternal(nsIDOMNode *aStartNode,
// we have access to the node.
nsCOMPtr<nsINode> start = do_QueryInterface(aStartNode);
nsCOMPtr<nsINode> end = do_QueryInterface(aEndNode);
nsresult rv = range->Set(start, aStartOffset, end, aEndOffset);
// XXXbz nsRange::SetStartAndEnd takes int32_t (and ranges generally work on
// int32_t), but we're passing uint32_t. The good news is that at this point
// our endpoints should really be within our length, so not really that big.
// And if they _are_ that big, SetStartAndEnd() will simply error out, which
// is not too bad for a case we don't expect to happen.
nsresult rv = range->SetStartAndEnd(start, aStartOffset, end, aEndOffset);
NS_ENSURE_SUCCESS(rv, rv);
// Get the selection, clear it and add the new range to it!