no bug - Correct some typos in the comments. a=typo-fix
[gecko.git] / accessible / mac / MOXMathAccessibles.mm
blob7bfe2e3e05a03cff48fed3f034752e0d7043e06f
1 /* clang-format off */
2 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 /* clang-format on */
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"
10 #import "MacUtils.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];
31 @end
33 @implementation MOXMathSquareRootAccessible
35 - (id)moxMathRootRadicand {
36   return [self childAt:0];
39 @end
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]];
67   } else {
68     return [NSNumber numberWithInteger:0];
69   }
72 @end
74 @implementation MOXMathSubSupAccessible
75 - (id)moxMathBase {
76   return [self childAt:0];
79 - (id)moxMathSubscript {
80   if (mRole == roles::MATHML_SUP) {
81     return nil;
82   }
84   return [self childAt:1];
87 - (id)moxMathSuperscript {
88   if (mRole == roles::MATHML_SUB) {
89     return nil;
90   }
92   return [self childAt:mRole == roles::MATHML_SUP ? 1 : 2];
95 @end
97 @implementation MOXMathUnderOverAccessible
98 - (id)moxMathBase {
99   return [self childAt:0];
102 - (id)moxMathUnder {
103   if (mRole == roles::MATHML_OVER) {
104     return nil;
105   }
107   return [self childAt:1];
110 - (id)moxMathOver {
111   if (mRole == roles::MATHML_UNDER) {
112     return nil;
113   }
115   return [self childAt:mRole == roles::MATHML_OVER ? 1 : 2];
117 @end