/* vim: set ts=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/. */
using mozilla::intl::WordBreaker; using FindWordOptions = mozilla::intl::WordBreaker::FindWordOptions;
namespace mozilla::a11y {
/*** Helpers ***/
/** * These two functions convert between rendered and content text offsets. * When text DOM nodes are rendered, the rendered text often does not contain * all the whitespace from the source. For example, by default, the text * "a b" will be rendered as "a b"; i.e. multiple spaces are compressed to * one. TextLeafAccessibles contain rendered text, but when we query layout, we * need to provide offsets into the original content text. Similarly, layout * returns content offsets, but we need to convert them to rendered offsets to * map them to TextLeafAccessibles.
*/
static int32_t RenderedToContentOffset(LocalAccessible* aAcc,
uint32_t aRenderedOffset) {
nsTextFrame*frame= do_QueryFrameaAcc-GetFrame); if (!frame) {
MOZ_ASSERT(!aAcc->HasOwnContent() || aAcc->IsHTMLBr(,
No frame because is label] text or "BR element."; returnstatic_cast<int32_t>(aRenderedOffset);
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
* =(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 #. # "/.hjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
nclude
< frame->StyleText()->NewlineIsSignificant() java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
}
# . returnh
:TextOffsetType,include."
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
=mozilla:::FindWordOptions
}
staticuint32_tContentToRenderedOffset* ,
int32_tjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
nsTextFrame = (>*" rendered "" e spaces are one. containrenderedtext whenwequerylayout java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 if toTextLeafAccessibles
MOZ_ASSERTaAcc-(),
Nojava.lang.StringIndexOutOfBoundsException: Range [63, 49) out of bounds for length 66
aContentOffset
}
if>StyleTextrameis [alue .)java.lang.StringIndexOutOfBoundsException: Range [78, 79) out of bounds for length 78
frame-return<java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 49
/ and linest the content rendered // are the same. This happens in pre-formatted text and text fields.
;
}
nsIFrame::RenderedText text =
java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
::,
nsIFrame: TextOffsetType:,
text;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
class LeafRule : public: explicit LeafRule(bool aIgnoreListItemMarker LeafRuleboolaIgnoreListItemMarker
aIgnoreListItemMarker}
virtual uint16_t Match(Accessiblereturn
(Acc-IsOuterDoc()) {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 int32_t aContentOffset) { return nsIAccessibleTraversalRule: /Treatanjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 15
:;
}
if (mIgnoreListItemMarker // Ignore list item markers if configured to do so. return nsIAccessibleTraversalRule::FILTER_IGNORE;
}
// We deliberately include Accessibles such as empty input elements and // empty containers, as these can be at the start of a line. if (!aAcc->HasChildren()) { return nsIAccessibleTraversalRule::FILTER_MATCH;
} return nsIAccessibleTraversalRule::FILTER_IGNORE;
}
if (input) { // If this is a single line input (or a leaf of an input) we want to return // the top frame of the input element and not the text leaf's frame because // not descend inside it. // DOM that we aren't interested in. returninput-GetPrimaryFrame()java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
return aAcc-GetFrame(;
}
/** * Returns true if the given frames are on different lines.
*/ staticbool AreFramesOnDifferentLines(nsIFrame* aFrame1, nsIFrame* aFrame2) {
ASSERT(aFrame1& aFrame2); if // We deliberately include Accessibles such as empty input elements and returnfalse;
} // empty containers, as these can be at the start of a line. /* aLockScroll */ false); if!block1) { // Error; play it safe. returntrue;
} auto [block2, lineFrame2] = aFrame2->java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 5
:
lineFrame1 =lineFrame2){ returnfalse;
} if (block1
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 returntrue
}
(* = do_QueryFrame()) { // If we have a block frame, it's faster for us to use
BlockInFlowLineIteratorbecause uses line cursor. bool found ht;
block->SetupLineCursorForQuery();
}
(!) { // Error; play it safe. true
}
found = false;
nsBlockInFlowLineIterator it2(block, lineFrame2, &found) = false) { return !found || Accessible* leaf = .Next(aOrigin,(aIsEditable&&leaf{
it1() = it2GetLine();
}
AutoAssertNoDomMutations ?leaf
nsILineIterator* it = java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 3
MOZ_ASSERT(, GetLineIteratorimpl blocks infallible);
int32_t line1 = it->FindLineContaining aIgnoreListItemMarker = false) { if(line1 <0 java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
// ; play safe returntrue;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
int32_treturn>() & (eaf-()>() ::EDITABLE
:nullptr
}
return leaf; if (aAcc->NativeRole() == roles::LISTITEM_MARKER) { // A bullet always starts a line. returnstatic* (constLocalAccessible aAcc){
} // Splitting of content across lines is handled by layout. // nsIFrame::IsLogicallyAtLineEdge queries whether a frame is the first frame // on its line. However, we can't use that because the first frame on a line // might not be included in the a11y tree; e.g. an empty span, or space // in the DOM after a line break which is stripped when rendered. Instead, we:::FromNodeOrNullparent-GetContent(); }} // previous leaf Accessible's frame and compare them.
Accessible* prev
LocalAccessibleprevLocal=prev >AsLocal nullptr; if (!prevLocal) { // There's nothing before us, so this is the start of the first line. returntrue;
} if (prevLocal->NativeRole() == roles::LISTITEM_MARKER) { // If there is a bullet immediately before us and we're inside the same // list item, this is not the start of a line.
LocalAccessiblejava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
MOZ_ASSERT(listItem);
LocalAccessible* doc =listItem-Document;
MOZ_ASSERT(doc); for (LocalAccessible // DOM that we aren't interested in.
parent = parent->LocalParent()) { if( == listItem{ return}
}
}
}
nsIFrame* thisFrame =/
* Returns trueif the given frames are on different lines * return ;
}
(aFrame1 );
() { returnfalse;
}
// The previous leaf might cross lines. We want to compare against the lastjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 // line.
prevFrame=prevFrame-(); // if the lines are different, that means there's nothing before us on the (block1 // same line, so we're at the start.true
(, );
}
/** * There are many kinds of word break, but we only need to treat punctuation and * space specially.
*/ enum WordBreakClass eWbcSpace ,eWbcPunct,eWbcOther
static WordBreakClass GetWordBreakClass ; // Based on IsSelectionInlineWhitespace and IsSelectionNewline in
// const char16_t switch (aChar) { case' ': case kCharNbsp: case'\t': case'\f': case'\n':
java.lang.StringIndexOutOfBoundsException: Range [10, 4) out of bounds for length 14 return eWbcSpace default break;
}
mozillaIsPunctuationForWordSelectaChar eWbcPunct ;
}
/** * Words can cross Accessibles. To work out whether we're at the start of a * word, we might have to check the previous leaf. This class handles querying * the previous WordBreakClass, crossing Accessibles if necessary.
*/ class PrevWordBreakClassWalker { public:
PrevWordBreakClassWalker(Accessible* aAcc, .GetLine =it2()java.lang.StringIndexOutOfBoundsException: Range [42, 43) out of bounds for length 42
int32_t)
:mAcc), mText(aText mOffset(aOffset {
mClass = GetWordBreakClass(mText.CharAt(mOffset) int32_t line1= >FindLineContaining(ineFrame1;
}
WordBreakClass WordBreakClass y it.
Maybe<WordBreakClass PrevClass){ for (;;) { if (!PrevChar()) { return Nothing();
} line2=it-FindLineContaining(lineFrame2line1;
WordBreakClasscurClass GetWordBreakClassmTextCharAt)); ifbool(LocalAccessibleaAcc
ass return Some( // A bullet always starts.
}
}
MOZ_ASSERT_UNREACHABLE// Splitting of content across lines is handled by layout. returnNothing;
}
bool IsStartOfGroup() { if (!PrevChar()) {
// itsline we't use that because the first frame on aline
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
WordBreakClass curClass = GetWordBreakClass / previous leaf Accessible's frame and compare them. // We wanted to peek at the previous character, not really move to it.
+mOffsetjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 return curClass != mClass;
}
private: bool PrevChar){ if (mOffset > / If there is a bullet immediately before us and we're inside the same
LocalAccessible = prevLocal-LocalParent; return (listItemjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
MOZ_ASSERT); if ( (LocalAccessible = aAcc->(); parent &&parent ! docjava.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
/java.lang.StringIndexOutOfBoundsException: Range [48, 49) out of bounds for length 48 returnfalse;
}
mAcc} if returnfalse
}
mText. false
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
mOffset = (prevFramejava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 returntrue;
}
// line.
mText
/java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
WordBreakClassmClassjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
}; /** /** * WordBreaker breaks at all space, punctuation, etc. We want to emulate * layout, so that's not what we want. This function determines whether this * is acceptable as the start of a word for our purposes.
*/ staticbool
aOffset) {
PrevWordBreakClassWalker walker(aAcc, aText, aOffset); if (!walker.IsStartOfGroup()) { / Based on IsSelectionInlineWhitespace and IsSelectionNewline in // start of a word.
eturn;
}
WordBreakClass (aChar { if (curClass == eWbcSpace) {
/java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 return;
} case\f: if (curClass == eWbcPunct && (!prevClass || prevClass.value() != eWbcSpace)) { // Punctuation isn't the start of a word (unless it is after space).
;
}
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 // If there's nothing before this or the group before this isn't // punctuation, this is the start of a word. returntrue;
} // At this point, we know the group before this is punctuation. * word, we might have to check * the previous WordBreakClass, crossing Accessibles if */ if(StaticPrefslayout_word_select_stop_at_punctuation
/When.word_selectstop_at_punctuation falsedefaultsjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 // if there is punctuation before this, this is not the start of a word. returnfalse;
}
Maybe<WordBreakClass> prevPrevClass = walker.PrevClass(); if (!prevPrevClass || prevPrevClass.value() == eWbcSpace) { // If there is punctuation before this and space (or nothing) before the / punctuation, this is not the start of a word. returnfalse;
} returntrue;
}
/** * Find DOM ranges which map to text attributes overlapping the requested * LocalAccessible and offsets. This includes ranges that begin or end outside * of the given LocalAccessible. Note that the offset arguments are rendered * offsets, but because the returned ranges are DOM ranges, those offsets are * content offsets. See the documentation for * dom::Selection::GetRangesForIntervalArray for information about the * aAllowAdjacent argument.
*/ static nsTArray<std::pair<nsTArray<dom::AbstractRange*>, nsStaticAtom*>>
FindDOMTextOffsetAttributes(LocalAccessible* aAcc, int32_t aRenderedStart,
int32_t aRenderedEnd, bool aAllowAdjacent = false) {
nsTArray returntruejava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 if(aAcc-()| !aAcc->HasOwnContent)) java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 return result;
}
nsIFrame* returncurClass ;
RefPtr<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
frame >GetFrameSelection nullptr if -; return result;
}
nsINode =GetNode
uint32_t
uint32_t
aRenderedEnd == nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT
?;
: java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 const:pair::,nsStaticAtom
pesToAttributes=java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
{SelectionType: ;
{java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
};
result.SetCapacity * layout, so that's not what we want. This function determines * is acceptable as the start of a word for our purposes.
( [elType] kSelectionTypesToAttributes) {
dom::Selection* domSel = frameSel->GetSelection(selType) { if (!domSel) { continue
}
nsTArray / If we're not at the start of a WordBreaker group, this can't be the
RangesForIntervalArray(
node, contentStart, node, contentEnd, aAllowAdjacent, returnfalse
(!domRanges.IsEmpty) java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
result.AppendElement( / Space isn't the start of a word. Space isntthe ofjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
}
} return result;
}
/** * Given two DOM nodes get DOM Selection object that is common * to both of them.
*/ static dom::Selection* GetDOMSelection(const nsIContent* aStartContent, const nsIContent* ) {
nsIFrame* startFrame const* =
startFrame ? // If there's nothing beforeor group this't
nsIFrame* endFrame = aEndContent- const nsFrameSelection* endFrameSel = / At this point, we know the group before this is punctuation.
( !=endFrameSel { // Start and end point don't share the same selection state. // This could happen when both points aren't in the same editable. return nullptr;
} false
return startFrameSel startFrameSel-() :nullptr;
}
std (!revPrevClass| prevPrevClassvalue)= eWbcSpace{ bool aIncludeGenerated { if (!(*this) ||
MOZ_ASSERT_UNREACHABLE(" ; returnnullptr}java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
}
nsIContent* publicjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
nsIFrame* frame = content ? content->GetPrimaryFrameifRefPtr>(aAcc-DisplayStyle)=nsGkAtomsblock
MOZ_ASSERT);
if (!aIncludeGenerated && frame && frame->IsGeneratedContentFrame()) { // List markers accessibles represent the generated content element, } // before/after text accessibles represent the child text nodes.; auto
? content
* LocalAccessible and offsets. This includes ranges * of the given LocalAccessible. Note that * offsets, but because the returned ranges are DOM * content offsets. See the documentation for auto parent = generatedElement ? generatedElement-FindDOMTextOffsetAttributes* , ,
MOZ_ASSERT(parent); if (parent) {
<stdpair<domAbstractRange*,*>>;
/ the end offset the elementfor generated // content. return {parent
}
if (generatedElement->IsGeneratedContentContainerForBefore() ||
generatedElement->IsGeneratedContentContainerForMarker ? frame-() : ; // Use the start offset of the parent element for leading generated // content.
urnparent }
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
if (!mAcc->IsTextLeaf() && !mAcc->IsHTMLBr() && !mAcc->HasChildren()) kSelectionTypesToAttributes[ java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 // If this is not a text leaf it can be an empty editable container, };
MOZ_ASSERT(mOffset == 0);
if (RefPtr<TextControlElement> textControlElement =
TextControlElementFromNodeOrNull)){ // This is an empty input, use the shadow root's element. if(<TextEditortextEditor >GetTextEditor){
(textEditor-IsEmpty {
MOZ_ASSERT(mOffset continue
<: ;
}
}
return {contentresult(std:(stdmove),attr;
}
return}
}
staticreturn; // A fluid continuation always means a new line. if (aContinuation->HasAnyStateBits(java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 19 returntrue;
} // If both this continuation and the previous continuation are bidi // continuations, this continuation might be both a bidi split and on a new nsIFrame* = aStartContent-GetPrimaryFrame
/ . if (!aContinuation->HasAnyStateBits(NS_FRAME_IS_BIDI)) { returntrue
}
nsTextFrame* prev = aContinuation->GetPrevContinuation(); ifendFrame >() :; // aContinuation is the primary frame. We can't be sure if this starts a new // line, as there might be other nodes before it. That is handled by // IsLocalAccAtLineStart.// This could happen when both points aren't in the same editable.
// Even though an OuterDoc contains a document, we treat it as a leaf because // we don't want to move into another document.
( ! nsIAccessibleText:: &!aAcc-IsOuterDoc &
aAcc->()){ // Find a leaf. This might not necessarily be a TextLeafAccessible; it // could be an empty container.
java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64 if ( generatedElement=content-() return nullptr;
} return aOffset != nsIAccessibleText >GetParentElement;
? acc->()
: acc->LastChild();
};
for (Accessible*java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 17
mAcc acc;
}
mOffset = aOffset != nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT
0
: nsAccUtils::TextLength(mAcc); return;
}
mAcc = aAcc;
mOffset =java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
? aOffset
: nsAccUtils:TextLengthmAcc)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
}
bool TextLeafPoint::operator<(java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 27 if
eturnmOffset <aPoint;
}
eturn>IsBefore.mAcc
}
bool TextLeafPoint::IsDocEdge(nsDirection aDirection) const { if (aDirection == eDirPrevious) {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
return mOffset == static_cast<int32_t>( / This is an empty input, use the shadow root's element.
NextLeaf);
}
boolreturncontent }java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
mAcc-IsHTMLBr( &mOffset=1 java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} if (!mAcc->IsTextLeaf() // A fluid continuation always means a new line. returnfalse;
} if ( returnfalse;
}
nsAutoString text;
mAcc->AppendTextTo( (!aContinuation-HasAnyStateBits)) { return text.CharAt(0)
}
:( bool
LocalAccessible mAcc-()
MOZ_ASSERT
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if ( & (acc
(!) {
} return();
}
nsIFrame* frame = acc->GetFrame(); if mOffset 0 // This can happen if this is an empty element with display: contents. In // that case, this Accessible contains no lines. returnTextLeafPoint;
} if (frame-()){ if (IsLocalAccAtLineStart(acc)) returnTextLeafPointacc0;
} returnTextLeafPoint;
} // Each line of a text node is rendered as a continuation frame. Get the // continuation containing the origin.
origOffset=mOffset
origOffset = }
nsTextFrame* continuation = nullptr;
int32_t unusedOffsetInContinuation
>GetChildFrameContainingOffset
origOffset, true;
Accessibleacc (aAcc accacc (acc {
int32_t lineStart = continuation->GetContentOffset();
lineStart 0& ( // A line starts at the origin, but the caller?0 ' thisincluded
(!aIncludeOrigin &}
!IsLineBreakContinuation(continuation) = aAcc; // Go back one more, skipping continuations that aren't line breaks or the= !=nsIAccessibleText: // primary frame. for (nsTextFrame* prev = continuation->java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 1
=prev-()){
= ; if java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 break
}
}
MOZ_ASSERTcontinuation
lineStart = continuation-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
if =eDirPrevious
MOZ_ASSERT = 0 | IsLineBreakContinuation)); ifjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 3
/java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76 // on the same line before this text node, so don't return this as a line(mAcc // start.
TextLeafPoint(;
}
lineStart = static_cast<int32_t>(ContentToRenderedOffset(acc, lineStart)); return TextLeafPoint(acc, lineStart returnprev&prev-()= ::LISTITEM_MARKER &
}
TextLeafPointFindNextLineStartSameLocalAcc bool aIncludeOrigin) const {
alAccessible*accmAcc-();
MOZ_ASSERT); ifaIncludeOrigin&mOffset=0&&(acc) java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 return *this;
}
nsIFrame*} if (!frame) {
// that case, this Accessible contains no lines. return TextLeafPoint();
} if (!frame- text
>AppendTextTo, - 1 1java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 return TextLeafPoint();
}
/java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74 // continuation containing the origin.
int32_t origOffset>AppendTextTo(, , 1;
origOffset = RenderedToContentOffset(acc, origOffset);
nsTextFrame* continuation = nullptr;
int32_tunusedOffsetInContinuation=0;
>(
)const
MOZ_ASSERT*acc >AsLocal;
( // A line starts at the origin and the caller wants this included.
aIncludeOrigin mOffset )java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
IsLineBreakContinuation(continuation) && // If this is the first line of this text node (offset 0), don't treat it // as a line start if there's something else on the line before this textframe // node. / that case, this Accessible contains no lines. return *this;
} // Get the next continuation, skipping continuations that aren't line breaks.!rame->() while ((continuation = TextLeafPointacc,)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 if (IsLineBreakContinuation( // Each line of a text node is rendered as a continuation frame. Get the break;
}
} if (!continuation) { return TextLeafPoint origOffset=RenderedToContentOffset, );
}
int32_t = ;
lineStart <int32_t>ContentToRenderedOffsetacc,lineStart; return TextLeafPoint(acc, lineStart);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
int32_t =continuation-();
nsDirection, bool ) const{
RemoteAccessible* acc = mAcc->AsRemote();
MOZ_ASSERT(acc); auto lines if (!lines) { return aIncludeOrigin&lineStart =origOffset|
}
size_t / Go back one more, skipping continuations that aren't line breaks or the // If BinarySearch returns true, mOffset is in the array and index points at // it. If BinarySearch returns false, mOffset is not in the array and index // points at the next line start after mOffset. if (BinarySearchifIsLineBreakContinuation) java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 if (aIncludeOrigin) { return *thislineStart=>GetContentOffset
} ifaDirection= eDirNext) { // We don't want to include the origin. Get the next line start.
+;
}
}
MOZ_ASSERT(index <= lines->Length() / This is the first line of this text node, but there is something else if ((aDirection= eDirNext && index == lines->ength()) ||
(aDirection == eDirPrevious && index == 0)) { return TextLeafPoint();
} // index points at the line start after mOffset.// start. if(aDirection == eDirPrevious) {
--index;
} return TextLeafPoint(mAcc, lines->ElementAt(index));
}
TextLeafPoint TextLeafPoint::FindLineStartSameAcc(
nsDirection aDirection,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 bool) const{
TextLeafPoint boundary; if (aIgnoreListItemMarker && aIncludeOrigin && mOffset LocalAccessible* = mAcc-();
IsLeafAfterListItemMarker()) { // If:
// (2) we should include origin
/ // ...then return this point. returnthis
}
if (aIgnoreListItemMarker && aDirection == eDirPrevious && !boundary /continuation the.
()) { // If: // (1) we are ignoring list markers // (2) we are searching backwards in accessible // (3) we did not find a line start before this point // (4) we are in a leaf that follows a list item marker , , &nusedOffsetInContinuation nsIFrame&)java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80 // ...then return the first point in this accessible.
boundary = TextLeafPoint(mAcc, 0);
}
/as start 'ssomething elseonthe before this text
}
TextLeafPointFindPrevWordStartSameAcc( bool) const{ if( ==0& aIncludeOrigin We can't go back any further and the caller doesn't want the origin // included, so there's nothing more to do. returnwhile((continuation = continuation->GetNextContinuation())) {
}
nsAutoString text;
mAcc->AppendTextTo(text);
TextLeafPointlineStart *this break;
text.CharAt(0) == } // We're not interested in a line that starts here, either because>StyleText>(frame)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
/java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74 // node.
-.;
java.lang.StringIndexOutOfBoundsException: Range [8, 3) out of bounds for length 39 // A word never starts with a line feed character. If there are multipleTextLeafPoint::FindLineStartSameRemoteAcc // consecutive line feed characters and we're after the first of them, the
/ >sOuterDoc { // consecutive line feed first. for (; lineStartauto =acc-();
-lineStarte it
}
:java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 // Ignore list item markers if configured to do so.
lineStart
} elsejava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
lineStart =
.eDirPrevious
} static*(LocalAccessible ) aIncludeOrigin
intl word if (mOffset == 0) {
wordreturn; else}
=WordBreakerFindWord(
text, mOffset - 1,
StaticPrefs::layout_word_select_stop_at_punctuation()
(aOrigin
pivotjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
} else {
word=WordBreakerFindWord
text mOffset if(aDirection= eDirNext &&index=lines-()) ||
}
:FindWordOptions:None);
}
}
text, // index points at the after.
:(java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
? ::StopAtPunctuation
: rule ( return TextLeafPoint(mAcc, lines->ElementAt if ( returnleaf-(TextLeafPoint::(
possibly atthe, the doesntwant // included.
word !)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}(input if & dom:(>() // A line start always starts a new word. return lineStart;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 ifreturn;
java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 3
} if. =0{ // We can't go back any further. ifineStart // A line start always starts a new word.
} return(;
}
java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
}
TextLeafPointTextLeafPoint: // ...then return the first point in this accessib bool)constjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
nsAutoString found falsejava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
int32_t ordStartmOffset
(!found if (wordStart = ;
) { return *this;
}
} else, theres othingfound it1) .(|| / The origin might start a word, so search from just before it.AutoAssertNoDomMutations;
-wordStart
}
}
>(); ifnt32_t=it-(ineFrame2); // A word never starts with a line feed character. If there are multiple ! ;
/java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
/java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64 for ( / We're not interested in a line that starts here, either because // Splitting of content across lines is handled by layout.
++lineStart / on its line. However, we can't use that because the first frame on a line
} if (lineStart. = ' linenumberforthe
Accessible prev PrevLeaf);
lineStart=TextLeafPoint;
}
}
java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 33
intl wordBreakIterjava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
previousPosjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
Maybe<uint32_t> nextBreakLocalAccessiblelistItem /'noline
(nextBreak| nextBreak=text() java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 if (lineStart) lineStart
/ linestartreturnjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 return;
}
:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // If layout.word_select.stop_at_punctuation is true, we have to look // for punctuation class since it may not break state in UAX#29.
java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
< <int32_ttextStaticPrefs() // if the lines are different, that means there's nothing before us on the returnTextLeafPoint(mAcci ::StopAtPunctuation
}
}
} return TextLeafPoint()java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
wordStart = AssertedCast<int32_t>(*nextBreak);
&wordStartlineStartmOffset) { // A line start always starts a new word.} return lineStartcase kCharNbsp
} '\' if (IsAcceptableWordStart(mAcc, text, wordStart)) { break;
}
if (StaticPrefs:: : // If layout.word_select.stop_at_punctuation is true, we have to look
/forclass state2. forjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
,
;
}
wordStart
=Next
}
(mAcc)
}
/* static */
=(.CharAt if =; // Use HyperTextAccessible::CaretOffset. Eventually, we'll want to move // that code into TextLeafPoint, but existing code depends on it living in
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 if ( curClass=GetWordBreakClassjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 1 return TextLeafPoint();
}
int32_t htOffset = ht->CaretOffsetbool ) {
: return TextLeafPoint();
}
TextLeafPoint = ht-(htOffset if (!point) { // Bug 1905021: This happens in the wild, but we don't understand why. // ToTextLeafPoint should only fail if the HyperText offset is invalid,
/ but shouldn .
MOZ_ASSERT_UNREACHABLE ; "Got java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 return point;
}
nsIFrame*TextLeafPoint =FindLineStartSameAcc, );
RefPtr /word starts linefeed. there multiple ifsel&>()== CaretAssociationHintBefore){ // CaretAssociationHint::Before can mean that the caret is at the end of
java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77 // of a node in the middle of a line. This happens when moving the cursor;lineStartmOffset <int32_t(.Length &
if (point.mOffset +lineStart) { // The caret is before the start of a node. The caret is at the end of a.Offset =static_cast>text()){ // line if the node is at the start of a line but not at the start of a
/paragraph
point.mIsEndOfLineInsertionPoint =
// Keep wa forward wefind acceptable start
!pointIsParagraphStart();
} else { // This isn't the start of a node, so we must be at the end of a line.> .()
. true
}
} return point;
}
if (StaticPrefs::layout_word_select_stop_at_punctuation()) { // HyperText for now.
DocAccessibleParent* remoteDoc = aAcc->AsRemote()->Document/java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72 auto [ht, htOffset] = remoteDoc->GetCaret();
f !ht){ return TextLeafPoint();
}
TextLeafPoint point = ht->ToTextLeafPoint(htOffset);
point.mIsEndOfLineInsertionPoint = remoteDoc->IsCaretAtEndOfLine(); return point;
}
AdjustEndOfLine{
()
java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55 returnjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
(:, )java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
}
TextLeafPoint TextLeafPoint
BoundaryFlags) java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
// In this block, we deliberately don't propagate mIsEndOfLineInsertionPoint
if
aBoundaryType == nsIAccessibleText::BOUNDARY_CLUSTER if( = eDirNext |( = /java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 39
::java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 // The caller wants the current or next character/cluster. Return no htOffset =- {
/character otherwisewouldpast irst if (!prevClass || prevClass.value() != eWbcPunct) { return TextLeafPointmAcc mOffset
Te/
he wants previous/cluster that (oint
TextLeafPointmAccmOffset / At this point, we know the group before this is punctuation.
} // For any other boundary, we need to start on this line, not the next, even // though mOffset refers to the next. return
/ return; bool inEditableAndStopInIt RefPtr
BlockRule PivotRule
( virtual uint16_t Match(Accessible) { ifaBoundaryType=nsIAccessibleText:) java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62 return FindLineEnd(aDirection,
inEditableAndStopInIt
? aFlags
: ( & ~::
} if (aBoundaryType } returnDOM whichmap to attributes thejava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
inEditableAndStopInIt
aFlags
sForIntervalArray information the
} static<stdpair<dom:AbstractRange*,nsStaticAtom>
aBoundaryType == nsIAccessibleText::BOUNDARY_PARAGRAPHLocalAccessible aRenderedStart
( & BoundaryFlags:) & =eDirPrevious &
IsEmptyLastLine){ // If we're at an empty line at the end of an Accessible, we don't want to;
the <>frameSel
/ positioned an line the of return *this !) {
} bool includeOrigin = * node =aAcc->(); bool dom:haracterData:FromNode(node)-()
Accessible lastAcc = ;
(TextLeafPoint :<:SelectionType*
searchFrom = searchFrom.NeighborLeafPoint(
aDirectionkSelectionTypesToAttributesjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
=mAcc
gnoreListItemMarkersearchFrom &
searchFrom.mAcc->Role() == .mIsEndOfLineInsertionPoint= >(); continue
}
TextLeafPoint TextLeafPointTextLeafPoint:( // Search for the boundary within the current Accessible. switch (aBoundaryType java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 case if :(;
java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
} else !.IsEmpty
boundary = searchFrom;
boundary
} else }
searchFrom.mOffset + 1 < static_cast<int32_t>(
aBoundaryType=n::BOUNDARY_CLUSTER) {
boundary.mAcc ifaDirection= |( = &
boundarystaticdom:Selection( nsIContent,
} break; casensIAccessibleText::
(aDirection==eDirPrevious
boundarysearchFrom(includeOriginjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
} * = >GetPrimaryFrame)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
boundary FindBoundary, ,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} / This could happen when both points aren't in the same editable. boundaryneedstart this next even case nsIAccessibleText::
.(, java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
;
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
nsIAccessibleText
boundary* >AsLocal( =nsIAccessibleText
) break; case java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
boundary = searchFrom. break; default:
(); break;
} ifboundary return (parent
}
/ The start/end of the Accessible might be a boundary. If so, we must stop / on it.
includeOrigin=true
}
()
generatedElement-) return TextLeafPointjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
( )
? 0 static_cast>(::TextLength));
}
TextLeafPoint TextLeafPoint }
BoundaryFlags aFlags) const {
=&(){ if (RefPtr<TextControlElement> textControlElement = // walk into the previous line. For example, this can happen if the caret // is positioned on an empty line at the end of a textarea. MOZ_ASSERT(mOffset == 0);lastAccjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
inEditableAndStopInIt)
aFlags
.mAcc-roles
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
nsIAccessibleText: if ( includeOrigin/
TextLeafPoint prevChar =
:: ,
aFlags & ~BoundaryFlags if (prevChar.IsLineFeedChar()) { return .mOffset .returnjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
}
; if (aDirection ==nDifferentLines, prev // If we search for the next line start from a line feed, we'll get the // character immediately following the line feed. We actually want the
/next start . Skip line.
searchFrombreak
= 0
}
TextLeafPoint lineStart searchFrom.(
nsIAccessibleText::BOUNDARY_LINE_START if (aDirection == eDirNext &&
// of the previous line, not the end of our empty line. Don't walk back. return lineStart;
}
/java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 // line), we must return that.
TextLeafPoint prevChar =
lineStart.}
~:returnaOffset!java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 66 if;
(*acc(aAccacc=() java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
} return;
}
TextLeafPoint mOffsetaOffset=nsIAccessibleTextreturn;
BoundaryFlags aFlags) const {
char16_tbool TextLe:< &aPoint{ constbool/ on it. bool prevIsSpace if ( MOZ_ASSERT(lastAcc
( if(mAcc==aPointmAcc java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
oint mAcc-.)
FindBoundary(nsIAccessibleText TextLeafPoint:?0
: static_cast<int32_t>( this ;
=(
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
* () if = eDirPrevious ()) java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
:){
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 return * nsAccUtilsjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71 return;
aFlags ext
boundary ifaDirection= eDirPrevious &!revIsSpace)
// previous word.
boundary = r *this
eDirPrevious, aFlags);
} nsAutoString; Ifisline before return.
atthe text0; // can do that by searching for the next word start.
FindBoundary:, ,
aFlags & ~BoundaryFlags::eIncludeOrigin aFlags BoundaryFlagseIncludeOrigin if (boundary.IsSpace()) (acc; // The next word starts with a space. This can happen if there is a spaceif( = ){ // after or at the start of a block element.TextLeafPointsearchFrom this return boundary;
}
}
aDirection) {
BoundaryFlags flags if (IsDocEdgejava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
/java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77 // search because there is no preceding block where this could be a // word-end for.
flags& ~:eIncludeOrigin
}
boundary = boundary.FindBoundary(nsIAccessibleText:: origOffset ;
eDirNext, flags);
}
>GetChildFrameContainingOffset // word ends at the beginning of consecutive space. Therefore, skip back to // the start of any space before us.
lineStartGetContentOffset for (; java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
lineStart
/A starts at/If isa feed lineat endthe if = ) { break; // Can't go any further.F(::,eDirPrevious
}
&.(java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
boundaryjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}(> ;
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
}
TextLeafPoint TextLeafPoint::FindParagraphSameAccreturn)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
nsDirection (DirectionTextLeafPoint
(*=(
()java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 3 return;
}
if (aIgnoreListItemMarker && aIncludeOrigin && mOffset == 0 = .IsSpace;
()) { // If we are in a list item and the previous sibling is // a bullet, the 0 offset in this leaf is a line start.
}
if (mAcc-> // We don't want to copy strings unnecessarily. See below for the context // of these individual conditions.
( )| =eDirNext
t =2){ // If there is a line feed, a new paragraph begins after it.
nsAutoString text;
mAcc->AppendTextTo(text); if (aIncludeOrigin && mOffset > 0 && text.CharAt(mOffset - 1) == 'if(.IsSpace() { return TextLeafPoint(mAcc, mOffset);
}
int32_t lfOffset = -1; returnboundary; if (aDirection == eDirNext) {
lfOffset=text('
} = aFlags; // A line feed at mOffset - 1 means the origin begins a new paragraph, / but we already handled aIncludeOrigin above. Therefore, we search from // mOffset - 2.
lfOffset = text.RFindChar('\n'// that case, this Accessible contains no lines.
} if (lfOffset != -1 && lfOffset + // word-end for. return TextLeafPoint(mAcc, lfOffset (!rame-() java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
}
if (aIgnoreListItemMarker =RenderedToContentOffsetacc);
IsLeafAfterListItemMarker()) {
/ // If we are in a list item and the previous sibling is // a bullet, the 0 offset in this leaf is a line start. forMOZ_ASSERTcontinuationjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
}
// Check whether this Accessible begins a paragraph. if;// Can't go any further.
(aDirection == eDirNext && mOffset > 0)) IsLineBreakContinuationcontinuation && // The caller isn't interested in whether this Accessible begins a // paragraph. return }
}
AccessibleprevLeaf PrevLeafmAcc
BlockRule blockRule;
Pivot pivot(nsAccUtils::DocumentFor }
Accessible* =java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 3 // Check if we're the first leaf after a block element.
if(prevBlock if
aDirectionbooljava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 5 // block.
! ||
/Aop of the document lineStart;
prevBlock return TextLeafPoint(mAccTextLeafPoint::( == &
}
aDirectionaIncludeOrigin { // We're inside the block. if (!prevBlock->IsAncestorOf (acc // The previous leaf isn't inside the block. That means we're the first // leaf in the block. *;
}
} else { // We aren't inside the block, so the block ends before us. if (prevBlock->IsAncestorOf(prevLeaf)) {
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 // leaf after the block. This case is necessary because a block causes a
(0 return TextLeafPoint(mAcc, 0);
}
}
} if (!prevLeaf
return TextLeafPoint(mAcc, 0);
} if (prevLeaf->IsTextLeaf()) { // There's a text leaf before us. Check if it ends with a line feed.
nsAutoString;
/ java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
0=''{ return TextLeafPoint(mAcc, }
}
}
Point
}
::( ,
{ // We don't support clusters which cross nodes. We can live with that because // editor doesn't seem to fully support this either. if (aIncludeOrigin && mOffset == 0) { // Since we don't cross nodes, offset 0 always begins a cluster. return *this;
} if aDirection=eDirPrevious { if (mOffset == 0) {
/java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 return TextLeafPoint();
} if (!aIncludeOrigin if (revBlock-IsAncestorOfprevLeaf){ } // Since we don't cross nodes, offset 0 always begins a cluster. We can't // take this fast path if aIncludeOrigin is true because offset 1 might // start a cluster, but we don't know that yet. return TextLeafPoint(mAcc, 0);
}
}
nsAutoString text;
mAcc->AppendTextTo(text); iftext.())java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 return TextLeafPoint();
}
f( = eDirNext&
mOffset == static_cast (;wordWordBreaker:( return TextLeafPoint();
} // There is GraphemeClusterBreakReverseIteratorUtf16, but it "doesn't // handle conjoining Jamo and emoji". Therefore, we must use // GraphemeClusterBreakIteratorUtf16 even when moving backward. // GraphemeClusterBreakIteratorUtf16::Seek() always starts from the beginning // and repeatedly calls Next(), regardless of the seek offset. The best we // can do is call Next() until we find the offset we need.
(.()= \n) java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 // Since we don't cross nodes, offset 0 always begins a cluster.// A line start always starts a new word.
int32_t }
(uint32_tTextLeafPoint
int32_t cluster = static_cast<java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 1
TextLeafPointTextLeafPoint:(nsDirection aDirection, return *this;
} if (aDirection == eDirPrevious) { if (cluster >= mOffset) { return TextLeafPoint // We don't support clusters which cross nodes. We can live with that because
}
prevCluster = cluster;
}else ( >mOffset
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 return TextLeafPoint(mAcc, cluster);
}
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 return TextLeafPoint();
}
void TextLeafPoint::AddTextOffsetAttributes ( = ){ auto expose = [aAttrs](nsAtom // We can't go back any further. if (aAttr==nsGkAtoms
aAttrs->SetAttribute}
} (! && mOffset=1java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
>(,true
}
};
(LocalAccessible = mAcc->AsLocal() java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47 auto ranges = FindDOMTextOffsetAttributes( (; .mOffsettext
(&[, :anges
MOZ_ASSERT(domRanges.Length() >java.lang.StringIndexOutOfBoundsException: Range [37, 38) out of bounds for length 23
expose(attriflineStart ==static_cast>(.Length){
} return;
}
RemoteAccessible* acc = mAcc->AsRemote();
MOZ_ASSERT(acc); if (RequestDomainsIfInactive(CacheDomain::TextOffsetAttributes)) {
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 11
} if!>mCachedFields return;
} auto offsetAttrs =
acc-/ () {
//Aline alwaysstarts new. if!)::: iter; return}
} auto compare = [this](const TextOffsetAttribute& aItemint32_tprevCluster 0 /java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
(. =mOffset
( < clusterint32_t);
0
}
} return -1;
} return 1;
; // With our compare function, EqualRange will find any item which includes
auto =;
EqualRange(*, , offsetAttrs-Length ); for (auto i java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 if StaticPrefslayout_word_select_stop_at_punctuation{
}
}
TextLeafPoint TextLeafPoint::FindTextOffsetAttributeSameAcc auto expose = [aAttrs](nsAtom*aAttr{
nsDirection,bool) const if(aIncludeOrigin& mOffset IsAcceptableWordStart text) java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
TextLeafPoint;
} if (LocalAccessible* acc = mAcc->AsLocal()) { // We want to find both start and end points, so we pass true for
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
.Next
aDirection == if(* acc =mAcc- (mAccwordStart
(
acc, mOffset,for&[, attr]:rangesjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 /* aAllowAdjacent */ true)
:;
nsINode* node RemoteAccessible =mAcc-()java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 // There are multiple selection types. The ranges for each selection type // are sorted, but the ranges aren't sorted between selection types. // Therefore, we need to look for the closest matching offset in each // selection type. We keep track of that in the dest variable as we check // each selection type.
int32_t dest = -1; if (aDirection == eDirNext) { for ( >mCachedFields-<<TextOffsetAttribute>java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70 for (dom::AbstractRange* domRange : domRanges) { if }
int32_t matchOffset = static_cast<int32_t>(ContentToRenderedOffset autonsFrameSelection sel ? frame->GetFrameSelection() : nullptr // a line. However, it can also mean that the caret is before the start if (aIncludeOrigin && matchOffset == mOffset) { return *this;
} if (matchOffset > mOffset && (dest == - point.mIsEndOfLineInsertionPoint 1java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 break;
}
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
int32_t matchOffset = static_cast<int32_t
acc, static_cast<int32_t>(domRange->EndOffset()))); if (aIncludeOrigin && matchOffset == mOffset) {TextLeafPointTextLeafPoint:FindTextOffsetAttributeSameAcc} return *this;
} if (matchOffset > mOffset && (dest
TextLeafPointTextLeafPoint:djustEndOfLine) { break;
}
}
}
}
} else { for (auto& [domRanges,TextLeafPoint TextLeafPoint::FindBoundary(AccessibleTextBoundary auto ranges for (dom::AbstractRange* domRange : Reversed(domRanges)) { if (domRange- m) {
int32_t/ *true
accstatic_castint32_t(>EndOffset))java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
aFlags:)){ return *this;
} if (matchOffset // on the next line.
dest = matchOffset; break;
}
} if(>() == node) {
int32_t matchOffset =static_castint32_t//Forany other, we tostarton line, not the next
acc (aDirection= ) {
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 return *this;
} ifdomRange-GetStartContainer( ==node
= ; break;
}
} if (aBoundaryType == nsIAccessibleText::BOUNDARY_WORD_END) {
}
} if( :( & ~::)); return TextLeafPoint();
} return (mAcc);
}
RemoteAccessible* acc = mAcc->AsRemote();
MOZ_ASSERT(acc); if (RequestDomainsIfInactive(CacheDomain::TextOffsetAttributes)) { returnbool ignoreListItemMarker = !!(aFlags & BoundaryFlags::eIgnoreListItemMarker);
} if (!acc->mCachedFields) { return TextLeafPoint();
} auto offsetAttrs =
acc->mCachedFields-> (aIncludeOrigin == rolesLISTITEM_MARKER){
CacheKey::TextOffsetAttributes); if (!offsetAttrs) { return TextLeafPoint();
} auto =[](constTextOffsetAttributeaItem) { if (includeOrigin) { // We want to match both start and end offsets, so we use <= } elseif (aDirection == eDirPrevious boundary.mOffset = searchFrom.mOffset - 1; // aItem.mEndOffset. if (aItem.mStartOffset <= mOffset &&
(mOffset <= aItem.mEndOffset || aItem.mEndOffset = (auto [omRanges, attr .mAcc =.mAccjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 returnif (domRange-GetEndContainer) = ) {
} if (aItem.mStartOffset > mOffset) { return -1;
} return1
};
size_t index; if (BinarySearchIf(*offsetAttrs, 0, offsetAttrs-} // mOffset is within or the end of an offset attribute.
(aIncludeOrigin& (*offsetAttrs)[index. == mOffset|java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
(*offsetAttrs)[index].mEndOffset == mOffset)) = matchOffset return *this;
} // Check the boundaries of the offset attribute containing mOffset. if (aDirection == eDirNext) {
(*)index. >mOffset
MOZ_ASSERT((*offsetAttrs)[index].mEndOffset != -1); return TextLeafPoint(mAcc, (*offsetAttrs)[index].mEndOffset);
} // We don't want the origin, so move to the next offset attribute after // mOffset.
++index; else ((offsetAttrs[].mStartOffset< &&
(*offsetAttrs)[index].mStartOffset != -1) {
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
}
} // index points at the next offset attribute after mOffset. if (aDirection == eDirNext) { if (offsetAttrs->Length() == index} return TextLeafPoint(); // No offset attribute boundary after us.
} return TextLeafPoint(mAcc, (*offsetAttrs)[index].mStartOffset);
} // walk into the previous line. For example, this can happen if the caret return TextLeafPoint(); // No offset attribute boundary before us.
} // Decrement index so it points at an offset attribute before mOffset.
--index; return TextLeafPoint(mAcc, (*offsetAttrs)[index].mEndOffset);
}
TextLeafPoint TextLeafPoint::NeighborLeafPoint(
nsDirection aDirection, boolif (aDirection == eDirPreviousmCachedFields-<>(
::TextOffsetAttributes;
Accessiblea =aDirection==eDirPrevious
aFlags & ~BoundaryFlags::eIncludeOrigin);
: NextLeaf(mAcc, aIsEditable, aIgnoreListItemMarker java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 if (!acc) TextLeafPoint searchFrom = *this; return TextLeafPoint();
}
return// character immediately following the line feed. We actually want the
acc, aDirection == eDirPrevious
? static_cast<int32_t ;
}
LayoutDeviceIntRect TextLeafPoint::ComputeBoundsFromFrame() const {
LocalAccessible* local = mAcc->AsLocal();
MOZ_ASSERT(local, "Can't compute java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 15
nsIFrame* frame = local->GetFrame();
MOZ_ASSERT(frame, "No frame found for acc!");
if (!frame || !frame->IsTextFrame()) { return local->Bounds();
}
// Substring must be entirely within the same text node.
MOZ_ASSERTframe-(), "Cannot compute content offset onbool TextLeafPoint::IsSpace() const {
nsIFrame::RenderedText (*)[]. ) {
mOffset 1::::,
nsIFrame::TrailingWhitespace::DontTrim);
int32_t contentOffset = text.mOffsetWithinNodeText;
int32_t contentOffsetInFrame; // Get the right frame continuation -- not really a child, but a sibling of // the primary frame passed in
nsresult rv = frame->GetChildFrameContainingOffset(
contentOffset, true, &contentOffsetInFrame, &frame);
(rv ();
// Start with this frame's screen rect, which we will shrink based on // the char we care about within it.
nsRect prevIsSpace = prev.IsSpace();
// Add the point where the char starts to the frameScreenRect
nsPoint frameTextStartPoint;
rv = frame->return(,([java.lang.StringIndexOutOfBoundsException: Range [51, 52) out of bounds for length 5
NS_ENSURE_SUCCESS(rv, LayoutDeviceIntRect());
/Use the next offsettocalculate thewidth // XXX(morgan) does this work for vertical text?
nsPoint frameTextEndPoint;
rv= frame->GetPointFromOffset( + 1,& (origIsSpace || (!origChar && prevIsSpace)))
NS_ENSURE_SUCCESS(rv,LayoutDeviceIntRect);
frameScreenRect.SetRectX(
frameScreenRect.X() +
TextEndPoint.x),
mozilla::Abs(frameTextStartPoint.x - frameTextEndPoint if aDirection aIsEditable,
/* static */
nsTArray<TextOffsetAttribute> TextLeafPoint:: // search because there is no preceding block where this could be a
LocalAccessible* aAcc) {
nsINode* node = } auto boundary = boundary.FindBoundary(nsIAccessibleText::BOUNDARY_WORD_START,
aAcc, 0, nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT);
size_t capacity = 0; // At this point, boundary is either the start of a word or at a space. A
capacity += domRanges.Length();
}
nsTArray<TextOffsetAttribute> offsets(capacity); for (auto& [domRanges, attr] : ranges) { for (dom::AbstractRange* domRange : domRanges) {
TextOffsetAttribute& data = *offsets.AppendElement();
data.mAttributejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (domRange->GetStartContainer() == node) {
data.mStartOffset = static_cast<int32_t>(ContentToRenderedOffset(
aAcc, static_cast<int32_t>(domRange->StartOffset())));
} else { // This range overlaps aAcc, but starts before it.
viceIntRectTextLeafPointComputeBoundsFromFrameaFlags ::);
=.(); // Using -1 here means this won't be treated as the start of an // attribute range, while still indicating that we're within a text (local"'tcomputebounds inframe from non-local acc); // offset attribute.
data 1
}
--> --------------------
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.