summaryrefslogtreecommitdiffstats
path: root/accessible/android/SessionAccessibility.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /accessible/android/SessionAccessibility.h
parentInitial commit. (diff)
downloadfirefox-esr-upstream/115.8.0esr.tar.xz
firefox-esr-upstream/115.8.0esr.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/android/SessionAccessibility.h')
-rw-r--r--accessible/android/SessionAccessibility.h122
1 files changed, 122 insertions, 0 deletions
diff --git a/accessible/android/SessionAccessibility.h b/accessible/android/SessionAccessibility.h
new file mode 100644
index 0000000000..5ec0293d3d
--- /dev/null
+++ b/accessible/android/SessionAccessibility.h
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_a11y_SessionAccessibility_h_
+#define mozilla_a11y_SessionAccessibility_h_
+
+#include "mozilla/java/SessionAccessibilityNatives.h"
+#include "mozilla/widget/GeckoViewSupport.h"
+#include "nsAppShell.h"
+#include "nsThreadUtils.h"
+#include "nsWindow.h"
+#include "AccessibleWrap.h"
+
+namespace mozilla {
+namespace a11y {
+
+class AccessibleWrap;
+class AccAttributes;
+class Accessible;
+class RemoteAccessible;
+class RootAccessibleWrap;
+class BatchData;
+
+class SessionAccessibility final
+ : public java::SessionAccessibility::NativeProvider::Natives<
+ SessionAccessibility> {
+ public:
+ typedef java::SessionAccessibility::NativeProvider::Natives<
+ SessionAccessibility>
+ Base;
+
+ SessionAccessibility(
+ jni::NativeWeakPtr<widget::GeckoViewSupport> aWindow,
+ java::SessionAccessibility::NativeProvider::Param aSessionAccessibility);
+
+ void OnWeakNonIntrusiveDetach(already_AddRefed<Runnable> aDisposer) {
+ SetAttached(false, std::move(aDisposer));
+ }
+
+ const java::SessionAccessibility::NativeProvider::Ref&
+ GetJavaAccessibility() {
+ return mSessionAccessibility;
+ }
+
+ static void Init();
+ static RefPtr<SessionAccessibility> GetInstanceFor(Accessible* aAccessible);
+ static RefPtr<SessionAccessibility> GetInstanceFor(PresShell* aPresShell);
+
+ // Native implementations
+ using Base::AttachNative;
+ using Base::DisposeNative;
+ void GetNodeInfo(int32_t aID, mozilla::jni::Object::Param aNodeInfo);
+ int GetNodeClassName(int32_t aID);
+ void SetText(int32_t aID, jni::String::Param aText);
+ void Click(int32_t aID);
+ bool Pivot(int32_t aID, int32_t aGranularity, bool aForward, bool aInclusive);
+ void ExploreByTouch(int32_t aID, float aX, float aY);
+ void NavigateText(int32_t aID, int32_t aGranularity, int32_t aStartOffset,
+ int32_t aEndOffset, bool aForward, bool aSelect);
+ void SetSelection(int32_t aID, int32_t aStart, int32_t aEnd);
+ void Cut(int32_t aID);
+ void Copy(int32_t aID);
+ void Paste(int32_t aID);
+ void StartNativeAccessibility();
+
+ // Event methods
+ void SendFocusEvent(Accessible* aAccessible);
+ void SendScrollingEvent(Accessible* aAccessible, int32_t aScrollX,
+ int32_t aScrollY, int32_t aMaxScrollX,
+ int32_t aMaxScrollY);
+ MOZ_CAN_RUN_SCRIPT_BOUNDARY
+ void SendAccessibilityFocusedEvent(Accessible* aAccessible);
+ void SendHoverEnterEvent(Accessible* aAccessible);
+ void SendTextSelectionChangedEvent(Accessible* aAccessible,
+ int32_t aCaretOffset);
+ void SendTextTraversedEvent(Accessible* aAccessible, int32_t aStartOffset,
+ int32_t aEndOffset);
+ void SendTextChangedEvent(Accessible* aAccessible, const nsAString& aStr,
+ int32_t aStart, uint32_t aLen, bool aIsInsert,
+ bool aFromUser);
+ void SendSelectedEvent(Accessible* aAccessible, bool aSelected);
+ void SendClickedEvent(Accessible* aAccessible, uint32_t aFlags);
+ void SendWindowContentChangedEvent();
+ void SendWindowStateChangedEvent(Accessible* aAccessible);
+ void SendAnnouncementEvent(Accessible* aAccessible,
+ const nsAString& aAnnouncement,
+ uint16_t aPriority);
+
+ Accessible* GetAccessibleByID(int32_t aID) const;
+
+ static const int32_t kNoID = -1;
+ static const int32_t kUnsetID = 0;
+
+ static void RegisterAccessible(Accessible* aAccessible);
+ static void UnregisterAccessible(Accessible* aAccessible);
+ static void UnregisterAll(PresShell* aPresShell);
+
+ NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SessionAccessibility)
+
+ private:
+ ~SessionAccessibility() {}
+
+ void PopulateNodeInfo(Accessible* aAccessible,
+ mozilla::jni::Object::Param aNodeInfo);
+
+ void SetAttached(bool aAttached, already_AddRefed<Runnable> aRunnable);
+
+ jni::NativeWeakPtr<widget::GeckoViewSupport> mWindow; // Parent only
+ java::SessionAccessibility::NativeProvider::GlobalRef mSessionAccessibility;
+
+ /*
+ * This provides a mapping from 32 bit id to accessible objects.
+ */
+ nsTHashMap<nsUint32HashKey, Accessible*> mIDToAccessibleMap;
+};
+
+} // namespace a11y
+} // namespace mozilla
+
+#endif