Bug 1694573 part 4: Make PlatformTextSelectionEvent take TextRange instead of TextRangeData. r=eeejay

TextRangeData is specific to IPDL and thus RemoteAccessible.

Differential Revision: https://phabricator.services.mozilla.com/D183703
This commit is contained in:
James Teh 2023-07-19 02:56:54 +00:00
parent ecc3d38304
commit 4458083853
3 changed files with 13 additions and 14 deletions

View File

@ -126,9 +126,9 @@ bool LocalizeString(const nsAString& aToken, nsAString& aLocalized);
#endif
#ifdef MOZ_WIDGET_COCOA
class TextRangeData;
void PlatformTextSelectionChangeEvent(
Accessible* aTarget, const nsTArray<TextRangeData>& aSelection);
class TextRange;
void PlatformTextSelectionChangeEvent(Accessible* aTarget,
const nsTArray<TextRange>& aSelection);
void PlatformRoleChangedEvent(Accessible* aTarget, const a11y::role& aRole,
uint8_t aRoleMapEntryIndex);

View File

@ -707,7 +707,9 @@ mozilla::ipc::IPCResult DocAccessibleParent::RecvTextSelectionChangeEvent(
mTextSelections.AppendElements(aSelection);
#ifdef MOZ_WIDGET_COCOA
PlatformTextSelectionChangeEvent(target, aSelection);
AutoTArray<TextRange, 1> ranges;
SelectionRanges(&ranges);
PlatformTextSelectionChangeEvent(target, ranges);
#else
PlatformEvent(target, nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED);
#endif
@ -1083,6 +1085,7 @@ mozilla::ipc::IPCResult DocAccessibleParent::RecvFocusEvent(
}
void DocAccessibleParent::SelectionRanges(nsTArray<TextRange>* aRanges) const {
aRanges->SetCapacity(mTextSelections.Length());
for (const auto& data : mTextSelections) {
// Selection ranges should usually be in sync with the tree. However, tree
// and selection updates happen using separate IPDL calls, so it's possible

View File

@ -16,6 +16,7 @@
#include "mozTextAccessible.h"
#include "MOXWebAreaAccessible.h"
#include "nsAccUtils.h"
#include "TextRange.h"
#include "nsAppShell.h"
#include "nsCocoaUtils.h"
@ -168,20 +169,15 @@ void PlatformSelectionEvent(Accessible* aTarget, Accessible* aWidget,
}
}
void PlatformTextSelectionChangeEvent(
Accessible* aTarget, const nsTArray<TextRangeData>& aSelection) {
void PlatformTextSelectionChangeEvent(Accessible* aTarget,
const nsTArray<TextRange>& aSelection) {
if (aSelection.Length()) {
// XXX Don't assume aTarget is remote.
MOXTextMarkerDelegate* delegate = [MOXTextMarkerDelegate
getOrCreateForDoc:aTarget->AsRemote()->Document()];
DocAccessibleParent* doc = aTarget->AsRemote()->Document();
RemoteAccessible* startContainer =
doc->GetAccessible(aSelection[0].StartID());
RemoteAccessible* endContainer = doc->GetAccessible(aSelection[0].EndID());
getOrCreateForDoc:nsAccUtils::DocumentFor(aTarget)];
// Cache the selection.
[delegate setSelectionFrom:startContainer
[delegate setSelectionFrom:aSelection[0].StartContainer()
at:aSelection[0].StartOffset()
to:endContainer
to:aSelection[0].EndContainer()
at:aSelection[0].EndOffset()];
}