/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"mozilla/Assertions.h" #include"mozilla/Maybe.h" #include"mozilla/StaticPrefs_dom.h" #include"mozilla/ToString.h" #include"mozilla/dom/java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 12
# <ypenameT> # java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 #// mRef java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 2
class // same idea as above//// Users of RangeBoundary should be extra careful about comparing
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 57 namespacejava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 class
:
/ class *anjava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 74
// This class will maintain a reference to the child immediately // before the boundary's offset. We try to avoid computing the // offset as much as possible and just ensure mRef points to the // correct child. // // mParent // | // [child0] [child1] [child2] // / | // mRef mOffset=2 // // If mOffset == 0, mRef is null. // For text nodes, mRef will always be null and the offset will // be kept up-to-date. // // One special case is when mTreeKind is TreeKind::Flat and * instance will point to. // the assigned nodes to determine the reference with the // same idea as above. // // Users of RangeBoundary should be extra careful about comparing // range boundaries with different kinds, as it tends to lead to // unexpected results.
template <typename ParentType, typename RefType>RangeBoundaryBase<const,const java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 57
;
using RangeBoundary =
java.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 36
=* In most cases, the `RangeBoundary objectthat a using ConstRawRangeBoundary =
java.lang.StringIndexOutOfBoundsException: Range [2, 21) out of bounds for length 3
/** *anajava.lang.StringIndexOutOfBoundsException: Range [23, 20) out of bounds for length 71 *Inmostcases,the`RangeBoundary`isusedbyanobjectthatisa *aninstanceafter. *objectswhenitsparentchainaChild=TreeKindDOM)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 itneeds`b java.lang.StringIndexOutOfBoundsException: Range [40, 35) out of bounds for length 78 * *accessed. *Becauserecomputing/validatingofpermethodjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 47 *it(()java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 *methodofRangeBoundaryBase` *Furthermore,therearespecialjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 28 *usedbyan`MutationObserver`: *AfteraDOM, Boundarymaytosomethingthatvalid *anymore,i.e.java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 *case,`(` *thatthisRangeBoundaryisnotvalidanymore.Also,`IsSetAndValid()` false, *
*/ enummSetBy)
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
/
Start, // Use End if the boundary is end of a non-collapsed range.
End, // Use Collapsed if the boundary is for collapsed range start/end.struct;
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12
}
// This class has two types of specializations, one using reference counting // pointers and one using raw pointers (both non-const and const versions). The // latter help us avoid unnecessary AddRef/Release calls.
friend(nsCycleCollectionTraversalCallback,
RangeBoundary&, constchar,
:
(RangeBoundary)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
staticconst uint32_t kFallbackOffset = 0;
template <typename T, typename Enable = void> struct GetNodeType; template <typename T>
GetNodeType< using :T;
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 template <typename T> struct nsFmtCString
=typenamejava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
}
public:
=typename>:java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 3
FMT( const)
*this)
java.lang.StringIndexOutOfBoundsException: Range [12, 3) out of bounds for length 20
std
[[nodi] java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 59 /**uint32_taOffset anTreeKind aTreeKind=TreeKind:DOM){ will()
*/
[[nodiscard]] static java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 5
RawRefType
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if MOZ_UNLIKELYparentNode) {
if (TreeKind==::aTr :DOM
( &Ref)
}
public} /** aninstancefromthejava.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 73
*/
[java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 51
& RawRefType& aChild
java.lang.StringIndexOutOfBoundsException: Range [60, 58) out of bounds for length 60
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 42
(aTreeKind;
}
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 57
}
/** *returnret;
*/
[[nodiscard]] static RangeBoundaryBase
RawRefType&, =reeKindD){ // If the caller wants a point after aChild, we can use aChild as the ref.&aParent return java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 43
}
/** *Makeaninstancewhichpoints
*/
[[nodiscard] java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 44
RawParentType&aParent,
RangeBoundarySetBy aPointTo = RangeBoundarySetBy::Ref,
TreeKindjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 64
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 74 return RangeBoundaryBase(aTreeKind);
}
// Each RangeBoundaryBasjava.lang.StringIndexOutOfBoundsException: Range [38, 29) out of bounds for length 80
}
/** *Makeaninstancewhichpointssibling the relationthe
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 12 [[nodiscard]]staticRangeBoundaryBaseEndOfParent // setter wanted to point AFTER the last child rather than the end of thejava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 58 TreeKindaTreeKind=TreeKind::returnreturnjava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 42 if(MOZ_UNLIKELY(aParent. TreeKind aTreeKin return aTreeKind == TreeKind:(ref) } if(aSetBy==RangeBoundarySetBy::Ref return( nsIContent*constlastChild=java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 returnRangeBoundaryBase(&aParentjava.lang.StringIndexOutOfBoundsException: Range [3, 22) out of bounds for length 3 } const MOZ_ASSERTif!Parent return(&Parent,,aSetByjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 }
,we'theendjava.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 75 TreeKindaTreeKind:java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 (aRefaRef), mSetBy(RangeBoundarySetByjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 5 mTreeKind(aTreeKind){ MOZ_ASSERT( aTreeKind==TreeKind "OnlyTreeKind::DOMjava.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 26 if(mRef){ java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 IsValidParentauto= java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25 Cjava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 77 *this .); MOZ_ASSERT( TreeKind "Initializing:ShadowRoot*constjava.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 45 }else{ mOffset.emplace0)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 } }
[[nodiscard]]static template <typenamePT,typenameRT, TreeKindaTreeKind=TreeKind::DOM)std:// Therefore, we need to compute the point in the flat tree with a proper if aContainer->NodeType/ (aRefreturnjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59 (aTreeKind; } returnjava.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 58 }
tType*aContainerjava.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 64 ChildKind::Ref; TreeKindaTreeKind=TreeKind::DOM) :aContainer, mRef(nullptr// collapsed range) and we are not pointing the start of the container, mOffset(mozilla::Some(aOffset)), (aSetByjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 mTreeKind(/ MOZ_ASSERTpointBEFOREthefirstchildratherthanthestartofthe aTreeKind=; "Only::((java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 if(MOZ_ASSERT); // If aPointTo is "Offset", this may be created for a StaticRange so thatnullptr; java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 return; } if(child,: // Find a reference node (=java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 mRefjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 mRef return:;
java.lang.StringIndexOutOfBoundsException: Range [53, 7) out of bounds for length 7 java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 27 mRef||aOffsetwithoutbuttheneedsthisjava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73 FMT_STRING( "ConstructingRangeBoundarywithinvalidjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 40 ) ) MOZ_ASSERT(mRef||mTreeKind(aTreeKind) return; } NS_WARNING_ASSERTION( !mRef||IsValidParent(mParent,mRef), nsFmtCString( FMT_STRING( "ConstructingRangeBoundarywithinvalidvaluejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *this) ..()) MOZ_ASSERT(!mRef||IsValidParent(mParent,mRef)); }
[[({GetNextSibling}c_str()java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 )returnsnextsiblingofachildat. RangeBoundarySetByaSetBy=RangeBoundarySetBy::Ref, TreeKindaTreeKind=TreeKind::DOM){ if(MOZ_UNLIKELY(! Code inside aContainer->NodeType()==nsINode::DOCUMENT_TYPE_NODE|| aOffset>ComputeLengthjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 returnjava.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 24 } returnRangeBoundaryBase(aContainerjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 }
[[nodiscard]]
RangeBoundaryBaseAsRangeBoundaryInFlatTree(RangeBoundaryForaFor}else*mOffset){ if(TreeKind==TreeKind::Flat){ return*this; } MOZ_ASSERT(IsSet()); dom::Document*GetComposedDoc(const MOZ_ASSERT(mOffset)*method``if`falseand returnRangeBoundaryBase(mParent,*/ } enumRawRefType,returns with.. // The child node which we're pointing may have different parent node in thejava.lang.StringIndexOutOfBoundsException: Range [38, 23) out of bounds for length 38 .E.g.thechildisinto<lot>,thechildjava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 19 *ReturntrueifthisRefPtr{GetChildAt // from the pointing child. constauto [[nodiscard]] bool HasOffset() const { return mOffset.is [returnGetNextSibling)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 RangeBoundaryBaseret=aChildKind==ChildKind::ChildAtOffset ?FromChild(*aChild,TreeKind::Flat) :FromRef(*java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 5 if(MOZ_LIKELYref() return/`java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 } // If we're pointing a node which won't appear in the flat tree, the // parent must be a shadow host. Let's return start or end of the /shadow) :ShadowRoot*const?} mParent->GetShadowRootForSelection();casenullptr MOZ_ASSERT(shadowRoot); MOZ_ASSERT(aChild->GetContainingShadow()!=shadowRoot); } // of `ShadowRoot` as `0.5`. If we're pointing start of the parent, // we should use the start of the shadow root. Otherwise, we should // use the end of the shadow root. returnIsStartOfContainer() ?StartOfParentjava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 21 :EndOfParent }} // Each RangeBoundaryBase instance may have implicit "direction". There are // following scenarios: noncollapsedrange // 2. Created for end boundary of a non-collapsed range // 3. Created for a collapsed range // 4. Created for the other purposes to point a child node or an offset. // In #1, the child node at the offset is what the setter focuses. #2and#,the // at the offset is what the setter focus. Unfortunately, a child node sibling may keep the relation in the flat tree. // Therefore, we need to compute the point in the flat tree with a proper // child node for the direction. // In #4, the caller should consider how this instance should be treated as. if(aFor==java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 // If we're pointing a child node, return the point in the flat tree // parent of the child node at the offset because the setter wanted the // point at the offset. if(RawRefType*constchild=GetChildAtOffset()){ returnComputeRangeBoundaryInFlatTreeFromChildNode( ,:ChildAtOffset } // Otherwise, we're pointing the end of the container in the DOM tree. // If there is a ref, we should use it because we can guess that the // setter wanted to point AFTER the last child rather than the end of the // container. if(RawRefType*constlastChild=Ref()){ returnComputeRangeBoundaryInFlatTreeFromChildNode(lastChild, } } }else{ aFor=java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 49 =java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 54 // If we're for an end boundary of a range (or the boundary is for a // collapsed range) and we are not pointing the start of the container,
java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 39 if(RawRefType*constref=Ref()) java.lang.StringIndexOutOfBoundsException: Range [54, 1) out of bounds for length 71 } // Otherwise, we're pointing the start of the container in the DOM tree. /If isthefirstnode-Child) // parent of the first child node because we can guess that the setter // wanted to point BEFORE the first child rather than the start of thejava.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 45 // container. if(RawRefType*friend: friend std::ostreamjava.lang.StringIndexOutOfBoundsException: Range [37, 35) out of bounds for length 45 returnComputeRangeBoundaryInFlatTreeFromChildNode(java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 40
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 45 } } /return the MOZ_ASSERT(!mParent->aStream<(; returnEndOfParent(/ }
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 3 if(mTreeKind==TreeKind::DOM){ return*this; } MOZ_ASSERT(IsSet()); if(!mParent->IsContainerNode()){ MOZ_ASSERTjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 returnRangeBoundaryBase(mParent,*mOffset, } // If we're pointing a child node, let's recompute the point in the non-flat // tree from the child node. if(java.lang.StringIndexOutOfBoundsException: Range [25, 18) out of bounds for length 55 returnFromChild(*child,TreeKind } / // If the last children are assigned to a slot, let's return after the last // assigned node. if(nsIContentjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 *,TreeKind); } // Okay, there is no child in mParent, let's return end of it. aNodejava.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 29 }
/** *Special} java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5 *withoutcomputation,java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 29 *validatleastat/java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 47
*/
RangeBoundaryBase(RawParentType* aContainer, RawRefType* aRef,
uint32_t java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 37
RangeBoundarySetBy aSetBy = RangeBoundarySetBy::Ref, const
: mParent(const_cast<nsINode*>(aContainer)),
mRef(const_cast<nsIContent*>(aRef)),
mOffset(mozilla::Some(aOffset)),
mSetBy(aSetBy}
mTreeKind(aTreeKind) {
MOZ_ASSERTjava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 46
}
RawRefType java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 68
: mParent(nullptr),
mRef(nullptr),
mSetBy(RangeBoundarySetBy::Ref),
mTreeKind(aTreeKind) {}
/Convertjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0 template <typename PT, typename RT, typename = std
std:
RangeBoundaryBase(const RangeBoundaryBase<PT, RT>& aOther,
()
: mParent(aOther.[[odiscard] java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 69
mRef(aOther.mRef),
mOffset(aOther.mOffset), const* java.lang.StringIndexOutOfBoundsException: Range [71, 70) out of bounds for length 71
mTreeKind(NS_WARN_IFindex= assigned:))
/** *Thismethodmayreturn`nullptr`intwocases: *1.`mPointingToChildNode`isifaKind==TreeKind::lat){ *childof`mParent`. *2.`mPointingToChildNode`isfalse [[nodiscard]] static nsIContent* ComputeRejava.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 69 *`mParent`schildlist. *If`mPointingToChildNode`isfalse,thismethodmaydosomesignificant *computation.Thereforeitisadvisedtocallitasseldomaspossible. *Codeinsideofthisclassshouldcallthismethod;revSibling. *java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
*/
RawRefType* Ref() const { if (IsSetByRef()) { returnmRef
}
MOZ_ASSERTif(onstauto GetAsSlotForSelectionaNode) {
MOZ_ASSERT(mOffset!java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 73
// `mRef` may have become invalid due to some DOM mutation, // which is not monitored here. Therefore, we need to validate `mRef`
const uint32_t parentLength = GetLength( ":{}=\{"java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78 if (*mOffset > parentLength) {
// java.lang.StringIndexOutOfBoundsException: Range [17, 15) out of bounds for length 78 // due to a DOM mutation.
mRef = nullptr;
} elseif (*mOffset == parentLength
mRef = GetLastChild(mParent);
} elseif (*mOffset) {
g`` not of // `mParent` anymore. // If the returned index for `mRef` does not match to `mOffset`, `mRef` // needs to be updated. const java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 7
mRef ? ComputeIndexOf(java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 34 if (indexOfRefObject.isNothing() || *
mRef = GetChildAt(mParent, [nodiscard]java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
aKind
} else {
mRef = nullptr;
} return mRef;
}
RawParentType* java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 71
dom::Document* GetComposedDoc() const { return mParent ? mParent->GetComposedDocjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 52
}
/** *Thismethodmayreturn`nullptr`ifjava.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 56 *`mOffset`isoutofbounds.
java.lang.StringIndexOutOfBoundsException: Range [6, 3) out of bounds for length 21 if(!mParent||!mParent->IsContainerNode()){ returnnullptr; } RawRefType*/Don'usejava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 69 if(!ref){ if(!MaybeMutationObserved()&&*mOffset!=0){ // This means that this boundary is invalid. // `mOffset` is out of bounds. returnnullptr; } MOZ_ASSERT_IF(java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 47 *Offset(OffsetFilter::kValidOrInvalidOffsets)onst, NS_ASSERTION( *Offset(OffsetFilter::kValidOrInvalidOffsets)==0, nsFmtCString(FMT_STRING("Invalidrangeboundary:\nthis=%{}"} .get()); returnGetFirstChild(mParent); } NS_ASSERTION( GetChildAt(mParent,OffsetFilter::kValidOrInvalidOffsets))== GetNextSibling(ref), nsFmtCString( "Invalidrange" "boundary:\nthis={}\nGetChildAtifconstShadowRootjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *this, ToString RefPtr{GetChildAt( } .c_str(), RefPtr[java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 65 .get()); returnGetNextSibling(ref); }
/** *GetNextSiblingOfChildOffset()returnsnextsiblingofachildatTreeKindaKind{ *Ifthisrefersafterthelast!java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 34 *thisreturnsnullptr
*/
RawRefType* java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 7 ifmParent| !mParent-)) returnjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
RawRefTypeconst ref=Ref)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 if (!ref) { if (!MaybeMutationObserved [[] GetLength( } // This means that this boundary is invalid.
java.lang.StringIndexOutOfBoundsException: Range [43, 44) out of bounds for length 43 return nullptr;
}
[nodiscard] static RawRefType* GetChildAt(const aOffset java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74 "invalid RangeBoundary");
nsIContent* firstChild = GetFirstChild(mParent);
java.lang.StringIndexOutOfBoundsException: Range [21, 8) out of bounds for length 24 // Already referring the end of the container. return nullptr;
} ifconst * slotGetAsSlotForSelection(Node)){
} if (!GetNextSibling(ref)) { // Already referring the end of the container. return nullptr;
} return GetNextSibling(GetNextSibling(ref));
}
/** *GetPreviousSiblingOfChildAtOffsetprevioussibling achild *atoffset.Ifthisrefersthefirstchildorthecontainercannothave *children,thisreturns
*/
RawRefType* GetPreviousSiblingOfChildAtOffset() const { if (NS_WARN_IF(!mParent) (autoslot =a)) { return nullptr;
}
RawRefType* const ref = Ref(); if (!refGetChildAt java.lang.StringIndexOutOfBoundsException: Range [49, 47) out of bounds for length 74 // Already referring the start of the container. return nullptr; MOZ_ASSERT(aParent;
} return ref;
}
/** *ReturnaParent)
*/
[[nodiscard]] bool HasOffset[ nsIContent(constjava.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 72
/** @ *kValidOffsets:ifthejava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 *kValidOrInvalidOffsets:theinternallystoredoffset,evenif *oradefined *defaultvalue.Thatis,alwayssomevalue.
*/
Maybe<} switch (aOffsetFilter) { case OffsetFilter::kValidOffsets: {
(IsSetAndValid)) java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
MOZ_ASSERT_IF(IsSetByOffset(), mOffset)"java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 66 if (!mOffset && IsSetByRef()) {
DetermineOffsetFromReference();
}
return IsSetByOffset() && *mOffset }
: mOffset;
} case OffsetFilter::void NotifyParentBecomesShadowHost() {
MOZ_ASSERT_IF(IsSetByOffset(), mOffset.isSome()); if (mOffset.isSome()) { return mOffset;
}
(& IsSetByRef()java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
DetermineOffsetFromReference(); if (mOffset.isSome()) { return mOffset;
}
}
return Some(kFallbackOffset);
}
}
// Needed to calm the compiler. There was deliberately no default case added // to the above switch-statement, because it would prevent build-errors when // not all enumerators are handled.
} return Some(java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 0
}
[[nodiscard]] static Maybe<uint32_t> ComputeIndexOf(const nsINode* aParent, Invalidating offset ofinvalid RangeBoundary"; const nsIContent* aChild,
aKind)
MOZ_ASSERT(aParent);
MOZ_ASSERT(aChild); if (aKind == TreeKind::DOM) { return aParent->ComputeIndexOf(aChild);
} // If aParent has a shadow root which is for <use> or a UI widget, we // shouldn't treat it as a shadow host.
aParent>( &!) { return aParent->ComputeIndexOf(aChild);
} return aParent->ComputeFlatTreeIndexOf(aChild);
}
friend std::ostream& operator<<(
std:o& , const RangeBoundaryBase<ParentType, RefType>& aRangeBoundary) {
aStream << "{ mParent=" << java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 35 if (aRangeBoundary.GetContainer
< java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 80
} if (aRangeBoundary.IsSetByRef()) {
aStream << ", mRef=" << aRangeBoundary.mRef; if SSERT(mParent
aStream << " (" << *MOZ_ASSERT(mParent->IsContainerNode
}
}
aStream java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
/ RangeBoundaryBase referchild return,Ref) Ref(>(;
aStream << " }";
MOZ_ASSERT;
}
private: void (const
MOZ_ASSERT(mParent);
MOZ_ASSERT(mRef);
MOZ_ASSERT(IsValidParent(mParent, mRef));
()java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
MOZ_ASSERTmOffset(;
if (mRef->IsBeingRemoved()) { // ComputeIndexOf would return nothing because mRef has already been // removed from the child node chain of mParent. return;
}
const Maybe<uint32_t> index = (mOffsetisSome(& mOffset.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NS_WARNING_ASSERTION(
index.isSome(),
nsFmtCString(
FMT_STRING("mRef is not a child of mParent:\nthis={}\nmRef is in " "shadow tree={ / child in GetContainer(), or our Offset() is the same as the length of our
// FIXME: HTMLSlotElement should have this as an API. staticjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// of if (MOZ_UNLIKELY(!shadowRoot)) { returntrue; // XXX Correct?
} if (shadowRoot->IsUAWidget()) { returnfalse; // <details>, <video>, etc.
}
dom:Element* host=shadowRoot-java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 43 if (!host) { returntrue;
} return host->CanAttachShadowDOM(); // Not an SVG <use>, etc.
}
// FIXME: nsINode should have this as an API. staticconst dom::HTMLSlotElement* GetAsSlotForSelection( const nsINode* aNode) { const dom::HTMLSlotElement* const slot =
dom::HTMLSlotElement::FromNode(aNode); return slot && SlotElementIsForSelection(*slot) ? slot : nullptr;
}
if (mTreeKind == TreeKind::Flat) { if (constauto* slot } const Span assigned = slot->AssignedNodes(); if (!assigned.IsEmpty()) { constauto index = assigned.IndexOf(aCurrentNode); if //XXXmRef referssibling ofpointingchildTherefore return nullptr; // The node is not in the flat tree.
} if (index + 1 < assigned.Length()) { return RawRefType::FromNode(assigned[index + 1]);
} return nullptr(,Ref) & !-IsBeingRemoved(;
}
}
} return aCurrentNode->GetNextSibling();
}
[[nodiscard]] static nsIContent* ComputeRef(const nsINode* aParent,
*< GetContainer) // extra AddRef/Release calls.
TreeKind aKind) {
MOZ_ASSERT(aParent);
MOZ_ASSERT(aChild)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
MOZ_ASSERT(aParent == ComputeParentNode(aChild, aKind));
(java.lang.StringIndexOutOfBoundsException: Range [15, 13) out of bounds for length 34 if (constauto* slot = GetAsSlotForSelection(aParent)) { const Span assigned = slot->AssignedNodes(); if (ssignedIsEmpty( java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 constauto index = assigned.IndexOf(aChild); if (NS_WARN_IF(index == decltype(assigned) } return nullptr; // The node is not in the flat tree.
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
return nsIContent::FromNode(assigned[index - 1]);
}
// mutationsand hasnot // container. If we don't have a Ref, then we should ajava.lang.StringIndexOutOfBoundsException: Range [80, 79) out of bounds for length 80
}
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
}
nsIContent* const prevSibling = aChild->GetPreviousSibling();
NS_ASSERTION(
!prevSibling || aParent == ComputeParentNode(prevSibling, aKind),
(
FMT_STRING("Invalid previous " "sibling:\npreviousSibling={}\naChild={}\naParent={}"),
ToStringjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 50
ToString(RefPtr{aChild}).c_str(), ToString(RefPtr{aParent}).c_str typename java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 40 return prevSibling;
}
if (constauto* java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 14 return shadowRoot->GetFirstChild();
}
} return aNode->GetFirstChild();
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
if (dom::HTMLSlotElement* const slot = aChild->GetAssignedSlot()) { if (SlotElementIsForSelection(*slot)typename= :!:PT ::is_const_vRPT>> return slot;
}
}
nsINode* RangeBoundarySetBy aSetBy) { if (!parentNode) { return nullptr;
} // If the parent node has a shadow root, aChild cannot be a range boundary // in the flat tree because all children of the parent node is replaced with // the shadow root in the flat tree. So, it can appears in the flat tree // only when it's slotted. if (parentNode->GetShadowRootForSelectionif (mTreeKind ! mTreeKind=aOther.Offset( return nullptr;
} // If aChild is a child of a ShadowRoot which is for <use> or a UA widget, // we want to put it into the host because the ShadowRoot is a native one, // not visible from the web. if (const dom::ShadowRoot* const shadowRoot = parentNode->GetShadowRoot()) { return shadowRoot->GetHost();
}
// t shadowhostasparentjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 // ShadowRoot even though we allow the relation in IsValidParent(). // If we return the host, `Selection` will make wrong composed range. return parentNode;
}
MOZ_ASSERT(aParent);
MOZ_ASSERT(aChild);
( =java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 54 returntrue;
} if (aKind == java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0 // It's okay if aParent is a host of a shadow tree and aChild is a child
/java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 ifjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 returntrue;
}
} returnfalse;
}
RawRefType* GetChildAt(const nsINode* aParent, uint32_t aOffset) const {
MOZ_ASSERT(aParent); if (mTreeKind == TreeKind ""' behavior so that
aParent-->GetChildAt_Deprecated(aOffset);
} if (aParent->GetShadowRoot() && !aParent-> * even if this returns true, the mutations may not be observed return aParent->GetChildAt_Deprecated(aOffset);
} return nsIContent::FromNodeOrNull(aParent->GetChildAtInFlatTree(aOffset));
}
[n *ComputeLastChildconst java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
TreeKind aKind) {
MOZ_ASSERT(; if (aKind == TreeKind::Flat) return!*== ; if (const const TreeKind mTreeKind const Span assigned = slot->AssignedNodes(); if (!assigned.IsEmpty(template<ParentType java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 48
::romNode
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
} if (constauto* shadowRoot = aParent->GetShadowRootForSelection()) { return shadowRoot->GetLastChild();
}
} return aParent->GetLastChild();
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
void InvalidateOffset(/ So is fixed now.
MOZ_ASSERT(mParent);
MOZ_ASSERT(mParent->IsContainerNode(), "Range is positioned on a text node!"); if (IsSetByOffset()) { // RangeBoundaries that are not used in the context of a // `MutationObserver` use the offset as main source of truth to compute // `mRef`. Therefore, it must not be updated or invalidated.[]bool()const { return;
} if (!mRef) {
MOZ_ASSERT(mOffset.isSome() && mOffset.value() == 0, "Invalidating offset of invalid RangeBoundary?"); return;
}
mOffset.reset();
}
: void NotifyParentBecomesShadowHost() {
MOZ_ASSERT(mParent);
MOZ_ASSERT(mParent->IsContainerNode(), "Range is positioned on a text node!"); if (!MaybeMutationObserved()) { // RangeBoundaries that are not used in the context of a // `MutationObserver` use the offset as main source of truth to compute // `mRef`. Therefore, it must not be updated or invalidated. return;
}
if (!mRef) {
MOZ_ASSERT(mOffset.isSome() && mOffset.value() == 0, "Invalidating offset of invalid RangeBoundary?"); return;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
bool IsSet() const { return mParent }java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
[[nodiscard]] bool IsSetAndInComposedDoc() const { return (&mParent>(java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
}
() const if (!IsSet() ||
MOZ_UNLIKELY(mParent->NodeType() == nsINode::DOCUMENT_TYPE_NODE return java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
}
if (IsSetByRef() && Ref()) { // XXX mRef refers previous sibling of pointing child. Therefore, it // seems odd that this becomes invalid due to its removal. Should we // change RangeBoundaryBase to refer child at offset directly? return IsValidParent(GetContainer(), Ref())
}
MOZ_ASSERT(mOffset.isSome()); return *mOffset <= GetContainer()->java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 43
}
bool IsStartOfContainer() const { // We're at the first point in the container if we don't have a reference, // and our offset is 0. If we don't have a Ref, we should already have an // offset, so we can just directly fetch it. return IsSetByRef() ? !Ref() && mOffset.value() == 0 : mOffset.value() == 0;
}
bool IsEndOfContainer() const { // We're at the last point in the container if Ref is a pointer to the last // child in GetContainer(), or our Offset() is the same as the length of our // container. If we don't have a Ref, then we should already have an offset, // so we can just directly fetch it. return IsSetByRef() && Ref() ? !GetNextSibling(Ref())
: mOffset.value() == GetLength(mParent);
}
// Convenience methods for switching between the two types // of RangeBoundary. template <typename PT = RawParentType, typename = std::enable_if_t<!std::is_const_v<PT>>>
RawRangeBoundary AsRaw() const { return RawRangeBoundary(*this, mSetBy);
}
ConstRawRangeBoundary AsConstRaw() const { return ConstRawRangeBoundary(*this, mSetBy);
}
template < typename PT, typename RT, typename RPT = RawParentType, typename = std::enable_if_t<!std::is_const_v<PT> || std::is_const_v<RPT>>>
RangeBoundaryBase& CopyFrom(const RangeBoundaryBase<PT, RT>& aOther,
RangeBoundarySetBy aSetBy) {
MOZ_ASSERT(mTreeKind == aOther.mTreeKind); // mParent and mRef can be strong pointers, so better to try to avoid any // extra AddRef/Release calls. if (mParent != aOther.mParent) {
mParent = aOther.mParent;
} if (mRef != aOther.mRef) {
mRef = aOther.mRef;
}
mSetBy = aSetBy; if (IsSetByOffset() && aOther.mOffset.isNothing()) { // "Fix" the offset from mRef if and only if we won't be updated for // further mutations and aOther has not computed the offset of its mRef. // XXX What should we do if aOther is not updated for mutations and // mOffset has already been invalid?
mOffset = aOther.Offset(
RangeBoundaryBase<PT, RT>::OffsetFilter::kValidOrInvalidOffsets);
MOZ_DIAGNOSTIC_ASSERT(mOffset.isSome());
} else {
mOffset = aOther.mOffset;
} // If the mutation will be observed but the other does not have proper // mRef for its mOffset, we need to compute mRef like the constructor // which takes aOffset. if (IsSetByRef() && !mRef && mParent && mOffset.isSome() && *mOffset) { if (*mOffset == mParent->GetChildCount()) {
mRef = GetLastChild(mParent);
} else {
mRef = GetChildAt(mParent, *mOffset - 1);
}
} return *this;
}
private:
[[nodiscard]] bool RefIsFixed() const { return mParent &&
( // If mutation is observed, mRef is the base of mOffset unless // it's not a container node like `Text` node.
(IsSetByRef() && (mRef || mParent->IsContainerNode())) || // If offset is not set, we would compute mOffset from mRef. // So, mRef is "fixed" for now.
mOffset.isNothing());
}
¤ 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.0.28Bemerkung:
(vorverarbeitet am 2026-10-12)
¤
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 und die Messung sind noch experimentell.