commit 19e5b824619d58f0acf1a0d8b6a357e97d696909
parent d97c693d3e02bbb6765181a3a6f808e1d4267eb5
Author: longsonr <longsonr@gmail.com>
Date: Fri, 10 Oct 2025 18:33:35 +0000
Bug 1992865 r=jfkthame,emilio
Differential Revision: https://phabricator.services.mozilla.com/D267948
Diffstat:
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp
@@ -3621,18 +3621,22 @@ void SVGTextFrame::SelectSubString(nsIContent* aContent, uint32_t charnum,
UpdateGlyphPositioning();
- // Convert charnum/nchars from addressable characters relative to
- // aContent to global character indices.
- CharIterator chit(this, CharIterator::eAddressable, aContent);
- if (!chit.AdvanceToSubtree() || !chit.Next(charnum) ||
- chit.IsAfterSubtree()) {
- aRv.ThrowIndexSizeError("Character index out of range");
- return;
+ RefPtr<nsIContent> content;
+
+ {
+ // Convert charnum/nchars from addressable characters relative to
+ // aContent to global character indices.
+ CharIterator chit(this, CharIterator::eAddressable, aContent);
+ if (!chit.AdvanceToSubtree() || !chit.Next(charnum) ||
+ chit.IsAfterSubtree()) {
+ aRv.ThrowIndexSizeError("Character index out of range");
+ return;
+ }
+ charnum = chit.TextElementCharIndex();
+ content = chit.GetTextFrame()->GetContent();
+ chit.NextWithinSubtree(nchars);
+ nchars = chit.TextElementCharIndex() - charnum;
}
- charnum = chit.TextElementCharIndex();
- const RefPtr<nsIContent> content = chit.GetTextFrame()->GetContent();
- chit.NextWithinSubtree(nchars);
- nchars = chit.TextElementCharIndex() - charnum;
RefPtr<nsFrameSelection> frameSelection = GetFrameSelection();