2 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #import "MOXMathAccessibles.h"
12 using namespace mozilla::a11y;
14 // XXX WebKit also defines the following attributes.
15 // See bugs 1176970 and 1176983.
16 // - NSAccessibilityMathFencedOpenAttribute @"AXMathFencedOpen"
17 // - NSAccessibilityMathFencedCloseAttribute @"AXMathFencedClose"
18 // - NSAccessibilityMathPrescriptsAttribute @"AXMathPrescripts"
19 // - NSAccessibilityMathPostscriptsAttribute @"AXMathPostscripts"
21 @implementation MOXMathRootAccessible
23 - (id)moxMathRootRadicand {
24 return [self childAt:0];
27 - (id)moxMathRootIndex {
28 return [self childAt:1];
33 @implementation MOXMathSquareRootAccessible
35 - (id)moxMathRootRadicand {
36 return [self childAt:0];
41 @implementation MOXMathFractionAccessible
43 - (id)moxMathFractionNumerator {
44 return [self childAt:0];
47 - (id)moxMathFractionDenominator {
48 return [self childAt:1];
51 // Bug 1639745: This doesn't actually work.
52 - (NSNumber*)moxMathLineThickness {
53 // WebKit sets line thickness to some logical value parsed in the
54 // renderer object of the <mfrac> element. It's not clear whether the
55 // exact value is relevant to assistive technologies. From a semantic
56 // point of view, the only important point is to distinguish between
57 // <mfrac> elements that have a fraction bar and those that do not.
58 // Per the MathML 3 spec, the latter happens iff the linethickness
59 // attribute is of the form [zero-float][optional-unit]. In that case we
60 // set line thickness to zero and in the other cases we set it to one.
61 if (NSString* thickness =
62 utils::GetAccAttr(self, nsGkAtoms::linethickness_)) {
63 NSNumberFormatter* formatter =
64 [[[NSNumberFormatter alloc] init] autorelease];
65 NSNumber* value = [formatter numberFromString:thickness];
66 return [NSNumber numberWithBool:[value boolValue]];
68 return [NSNumber numberWithInteger:0];
74 @implementation MOXMathSubSupAccessible
76 return [self childAt:0];
79 - (id)moxMathSubscript {
80 if (mRole == roles::MATHML_SUP) {
84 return [self childAt:1];
87 - (id)moxMathSuperscript {
88 if (mRole == roles::MATHML_SUB) {
92 return [self childAt:mRole == roles::MATHML_SUP ? 1 : 2];
97 @implementation MOXMathUnderOverAccessible
99 return [self childAt:0];
103 if (mRole == roles::MATHML_OVER) {
107 return [self childAt:1];
111 if (mRole == roles::MATHML_UNDER) {
115 return [self childAt:mRole == roles::MATHML_OVER ? 1 : 2];