Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduces a speechgenerator pool #1040

Merged
merged 26 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6c6b564
Adds rule, style cycling and summary computation.
zorkow Sep 14, 2023
c9b3f1d
Adds blurring.
zorkow Sep 24, 2023
957be4d
Solution for tabbing problem and menu opening.
zorkow Sep 24, 2023
658b5ea
timeout removed, focusout does not work.
zorkow Sep 26, 2023
f21065e
Focus out does work.
zorkow Sep 26, 2023
2d275a7
Improves click behaviour.
zorkow Sep 26, 2023
5b12a44
Removes superfluous stop.
zorkow Sep 27, 2023
1161697
fixes the incorrect braille components
zorkow Dec 6, 2023
487ff21
Moves speech related modules into dedicated subfolder.
zorkow Dec 8, 2023
4de62f2
adding a speech generator pool.
zorkow Dec 8, 2023
aa9f202
correct speech output in subtitle
zorkow Dec 8, 2023
74c3edd
generalise label computation
zorkow Dec 9, 2023
ddfbbce
Moves region update to generator pool.
zorkow Dec 19, 2023
79abb5d
Reinstantiate aria-label in cleanup
zorkow Dec 20, 2023
2a3aee4
Moving more functionality into the generator pool class.
zorkow Dec 20, 2023
dab2197
Cleanup to toggle
zorkow Jan 10, 2024
d56df31
Changes Engine default import
zorkow Jan 11, 2024
8454602
Corrects locale change
zorkow Jan 11, 2024
e0114c3
Refactor speech generation to generator pool, ensure compatibility wi…
zorkow Jan 14, 2024
680ac0e
Simplify types, cleanup and commenting.
zorkow Jan 15, 2024
548ad45
Corrects smart clearspeak preference menu.
zorkow Jan 15, 2024
10065ea
Cleanup and missing comments.
zorkow Jan 15, 2024
c00b03c
Fixes the refocusing on elements after collapse.
zorkow Jan 15, 2024
b74ccd1
Ensure use of adaptors for node access throughout speech generation.
zorkow Jan 18, 2024
7524905
Incorporates review suggestions.
zorkow Feb 7, 2024
17c4e8d
Incorporates review suggestions.
zorkow Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ts/a11y/complexity/collapse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ export class Collapse {

const attributes = node.attributes.getAllAttributes();
for (const name of Object.keys(attributes)) {
if (name.substring(0, 14) === 'data-semantic-') {
if (name.substring(0, 14) === 'data-semantic-' ||
name.substring(0, 5) === 'aria-' ||
name === 'role') {
mrow.attributes.set(name, attributes[name]);
delete attributes[name];
}
Expand Down
26 changes: 11 additions & 15 deletions ts/a11y/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,9 @@ export function ExplorerMathItemMixin<B extends Constructor<HTMLMATHITEM>>(
public explorers: ExplorerPool;

/**
* True when a rerendered element should regain the focus
* Semantic id of the rerendered element that should regain the focus.
*/
protected refocus: boolean = false;

/**
* Save explorer id during rerendering.
*/
protected savedId: string = null;
protected refocus: number = null;

/**
* Add the explorer to the output for this math item
Expand All @@ -116,10 +111,6 @@ export function ExplorerMathItemMixin<B extends Constructor<HTMLMATHITEM>>(
if (!this.isEscaped && (document.options.enableExplorer || force)) {
const node = this.typesetRoot;
const mml = toMathML(this.root);
if (this.savedId) {
this.typesetRoot.setAttribute('sre-explorer-id', this.savedId);
this.savedId = null;
}
if (!this.explorers) {
this.explorers = new ExplorerPool();
}
Expand All @@ -132,9 +123,12 @@ export function ExplorerMathItemMixin<B extends Constructor<HTMLMATHITEM>>(
* @override
*/
public rerender(document: ExplorerMathDocument, start: number = STATE.RERENDER) {
this.savedId = this.typesetRoot.getAttribute('sre-explorer-id');
this.refocus = (hasWindow ? window.document.activeElement === this.typesetRoot : false);
if (this.explorers) {
let speech = this.explorers.speech;
if (speech && speech.attached && speech.active) {
const focus = speech.semanticFocus();
this.refocus = focus ? focus.id : null;
}
this.explorers.reattach();
}
super.rerender(document, start);
Expand All @@ -145,11 +139,13 @@ export function ExplorerMathItemMixin<B extends Constructor<HTMLMATHITEM>>(
*/
public updateDocument(document: ExplorerMathDocument) {
super.updateDocument(document);
this.refocus && this.typesetRoot.focus();
if (this.explorers?.speech) {
this.explorers.speech.restarted = this.refocus;
}
this.refocus = null;
if (this.explorers) {
this.explorers.restart();
}
this.refocus = false;
}

};
Expand Down
24 changes: 18 additions & 6 deletions ts/a11y/explorer/ExplorerPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {LiveRegion, SpeechRegion, ToolTip, HoverRegion} from './Region.js';
import type { ExplorerMathDocument, ExplorerMathItem } from '../explorer.js';

import {Explorer} from './Explorer.js';
import * as ke from './KeyExplorer.js';
import {SpeechExplorer} from './KeyExplorer.js';
import * as me from './MouseExplorer.js';
import {TreeColorer, FlameColorer} from './TreeExplorer.js';

Expand Down Expand Up @@ -87,9 +87,9 @@ type ExplorerInit = (doc: ExplorerMathDocument, pool: ExplorerPool,
*/
let allExplorers: {[options: string]: ExplorerInit} = {
speech: (doc: ExplorerMathDocument, pool: ExplorerPool, node: HTMLElement, ...rest: any[]) => {
let explorer = ke.SpeechExplorer.create(
let explorer = SpeechExplorer.create(
doc, pool, doc.explorerRegions.speechRegion, node,
doc.explorerRegions.brailleRegion, doc.explorerRegions.magnifier, rest[0], rest[1]) as ke.SpeechExplorer;
doc.explorerRegions.brailleRegion, doc.explorerRegions.magnifier, rest[0], rest[1]) as SpeechExplorer;
explorer.sound = true;
return explorer;
},
Expand Down Expand Up @@ -213,7 +213,7 @@ export class ExplorerPool {
let keyExplorers = [];
for (let key of Object.keys(this.explorers)) {
let explorer = this.explorers[key];
if (explorer instanceof ke.SpeechExplorer) {
if (explorer instanceof SpeechExplorer) {
explorer.AddEvents();
explorer.stoppable = false;
keyExplorers.unshift(explorer);
Expand Down Expand Up @@ -253,7 +253,9 @@ export class ExplorerPool {
* Restarts explorers after a MathItem is rerendered.
*/
public restart() {
this._restart.forEach(x => this.explorers[x].Start());
this._restart.forEach(x => {
this.explorers[x].Start();
});
this._restart = [];
}

Expand All @@ -275,7 +277,7 @@ export class ExplorerPool {
{color: 'red'}, {color: 'black'},
{renderer: this.document.outputJax.name, browser: 'v3'}
);
((this.explorers['speech'] as ke.SpeechExplorer).region as SpeechRegion).highlighter =
(this.speech.region as SpeechRegion).highlighter =
this.secondaryHighlighter;
}

Expand All @@ -295,6 +297,16 @@ export class ExplorerPool {
this.highlighter.unhighlight();
}

/**
* Convenience method to return the speech explorer of the pool with the
* correct type.
*
* @return {SpeechExplorer}
*/
public get speech(): SpeechExplorer {
return this.explorers['speech'] as SpeechExplorer;
}

/**
* Retrieves color assignment for the document options.
*
Expand Down
Loading