/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
nsINode* previousCommonAncestor = mCommonAncestor; if (startRoot == endRoot) {
MOZ_ASSERT(!startRoot && !endRoot);
MOZ_ASSERT(!aOwner); // This should be the case when Release() is called.
mCommonAncestor = startRoot;
mOwner = nullptr;
} else {
mCommonAncestor =
nsContentUtils::GetClosestCommonShadowIncludingInclusiveAncestor(
mStart.Container(), mEnd.Container());
MOZ_ASSERT_IF(mOwner, mOwner == aOwner); if (!mOwner) {
mOwner = aOwner;
}
}
if (previousCommonAncestor != mCommonAncestor) { if (previousCommonAncestor) {
previousCommonAncestor->RemoveMutationObserver(this);
} if (mCommonAncestor) {
mCommonAncestor->AddMutationObserver(this);
}
}
} void CrossShadowBoundaryRange::ContentWillBeRemoved(nsIContent* aChild, const BatchRemovalState*) { // It's unclear from the spec about what should the selection be after // DOM mutation. See https://github.com/w3c/selection-api/issues/168 // // For now, we just clear the selection if the removed node is related // to mStart or mEnd.
MOZ_DIAGNOSTIC_ASSERT(mOwner);
MOZ_DIAGNOSTIC_ASSERT(mOwner->GetCrossShadowBoundaryRange() == this);
// For now CrossShadowBoundaryRange::CharacterDataChanged is only meant // to handle the character removal initiated by nsRange::CutContents. void CrossShadowBoundaryRange::CharacterDataChanged(
nsIContent* aContent, const CharacterDataChangeInfo& aInfo) { // When aInfo.mDetails is present, it means the character data was // changed due to splitText() or normalize(), which shouldn't be the // case for nsRange::CutContents, so we return early. if (aInfo.mDetails) { return;
}
MOZ_ASSERT(aContent);
MOZ_ASSERT(mIsPositioned);
auto MaybeCreateNewBoundary =
[aContent,
&aInfo](const RangeBoundary& aBoundary) -> Maybe<RawRangeBoundary> { // If the changed node contains our start boundary and the change starts // before the boundary we'll need to adjust the offset. if (aContent == aBoundary.Container() && // aInfo.mChangeStart is the offset where the change starts, if it's // smaller than the offset of aBoundary, it means the characters // before the selected content is changed (i.e, removed), so the // offset of aBoundary needs to be adjusted.
aInfo.mChangeStart <
*aBoundary.Offset(
RangeBoundary::OffsetFilter::kValidOrInvalidOffsets)) {
RawRangeBoundary newStart =
nsRange::ComputeNewBoundaryWhenBoundaryInsideChangedText(
aInfo, aBoundary.AsRaw()); return Some(newStart);
} return Nothing();
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.