From 447aa32c0edc7f46d31725196608d0c9ea342d18 Mon Sep 17 00:00:00 2001 From: James Teh Date: Wed, 29 Nov 2023 03:53:19 +0000 Subject: [PATCH] Bug 1862802 part 1: Provide an argument to PlatformCaretMoveEvent specifying whether the event was caused by user input. r=eeejay This is needed in order to support find in page on Android using remote caret events instead of virtual cursor change events. Depends on D192641 Differential Revision: https://phabricator.services.mozilla.com/D192642 --- accessible/android/Platform.cpp | 3 ++- accessible/atk/AccessibleWrap.cpp | 3 ++- accessible/base/Platform.h | 3 ++- accessible/generic/LocalAccessible.cpp | 9 +++++---- accessible/ipc/DocAccessibleChild.cpp | 9 +++++---- accessible/ipc/DocAccessibleChild.h | 2 +- accessible/ipc/DocAccessibleParent.cpp | 5 +++-- accessible/ipc/DocAccessibleParent.h | 3 ++- accessible/ipc/PDocAccessible.ipdl | 2 +- accessible/mac/Platform.mm | 3 ++- accessible/other/Platform.cpp | 3 ++- accessible/windows/msaa/Platform.cpp | 3 ++- 12 files changed, 29 insertions(+), 19 deletions(-) diff --git a/accessible/android/Platform.cpp b/accessible/android/Platform.cpp index ed93025bfe53..b912f644383c 100644 --- a/accessible/android/Platform.cpp +++ b/accessible/android/Platform.cpp @@ -142,7 +142,8 @@ void a11y::PlatformFocusEvent(Accessible* aTarget, void a11y::PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset, bool aIsSelectionCollapsed, int32_t aGranularity, - const LayoutDeviceIntRect& aCaretRect) { + const LayoutDeviceIntRect& aCaretRect, + bool aFromUser) { RefPtr sessionAcc = SessionAccessibility::GetInstanceFor(aTarget); diff --git a/accessible/atk/AccessibleWrap.cpp b/accessible/atk/AccessibleWrap.cpp index 65c1836d6fbe..98f303ee4aad 100644 --- a/accessible/atk/AccessibleWrap.cpp +++ b/accessible/atk/AccessibleWrap.cpp @@ -1069,7 +1069,8 @@ void a11y::PlatformFocusEvent(Accessible* aTarget, void a11y::PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset, bool aIsSelectionCollapsed, int32_t aGranularity, - const LayoutDeviceIntRect& aCaretRect) { + const LayoutDeviceIntRect& aCaretRect, + bool aFromUser) { AtkObject* wrapper = GetWrapperFor(aTarget); g_signal_emit_by_name(wrapper, "text_caret_moved", aOffset); } diff --git a/accessible/base/Platform.h b/accessible/base/Platform.h index 2d984342f560..d22ddd664d68 100644 --- a/accessible/base/Platform.h +++ b/accessible/base/Platform.h @@ -99,7 +99,8 @@ void PlatformFocusEvent(Accessible* aTarget, const LayoutDeviceIntRect& aCaretRect); void PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset, bool aIsSelectionCollapsed, int32_t aGranularity, - const LayoutDeviceIntRect& aCaretRect); + const LayoutDeviceIntRect& aCaretRect, + bool aFromUser); void PlatformTextChangeEvent(Accessible* aTarget, const nsAString& aStr, int32_t aStart, uint32_t aLen, bool aIsInsert, bool aFromUser); diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp index 76b8a446bc8f..34d873b176fa 100644 --- a/accessible/generic/LocalAccessible.cpp +++ b/accessible/generic/LocalAccessible.cpp @@ -915,7 +915,8 @@ nsresult LocalAccessible::HandleAccEvent(AccEvent* aEvent) { AccCaretMoveEvent* event = downcast_accEvent(aEvent); ipcDoc->SendCaretMoveEvent( id, event->GetCaretOffset(), event->IsSelectionCollapsed(), - event->IsAtEndOfLine(), event->GetGranularity()); + event->IsAtEndOfLine(), event->GetGranularity(), + event->IsFromUserInput()); break; } case nsIAccessibleEvent::EVENT_TEXT_INSERTED: @@ -1038,9 +1039,9 @@ nsresult LocalAccessible::HandleAccEvent(AccEvent* aEvent) { // AccessibleWrap::UpdateSystemCaretFor currently needs to call // HyperTextAccessible::GetCaretRect again to get the widget and there's // no point calling it twice. - PlatformCaretMoveEvent(target, event->GetCaretOffset(), - event->IsSelectionCollapsed(), - event->GetGranularity(), rect); + PlatformCaretMoveEvent( + target, event->GetCaretOffset(), event->IsSelectionCollapsed(), + event->GetGranularity(), rect, event->IsFromUserInput()); break; } case nsIAccessibleEvent::EVENT_TEXT_INSERTED: diff --git a/accessible/ipc/DocAccessibleChild.cpp b/accessible/ipc/DocAccessibleChild.cpp index 67f0dd0b3e88..5f9d1a0a63fd 100644 --- a/accessible/ipc/DocAccessibleChild.cpp +++ b/accessible/ipc/DocAccessibleChild.cpp @@ -381,10 +381,11 @@ bool DocAccessibleChild::SendCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset, const bool& aIsSelectionCollapsed, const bool& aIsAtEndOfLine, - const int32_t& aGranularity) { - return PDocAccessibleChild::SendCaretMoveEvent(aID, GetCaretRectFor(aID), - aOffset, aIsSelectionCollapsed, - aIsAtEndOfLine, aGranularity); + const int32_t& aGranularity, + bool aFromUser) { + return PDocAccessibleChild::SendCaretMoveEvent( + aID, GetCaretRectFor(aID), aOffset, aIsSelectionCollapsed, aIsAtEndOfLine, + aGranularity, aFromUser); } #if !defined(XP_WIN) diff --git a/accessible/ipc/DocAccessibleChild.h b/accessible/ipc/DocAccessibleChild.h index def22c596b31..0a6164cce898 100644 --- a/accessible/ipc/DocAccessibleChild.h +++ b/accessible/ipc/DocAccessibleChild.h @@ -132,7 +132,7 @@ class DocAccessibleChild : public PDocAccessibleChild { bool SendCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset, const bool& aIsSelectionCollapsed, const bool& aIsAtEndOfLine, - const int32_t& aGranularity); + const int32_t& aGranularity, bool aFromUser); bool SendFocusEvent(const uint64_t& aID); #if !defined(XP_WIN) diff --git a/accessible/ipc/DocAccessibleParent.cpp b/accessible/ipc/DocAccessibleParent.cpp index b64ef0f7461a..38cede035526 100644 --- a/accessible/ipc/DocAccessibleParent.cpp +++ b/accessible/ipc/DocAccessibleParent.cpp @@ -439,7 +439,8 @@ mozilla::ipc::IPCResult DocAccessibleParent::RecvStateChangeEvent( mozilla::ipc::IPCResult DocAccessibleParent::RecvCaretMoveEvent( const uint64_t& aID, const LayoutDeviceIntRect& aCaretRect, const int32_t& aOffset, const bool& aIsSelectionCollapsed, - const bool& aIsAtEndOfLine, const int32_t& aGranularity) { + const bool& aIsAtEndOfLine, const int32_t& aGranularity, + const bool& aFromUser) { ACQUIRE_ANDROID_LOCK if (mShutdown) { return IPC_OK(); @@ -463,7 +464,7 @@ mozilla::ipc::IPCResult DocAccessibleParent::RecvCaretMoveEvent( } PlatformCaretMoveEvent(proxy, aOffset, aIsSelectionCollapsed, aGranularity, - aCaretRect); + aCaretRect, aFromUser); if (!nsCoreUtils::AccEventObserversExist()) { return IPC_OK(); diff --git a/accessible/ipc/DocAccessibleParent.h b/accessible/ipc/DocAccessibleParent.h index 49610c0888ba..452b2b4f6dc1 100644 --- a/accessible/ipc/DocAccessibleParent.h +++ b/accessible/ipc/DocAccessibleParent.h @@ -110,7 +110,8 @@ class DocAccessibleParent : public RemoteAccessible, mozilla::ipc::IPCResult RecvCaretMoveEvent( const uint64_t& aID, const LayoutDeviceIntRect& aCaretRect, const int32_t& aOffset, const bool& aIsSelectionCollapsed, - const bool& aIsAtEndOfLine, const int32_t& aGranularity) final; + const bool& aIsAtEndOfLine, const int32_t& aGranularity, + const bool& aFromUser) final; virtual mozilla::ipc::IPCResult RecvTextChangeEvent( const uint64_t& aID, const nsAString& aStr, const int32_t& aStart, diff --git a/accessible/ipc/PDocAccessible.ipdl b/accessible/ipc/PDocAccessible.ipdl index c947eb44f43f..d7ef1c355243 100644 --- a/accessible/ipc/PDocAccessible.ipdl +++ b/accessible/ipc/PDocAccessible.ipdl @@ -64,7 +64,7 @@ parent: LayoutDeviceIntRect aCaretRect, int32_t aOffset, bool aIsSelectionCollapsed, bool aIsAtEndOfLine, - int32_t aGranularity); + int32_t aGranularity, bool aFromUser); async TextChangeEvent(uint64_t aID, nsString aStr, int32_t aStart, uint32_t aLen, bool aIsInsert, bool aFromUser); async SelectionEvent(uint64_t aID, uint64_t aWidgetID, uint32_t aType); diff --git a/accessible/mac/Platform.mm b/accessible/mac/Platform.mm index 17a735940e13..eb507adefbe1 100644 --- a/accessible/mac/Platform.mm +++ b/accessible/mac/Platform.mm @@ -121,7 +121,8 @@ void PlatformFocusEvent(Accessible* aTarget, void PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset, bool aIsSelectionCollapsed, int32_t aGranularity, - const LayoutDeviceIntRect& aCaretRect) { + const LayoutDeviceIntRect& aCaretRect, + bool aFromUser) { mozAccessible* wrapper = GetNativeFromGeckoAccessible(aTarget); MOXTextMarkerDelegate* delegate = [MOXTextMarkerDelegate getOrCreateForDoc:nsAccUtils::DocumentFor(aTarget)]; diff --git a/accessible/other/Platform.cpp b/accessible/other/Platform.cpp index 43ba7f3b3103..038a7a6a8cdc 100644 --- a/accessible/other/Platform.cpp +++ b/accessible/other/Platform.cpp @@ -27,7 +27,8 @@ void a11y::PlatformFocusEvent(Accessible* aTarget, void a11y::PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset, bool aIsSelectionCollapsed, int32_t aGranularity, - const LayoutDeviceIntRect& aCaretRect) {} + const LayoutDeviceIntRect& aCaretRect, + bool aFromUser) {} void a11y::PlatformTextChangeEvent(Accessible*, const nsAString&, int32_t, uint32_t, bool, bool) {} diff --git a/accessible/windows/msaa/Platform.cpp b/accessible/windows/msaa/Platform.cpp index b0556b90e434..40dddac2159f 100644 --- a/accessible/windows/msaa/Platform.cpp +++ b/accessible/windows/msaa/Platform.cpp @@ -95,7 +95,8 @@ void a11y::PlatformFocusEvent(Accessible* aTarget, void a11y::PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset, bool aIsSelectionCollapsed, int32_t aGranularity, - const LayoutDeviceIntRect& aCaretRect) { + const LayoutDeviceIntRect& aCaretRect, + bool aFromUser) { AccessibleWrap::UpdateSystemCaretFor(aTarget, aCaretRect); MsaaAccessible::FireWinEvent(aTarget, nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED);