summaryrefslogtreecommitdiffstats
path: root/accessible/windows/msaa/Compatibility.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /accessible/windows/msaa/Compatibility.cpp
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-upstream/125.0.1.tar.xz
firefox-upstream/125.0.1.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/windows/msaa/Compatibility.cpp')
-rw-r--r--accessible/windows/msaa/Compatibility.cpp57
1 files changed, 46 insertions, 11 deletions
diff --git a/accessible/windows/msaa/Compatibility.cpp b/accessible/windows/msaa/Compatibility.cpp
index 440f327520..42bc2386bb 100644
--- a/accessible/windows/msaa/Compatibility.cpp
+++ b/accessible/windows/msaa/Compatibility.cpp
@@ -103,7 +103,7 @@ void Compatibility::Init() {
// Note we collect some AT statistics/telemetry here for convenience.
InitConsumers();
- CrashReporter::AnnotateCrashReport(
+ CrashReporter::RecordAnnotationNSCString(
CrashReporter::Annotation::AccessibilityInProcClient,
nsPrintfCString("0x%X", sConsumers));
@@ -142,9 +142,20 @@ void Compatibility::GetHumanReadableConsumersStr(nsAString& aResult) {
}
}
-// Time when SuppressA11yForClipboardCopy() was called, as returned by
-// ::GetTickCount().
-static DWORD sA11yClipboardCopySuppressionStartTime = 0;
+struct SuppressionTimer {
+ constexpr SuppressionTimer() = default;
+ void Start() { mStart = ::GetTickCount(); }
+ bool IsActive(DWORD aTickCount) const {
+ return mStart && aTickCount - mStart < kSuppressTimeout;
+ }
+ // Last time Start() was called, as returned by ::GetTickCount().
+ DWORD mStart = 0;
+
+ static constexpr DWORD kSuppressTimeout = 1500; // ms
+};
+
+static SuppressionTimer sClipboardSuppressionTimer;
+static SuppressionTimer sSnapLayoutsSuppressionTimer;
/* static */
void Compatibility::SuppressA11yForClipboardCopy() {
@@ -166,16 +177,40 @@ void Compatibility::SuppressA11yForClipboardCopy() {
}();
if (doSuppress) {
- sA11yClipboardCopySuppressionStartTime = ::GetTickCount();
+ sClipboardSuppressionTimer.Start();
}
}
/* static */
-bool Compatibility::IsA11ySuppressedForClipboardCopy() {
- constexpr DWORD kSuppressTimeout = 1500; // ms
- if (!sA11yClipboardCopySuppressionStartTime) {
- return false;
+void Compatibility::SuppressA11yForSnapLayouts() {
+ // Bug 1883132: Snap Layouts might enable a11y to find the maximize button
+ // position.
+ bool doSuppress = [&] {
+ switch (StaticPrefs::accessibility_windows_suppress_for_snap_layout()) {
+ case 0:
+ return false;
+ case 1:
+ return true;
+ default:
+ // Our workaround for Snap Layouts is needed from Windows 11 22H2
+ return IsWin1122H2OrLater();
+ }
+ }();
+
+ if (doSuppress) {
+ sSnapLayoutsSuppressionTimer.Start();
+ }
+}
+
+/* static */
+SuppressionReasons Compatibility::A11ySuppressionReasons() {
+ const auto now = ::GetTickCount();
+ auto reasons = SuppressionReasons::None;
+ if (sClipboardSuppressionTimer.IsActive(now)) {
+ reasons |= SuppressionReasons::Clipboard;
+ }
+ if (sSnapLayoutsSuppressionTimer.IsActive(now)) {
+ reasons |= SuppressionReasons::SnapLayouts;
}
- return ::GetTickCount() - sA11yClipboardCopySuppressionStartTime <
- kSuppressTimeout;
+ return reasons;
}