diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /accessible/mac/MOXMathAccessibles.mm | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/mac/MOXMathAccessibles.mm')
-rw-r--r-- | accessible/mac/MOXMathAccessibles.mm | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/accessible/mac/MOXMathAccessibles.mm b/accessible/mac/MOXMathAccessibles.mm new file mode 100644 index 0000000000..7bfe2e3e05 --- /dev/null +++ b/accessible/mac/MOXMathAccessibles.mm @@ -0,0 +1,117 @@ +/* clang-format off */ +/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* clang-format on */ +/* 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/. */ + +#import "MOXMathAccessibles.h" + +#import "MacUtils.h" + +using namespace mozilla::a11y; + +// XXX WebKit also defines the following attributes. +// See bugs 1176970 and 1176983. +// - NSAccessibilityMathFencedOpenAttribute @"AXMathFencedOpen" +// - NSAccessibilityMathFencedCloseAttribute @"AXMathFencedClose" +// - NSAccessibilityMathPrescriptsAttribute @"AXMathPrescripts" +// - NSAccessibilityMathPostscriptsAttribute @"AXMathPostscripts" + +@implementation MOXMathRootAccessible + +- (id)moxMathRootRadicand { + return [self childAt:0]; +} + +- (id)moxMathRootIndex { + return [self childAt:1]; +} + +@end + +@implementation MOXMathSquareRootAccessible + +- (id)moxMathRootRadicand { + return [self childAt:0]; +} + +@end + +@implementation MOXMathFractionAccessible + +- (id)moxMathFractionNumerator { + return [self childAt:0]; +} + +- (id)moxMathFractionDenominator { + return [self childAt:1]; +} + +// Bug 1639745: This doesn't actually work. +- (NSNumber*)moxMathLineThickness { + // WebKit sets line thickness to some logical value parsed in the + // renderer object of the <mfrac> element. It's not clear whether the + // exact value is relevant to assistive technologies. From a semantic + // point of view, the only important point is to distinguish between + // <mfrac> elements that have a fraction bar and those that do not. + // Per the MathML 3 spec, the latter happens iff the linethickness + // attribute is of the form [zero-float][optional-unit]. In that case we + // set line thickness to zero and in the other cases we set it to one. + if (NSString* thickness = + utils::GetAccAttr(self, nsGkAtoms::linethickness_)) { + NSNumberFormatter* formatter = + [[[NSNumberFormatter alloc] init] autorelease]; + NSNumber* value = [formatter numberFromString:thickness]; + return [NSNumber numberWithBool:[value boolValue]]; + } else { + return [NSNumber numberWithInteger:0]; + } +} + +@end + +@implementation MOXMathSubSupAccessible +- (id)moxMathBase { + return [self childAt:0]; +} + +- (id)moxMathSubscript { + if (mRole == roles::MATHML_SUP) { + return nil; + } + + return [self childAt:1]; +} + +- (id)moxMathSuperscript { + if (mRole == roles::MATHML_SUB) { + return nil; + } + + return [self childAt:mRole == roles::MATHML_SUP ? 1 : 2]; +} + +@end + +@implementation MOXMathUnderOverAccessible +- (id)moxMathBase { + return [self childAt:0]; +} + +- (id)moxMathUnder { + if (mRole == roles::MATHML_OVER) { + return nil; + } + + return [self childAt:1]; +} + +- (id)moxMathOver { + if (mRole == roles::MATHML_UNDER) { + return nil; + } + + return [self childAt:mRole == roles::MATHML_OVER ? 1 : 2]; +} +@end |