OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview A class for walking mathml expressions. | 6 * @fileoverview A class for walking mathml expressions. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('cvox.MathShifter'); | 9 goog.provide('cvox.MathShifter'); |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 */ | 41 */ |
42 this.direction_ = false; | 42 this.direction_ = false; |
43 | 43 |
44 /** | 44 /** |
45 * Indicates whether or not we've bumped against an edge in the math | 45 * Indicates whether or not we've bumped against an edge in the math |
46 * structure. | 46 * structure. |
47 * @private | 47 * @private |
48 */ | 48 */ |
49 this.bumped_ = false; | 49 this.bumped_ = false; |
50 | 50 |
51 cvox.TraverseMath.getInstance().initialize(sel.start.node); | 51 cvox.TraverseMath.getInstance().initialize(sel.start.node); |
52 }; | 52 }; |
53 goog.inherits(cvox.MathShifter, cvox.AbstractShifter); | 53 goog.inherits(cvox.MathShifter, cvox.AbstractShifter); |
54 | 54 |
55 | 55 |
56 /** | 56 /** |
57 * @override | 57 * @override |
58 */ | 58 */ |
59 cvox.MathShifter.prototype.next = function(sel) { | 59 cvox.MathShifter.prototype.next = function(sel) { |
60 // Delegate to TraverseMath which manages selection inside of the math tree. | 60 // Delegate to TraverseMath which manages selection inside of the math tree. |
61 var r = sel.isReversed(); | 61 var r = sel.isReversed(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 text: cvox.BrailleUtil.getTemplated(prevSel.start.node, sel.start.node) | 103 text: cvox.BrailleUtil.getTemplated(prevSel.start.node, sel.start.node) |
104 }); | 104 }); |
105 }; | 105 }; |
106 | 106 |
107 | 107 |
108 /** | 108 /** |
109 * @override | 109 * @override |
110 */ | 110 */ |
111 cvox.MathShifter.prototype.getGranularityMsg = function() { | 111 cvox.MathShifter.prototype.getGranularityMsg = function() { |
112 return this.direction_ ? 'up to level ' + this.level_ : | 112 return this.direction_ ? 'up to level ' + this.level_ : |
113 'down to level ' + this.level_; | 113 'down to level ' + this.level_; |
114 }; | 114 }; |
115 | 115 |
116 | 116 |
117 /** | 117 /** |
118 * @override | 118 * @override |
119 */ | 119 */ |
120 cvox.MathShifter.prototype.makeLessGranular = function() { | 120 cvox.MathShifter.prototype.makeLessGranular = function() { |
121 this.level_ = this.level_ > 0 ? this.level_ - 1 : 0; | 121 this.level_ = this.level_ > 0 ? this.level_ - 1 : 0; |
122 this.direction_ = true; | 122 this.direction_ = true; |
123 this.bumped_ = !cvox.TraverseMath.getInstance().nextParentChild(true); | 123 this.bumped_ = !cvox.TraverseMath.getInstance().nextParentChild(true); |
(...skipping 10 matching lines...) Expand all Loading... |
134 this.level_++; | 134 this.level_++; |
135 } | 135 } |
136 }; | 136 }; |
137 | 137 |
138 | 138 |
139 /** | 139 /** |
140 * @override | 140 * @override |
141 */ | 141 */ |
142 cvox.MathShifter.create = function(sel) { | 142 cvox.MathShifter.create = function(sel) { |
143 if (cvox.DomPredicates.mathPredicate( | 143 if (cvox.DomPredicates.mathPredicate( |
144 cvox.DomUtil.getAncestors(sel.start.node))) { | 144 cvox.DomUtil.getAncestors(sel.start.node))) { |
145 var mathNode = cvox.DomUtil.getContainingMath(sel.end.node); | 145 var mathNode = cvox.DomUtil.getContainingMath(sel.end.node); |
146 cvox.TraverseMath.getInstance().initialize(mathNode); | 146 cvox.TraverseMath.getInstance().initialize(mathNode); |
147 cvox.SpeechRuleEngine.getInstance().parameterize( | 147 cvox.SpeechRuleEngine.getInstance().parameterize( |
148 cvox.MathmlStore.getInstance()); | 148 cvox.MathmlStore.getInstance()); |
149 // TODO (sorge) Embed these changes into a local context menu/options menu. | 149 // TODO (sorge) Embed these changes into a local context menu/options menu. |
150 var dynamicCstr = cvox.MathStore.createDynamicConstraint( | 150 var dynamicCstr = cvox.MathStore.createDynamicConstraint( |
151 cvox.TraverseMath.getInstance().domain, | 151 cvox.TraverseMath.getInstance().domain, |
152 cvox.TraverseMath.getInstance().style); | 152 cvox.TraverseMath.getInstance().style); |
153 cvox.SpeechRuleEngine.getInstance().setDynamicConstraint(dynamicCstr); | 153 cvox.SpeechRuleEngine.getInstance().setDynamicConstraint(dynamicCstr); |
154 return new cvox.MathShifter(sel); | 154 return new cvox.MathShifter(sel); |
155 } | 155 } |
156 return null; | 156 return null; |
157 }; | 157 }; |
158 | 158 |
159 | 159 |
160 /** | 160 /** |
161 * The active domain of the MathShifter. | 161 * The active domain of the MathShifter. |
162 * | 162 * |
163 * @return {string} The name of the current Math Domain. | 163 * @return {string} The name of the current Math Domain. |
164 */ | 164 */ |
165 cvox.MathShifter.prototype.getDomainMsg = function() { | 165 cvox.MathShifter.prototype.getDomainMsg = function() { |
166 return cvox.TraverseMath.getInstance().domain; | 166 return cvox.TraverseMath.getInstance().domain; |
167 }; | 167 }; |
OLD | NEW |