mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1703040 - Upgrade !mIsPositioned assertion to diagnostic assert. r=masayuki
We are currently winding up with crashes that seem to be caused by ranges in a selection having start and end containers in disconnected trees. Most likely this has something to do with the ranges crossing shadow or native anonymous boundaries, but it isn't clear. This patch changes `DoSetRange` so we should hopefully assert as soon as we get into that situation, rather than when we try to inspect the range. The most obvious way to do this check would be to upgrade `AssertIfMismatchRootAndRangeBoundaries` from a debug assertion to a diagnostic assertion. Unfortunately, those checks are rather expensive, and this code should be fairly hot. Fortunately, the existing `!mIsPositioned` assertion should have the same effect in all of the situations I've been able to think of. I've re-checked the code a few times since I wrote the patch, and I believe it is sound. We should hopefully find out within a couple of weeks if we need to do more. Differential Revision: https://phabricator.services.mozilla.com/D162242
This commit is contained in:
parent
b1213c2c25
commit
1b1268b98a
@ -738,8 +738,8 @@ bool nsRange::IsPointComparableToRange(const nsINode& aContainer,
|
||||
}
|
||||
|
||||
if (!aContainer.IsInclusiveDescendantOf(mRoot)) {
|
||||
// TODO(emilio): Switch to ThrowWrongDocumentError, but IsPointInRange relies on the
|
||||
// error code right now in order to suppress the exception.
|
||||
// TODO(emilio): Switch to ThrowWrongDocumentError, but IsPointInRange
|
||||
// relies on the error code right now in order to suppress the exception.
|
||||
aRv.Throw(NS_ERROR_DOM_WRONG_DOCUMENT_ERR);
|
||||
return false;
|
||||
}
|
||||
@ -942,7 +942,7 @@ void nsRange::DoSetRange(const RangeBoundaryBase<SPT, SRT>& aStartBoundary,
|
||||
if (newCommonAncestor) {
|
||||
RegisterClosestCommonInclusiveAncestor(newCommonAncestor);
|
||||
} else {
|
||||
NS_ASSERTION(!mIsPositioned, "unexpected disconnected nodes");
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mIsPositioned, "unexpected disconnected nodes");
|
||||
mSelection = nullptr;
|
||||
MOZ_DIAGNOSTIC_ASSERT(
|
||||
!mRegisteredClosestCommonInclusiveAncestor,
|
||||
|
Loading…
x
Reference in New Issue
Block a user