Skip to content

Commit

Permalink
Bug 1840574: Don't try to get the selection in HyperTextAccessible::G…
Browse files Browse the repository at this point in the history
…etSelectionDOMRanges if the initial tree hasn't been constructed yet. r=morgan

Differential Revision: https://phabricator.services.mozilla.com/D199601
  • Loading branch information
jcsteh committed Jan 30, 2024
1 parent ec805ae commit 673de14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions accessible/generic/HyperTextAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,17 @@ LayoutDeviceIntRect HyperTextAccessible::GetCaretRect(nsIWidget** aWidget) {

void HyperTextAccessible::GetSelectionDOMRanges(SelectionType aSelectionType,
nsTArray<nsRange*>* aRanges) {
if (IsDoc() && !AsDoc()->HasLoadState(DocAccessible::eTreeConstructed)) {
// Rarely, a client query can be handled after a DocAccessible is created
// but before the initial tree is constructed, since DoInitialUpdate happens
// during a refresh tick. In that case, there might be a DOM selection, but
// we can't use it. We will crash if we try due to mContent being null, etc.
// This should only happen in the parent process because we should never
// try to push the cache in a content process before the initial tree is
// constructed.
MOZ_ASSERT(XRE_IsParentProcess(), "Query before DoInitialUpdate");
return;
}
// Ignore selection if it is not visible.
RefPtr<nsFrameSelection> frameSelection = FrameSelection();
if (!frameSelection || frameSelection->GetDisplaySelection() <=
Expand Down
2 changes: 1 addition & 1 deletion accessible/generic/LocalAccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ class LocalAccessible : public nsISupports, public Accessible {

// Data Members
// mContent can be null in a DocAccessible if the document has no body or
// root element.
// root element, or if the initial tree hasn't been constructed yet.
nsCOMPtr<nsIContent> mContent;
RefPtr<DocAccessible> mDoc;

Expand Down

0 comments on commit 673de14

Please sign in to comment.