Bug 1862802 part 2: Support find in page on Android using only caret events instead of converting them to virtual cursor change events. r=eeejay

Depends on D192642

Differential Revision: https://phabricator.services.mozilla.com/D192643
This commit is contained in:
James Teh 2023-11-28 22:03:19 +00:00
parent cfdccbd78f
commit ea3ee1204a
2 changed files with 16 additions and 22 deletions

View File

@ -65,25 +65,6 @@ nsresult AccessibleWrap::HandleAccEvent(AccEvent* aEvent) {
static_cast<DocAccessibleWrap*>(accessible->Document());
if (doc) {
switch (aEvent->GetEventType()) {
case nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED: {
if (accessible != aEvent->Document() && !aEvent->IsFromUserInput()) {
AccCaretMoveEvent* caretEvent = downcast_accEvent(aEvent);
HyperTextAccessible* ht = AsHyperText();
// Pivot to the caret's position if it has an expanded selection.
// This is used mostly for find in page.
if ((ht && ht->SelectionCount())) {
DOMPoint point =
AsHyperText()->OffsetToDOMPoint(caretEvent->GetCaretOffset());
if (LocalAccessible* newPos =
doc->GetAccessibleOrContainer(point.node)) {
static_cast<AccessibleWrap*>(newPos)->PivotTo(
java::SessionAccessibility::HTML_GRANULARITY_DEFAULT, true,
true);
}
}
}
break;
}
case nsIAccessibleEvent::EVENT_SCROLLING_START: {
accessible->PivotTo(
java::SessionAccessibility::HTML_GRANULARITY_DEFAULT, true, true);

View File

@ -146,10 +146,23 @@ void a11y::PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset,
bool aFromUser) {
RefPtr<SessionAccessibility> sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
if (sessionAcc) {
sessionAcc->SendTextSelectionChangedEvent(aTarget, aOffset);
if (!sessionAcc) {
return;
}
if (!aTarget->IsDoc() && !aFromUser && !aIsSelectionCollapsed) {
// Pivot to the caret's position if it has an expanded selection.
// This is used mostly for find in page.
Accessible* leaf = TextLeafPoint::GetCaret(aTarget).ActualizeCaret().mAcc;
MOZ_ASSERT(leaf);
if (Accessible* result = AccessibleWrap::DoPivot(
leaf, java::SessionAccessibility::HTML_GRANULARITY_DEFAULT, true,
true)) {
sessionAcc->SendAccessibilityFocusedEvent(result);
}
}
sessionAcc->SendTextSelectionChangedEvent(aTarget, aOffset);
}
void a11y::PlatformTextChangeEvent(Accessible* aTarget, const nsAString& aStr,