@@ -19,7 +19,7 @@ import {mathjax} from '../../mathjax.js';
1919import { Sre } from '../sre.js' ;
2020import { OptionList } from '../../util/Options.js' ;
2121import { LiveRegion } from '../explorer/Region.js' ;
22- import { buildLabel , buildSpeech } from '../speech/SpeechUtil.js' ;
22+ import { buildLabel , buildSpeech , InPlace } from '../speech/SpeechUtil.js' ;
2323import { DOMAdaptor } from '../../core/DOMAdaptor.js' ;
2424
2525/**
@@ -177,7 +177,7 @@ export class GeneratorPool<N, T, D> {
177177 * @param {N } node The typeset node.
178178 */
179179 public summary ( node : N ) {
180- if ( this . lastSummary ) {
180+ if ( this . lastMove === InPlace . SUMMARY ) {
181181 this . CleanUp ( node ) ;
182182 return this . lastSpeech ;
183183 }
@@ -193,11 +193,11 @@ export class GeneratorPool<N, T, D> {
193193 * @param {N } node
194194 */
195195 public CleanUp ( node : N ) {
196- if ( this . lastSummary ) {
196+ if ( this . lastMove ) {
197197 // TODO: Remember the speech.
198198 this . adaptor . setAttribute ( node , 'aria-label' , buildSpeech ( this . getLabel ( node ) ) [ 0 ] ) ;
199199 }
200- this . lastSummary = false ;
200+ this . lastMove = InPlace . NONE ;
201201 }
202202
203203 /**
@@ -206,9 +206,24 @@ export class GeneratorPool<N, T, D> {
206206 private lastSpeech = '' ;
207207
208208 /**
209- * Remembers that the last speech computation was a summary.
209+ * Remembers whether the last speech computation was in-place, i.e., a summary
210+ * or depth computation.
210211 */
211- private lastSummary = false ;
212+ private lastMove_ = InPlace . NONE ;
213+
214+ /**
215+ * Getter for last move.
216+ */
217+ public get lastMove ( ) {
218+ return this . lastMove_ ;
219+ }
220+
221+ /**
222+ * Setter for last move.
223+ */
224+ public set lastMove ( move : InPlace ) {
225+ this . lastMove_ = this . lastSpeech ? move : InPlace . NONE ;
226+ }
212227
213228 /**
214229 * Updates the given speech regions, possibly reinstanting previously saved
@@ -225,11 +240,7 @@ export class GeneratorPool<N, T, D> {
225240 ) {
226241 let speech = this . getLabel ( node , this . lastSpeech ) ;
227242 speechRegion . Update ( speech ) ;
228- // TODO: See if we can reuse the speech from the speech region.
229243 this . adaptor . setAttribute ( node , 'aria-label' , buildSpeech ( speech ) [ 0 ] ) ;
230- if ( this . lastSpeech ) {
231- this . lastSummary = true ;
232- }
233244 this . lastSpeech = '' ;
234245 brailleRegion . Update (
235246 this . adaptor . getAttribute ( node , 'aria-braillelabel' ) ) ;
@@ -379,7 +390,7 @@ export class GeneratorPool<N, T, D> {
379390 }
380391
381392 public depth ( node : N , actionable : boolean ) {
382- if ( this . lastSummary ) {
393+ if ( this . lastMove === InPlace . DEPTH ) {
383394 this . CleanUp ( node ) ;
384395 return this . lastSpeech ;
385396 }
0 commit comments