Bug 1909142 part 1: Add Selection and nsFrameSelection getters to enable the accessibility engine to query custom highlight information. r=jjaschke

Differential Revision: https://phabricator.services.mozilla.com/D233805
This commit is contained in:
James Teh
2025-02-05 22:59:15 +00:00
parent f1aaea80be
commit 24f35ca025
3 changed files with 20 additions and 2 deletions

View File

@@ -4445,7 +4445,7 @@ void Selection::SetColors(const nsAString& aForegroundColor,
void Selection::ResetColors() { mCustomColors = nullptr; }
void Selection::SetHighlightSelectionData(
HighlightSelectionData aHighlightSelectionData) {
struct HighlightSelectionData aHighlightSelectionData) {
MOZ_ASSERT(mSelectionType == SelectionType::eHighlight);
mHighlightData = std::move(aHighlightSelectionData);
}

View File

@@ -604,6 +604,10 @@ class Selection final : public nsSupportsWeakReference,
void SetHighlightSelectionData(
HighlightSelectionData aHighlightSelectionData);
const HighlightSelectionData& HighlightSelectionData() const {
return mHighlightData;
}
/**
* See documentation of `GetRangesForInterval` in Selection.webidl.
*
@@ -1123,7 +1127,7 @@ class Selection final : public nsSupportsWeakReference,
CachedOffsetForFrame* mCachedOffsetForFrame;
nsDirection mDirection;
const SelectionType mSelectionType;
HighlightSelectionData mHighlightData;
struct HighlightSelectionData mHighlightData;
UniquePtr<SelectionCustomColors> mCustomColors;
// Non-zero if we don't want any changes we make to the selection to be

View File

@@ -466,6 +466,20 @@ class nsFrameSelection final {
return *GetSelection(mozilla::SelectionType::eNormal);
}
/**
* Returns the number of highlight selections.
*/
size_t HighlightSelectionCount() const {
return mHighlightSelections.Length();
}
/**
* Get a highlight selection by index. The index must be valid.
*/
RefPtr<mozilla::dom::Selection> HighlightSelection(size_t aIndex) const {
return mHighlightSelections[aIndex].second();
}
/**
* @brief Adds a highlight selection for `aHighlight`.
*/