Commit 9ad99052 authored by Yura Zenevich's avatar Yura Zenevich
Browse files

Bug 1598026 - separate listening for accessibility lifecycle events between...

Bug 1598026 - separate listening for accessibility lifecycle events between parent and content. r=mtigley

Differential Revision: https://phabricator.services.mozilla.com/D77466
parent 98c96155
......@@ -11,11 +11,6 @@ const {
} = require("devtools/shared/constants");
const { FILTERS } = require("devtools/client/accessibility/constants");
const PARENT_ACCESSIBILITY_EVENTS = [
"can-be-disabled-change",
"can-be-enabled-change",
];
/**
* Component responsible for tracking all Accessibility fronts in parent and
* content processes.
......@@ -39,12 +34,18 @@ class AccessibilityProxy {
this.startListeningForLifecycleEvents = this.startListeningForLifecycleEvents.bind(
this
);
this.startListeningForParentLifecycleEvents = this.startListeningForParentLifecycleEvents.bind(
this
);
this.stopListeningForAccessibilityEvents = this.stopListeningForAccessibilityEvents.bind(
this
);
this.stopListeningForLifecycleEvents = this.stopListeningForLifecycleEvents.bind(
this
);
this.stopListeningForParentLifecycleEvents = this.stopListeningForParentLifecycleEvents.bind(
this
);
this.highlightAccessible = this.highlightAccessible.bind(this);
this.unhighlightAccessible = this.unhighlightAccessible.bind(this);
this._onTargetAvailable = this._onTargetAvailable.bind(this);
......@@ -189,19 +190,25 @@ class AccessibilityProxy {
startListeningForLifecycleEvents(eventMap) {
for (const [type, listeners] of Object.entries(eventMap)) {
const accessibilityFront = PARENT_ACCESSIBILITY_EVENTS.includes(type)
? this.parentAccessibilityFront
: this.accessibilityFront;
this._on(accessibilityFront, type, listeners);
this._on(this.accessibilityFront, type, listeners);
}
}
stopListeningForLifecycleEvents(eventMap) {
for (const [type, listeners] of Object.entries(eventMap)) {
const accessibilityFront = PARENT_ACCESSIBILITY_EVENTS.includes(type)
? this.parentAccessibilityFront
: this.accessibilityFront;
this._off(accessibilityFront, type, listeners);
this._off(this.accessibilityFront, type, listeners);
}
}
startListeningForParentLifecycleEvents(eventMap) {
for (const [type, listener] of Object.entries(eventMap)) {
this.parentAccessibilityFront.on(type, listener);
}
}
stopListeningForParentLifecycleEvents(eventMap) {
for (const [type, listener] of Object.entries(eventMap)) {
this.parentAccessibilityFront.off(type, listener);
}
}
......@@ -253,9 +260,13 @@ class AccessibilityProxy {
async initializeProxyForPanel(targetFront) {
await this._updateTarget(targetFront);
this.parentAccessibilityFront = await this._currentTarget.client.mainRoot.getFront(
"parentaccessibility"
);
// No need to retrieve parent accessibility front since root front does not
// change.
if (!this.parentAccessibilityFront) {
this.parentAccessibilityFront = await this._currentTarget.client.mainRoot.getFront(
"parentaccessibility"
);
}
this.accessibleWalkerFront = this.accessibilityFront.accessibleWalkerFront;
this.simulatorFront = this.accessibilityFront.simulatorFront;
......@@ -265,11 +276,8 @@ class AccessibilityProxy {
// Move front listeners to new front.
for (const [type, listeners] of this.accessibilityEventsMap.entries()) {
const accessibilityFront = PARENT_ACCESSIBILITY_EVENTS.includes(type)
? this.parentAccessibilityFront
: this.accessibilityFront;
for (const listener of listeners) {
accessibilityFront.on(type, listener);
this.accessibilityFront.on(type, listener);
}
}
......
......@@ -51,51 +51,59 @@ AccessibilityView.prototype = {
*
* @param {Object}
* Object that contains the following properties:
* - supports {JSON}
* a collection of flags indicating
* which accessibility panel features
* are supported by the current
* serverside version.
* - fluentBundles {Array}
* array of FluentBundles elements for
* localization
* - toolbox {Object}
* devtools toolbox.
* - getAccessibilityTreeRoot {Function}
* Returns the topmost accessibiliity
* walker that is used as the root of
* the accessibility tree.
* - startListeningForAccessibilityEvents {Function}
* Add listeners for specific
* accessibility events.
* - stopListeningForAccessibilityEvents {Function}
* Remove listeners for specific
* accessibility events.
* - audit {Function}
* Audit function that will start
* accessibility audit for given types
* of accessibility issues.
* - simulate {null|Function}
* Apply simulation of a given type
* (by setting color matrices in
* docShell).
* - enableAccessibility {Function}
* Enable accessibility services.
* - disableAccessibility {Function}
* Disable accessibility services.
* - resetAccessiblity {Function}
* Reset the state of the
* accessibility services.
* - startListeningForLifecycleEvents {Function}
* Add listeners for accessibility
* service lifecycle events.
* - stopListeningForLifecycleEvents {Function}
* Remove listeners for accessibility
* service lifecycle events.
* - highlightAccessible {Function}
* Highlight accessible object.
* - unhighlightAccessible {Function}
* Unhighlight accessible object.
* - supports {JSON}
* a collection of flags indicating
* which accessibility panel features
* are supported by the current
* serverside version.
* - fluentBundles {Array}
* array of FluentBundles elements
* for localization
* - toolbox {Object}
* devtools toolbox.
* - getAccessibilityTreeRoot {Function}
* Returns the topmost accessibiliity
* walker that is used as the root of
* the accessibility tree.
* - startListeningForAccessibilityEvents {Function}
* Add listeners for specific
* accessibility events.
* - stopListeningForAccessibilityEvents {Function}
* Remove listeners for specific
* accessibility events.
* - audit {Function}
* Audit function that will start
* accessibility audit for given types
* of accessibility issues.
* - simulate {null|Function}
* Apply simulation of a given type
* (by setting color matrices in
* docShell).
* - enableAccessibility {Function}
* Enable accessibility services.
* - disableAccessibility {Function}
* Disable accessibility services.
* - resetAccessiblity {Function}
* Reset the state of the
* accessibility services.
* - startListeningForLifecycleEvents {Function}
* Add listeners for accessibility
* service lifecycle events.
* - stopListeningForLifecycleEvents {Function}
* Remove listeners for accessibility
* service lifecycle events.
* - startListeningForParentLifecycleEvents {Function}
* Add listeners for parent process
* accessibility service lifecycle
* events.
* - stopListeningForParentLifecycleEvents {Function}
* Remove listeners for parent
* process accessibility service
* lifecycle events.
* - highlightAccessible {Function}
* Highlight accessible object.
* - unhighlightAccessible {Function}
* Unhighlight accessible object.
*/
async initialize({
supports,
......@@ -111,6 +119,8 @@ AccessibilityView.prototype = {
resetAccessiblity,
startListeningForLifecycleEvents,
stopListeningForLifecycleEvents,
startListeningForParentLifecycleEvents,
stopListeningForParentLifecycleEvents,
highlightAccessible,
unhighlightAccessible,
}) {
......@@ -130,6 +140,8 @@ AccessibilityView.prototype = {
resetAccessiblity,
startListeningForLifecycleEvents,
stopListeningForLifecycleEvents,
startListeningForParentLifecycleEvents,
stopListeningForParentLifecycleEvents,
highlightAccessible,
unhighlightAccessible,
});
......
......@@ -74,6 +74,8 @@ class MainFrame extends Component {
resetAccessiblity: PropTypes.func.isRequired,
startListeningForLifecycleEvents: PropTypes.func.isRequired,
stopListeningForLifecycleEvents: PropTypes.func.isRequired,
startListeningForParentLifecycleEvents: PropTypes.func.isRequired,
stopListeningForParentLifecycleEvents: PropTypes.func.isRequired,
highlightAccessible: PropTypes.func.isRequired,
unhighlightAccessible: PropTypes.func.isRequired,
};
......@@ -92,6 +94,8 @@ class MainFrame extends Component {
this.props.startListeningForLifecycleEvents({
init: this.resetAccessibility,
shutdown: this.resetAccessibility,
});
this.props.startListeningForParentLifecycleEvents({
"can-be-enabled-change": this.onCanBeEnabledChange,
"can-be-disabled-change": this.onCanBeDisabledChange,
});
......@@ -111,6 +115,8 @@ class MainFrame extends Component {
this.props.stopListeningForLifecycleEvents({
init: this.resetAccessibility,
shutdown: this.resetAccessibility,
});
this.props.stopListeningForParentLifecycleEvents({
"can-be-enabled-change": this.onCanBeEnabledChange,
"can-be-disabled-change": this.onCanBeDisabledChange,
});
......
......@@ -194,27 +194,41 @@ AccessibilityPanel.prototype = {
}
// Alright reset the flag we are about to refresh the panel.
this.shouldRefresh = false;
const {
supports,
getAccessibilityTreeRoot,
startListeningForAccessibilityEvents,
stopListeningForAccessibilityEvents,
audit,
simulate,
enableAccessibility,
disableAccessibility,
resetAccessiblity,
startListeningForLifecycleEvents,
stopListeningForLifecycleEvents,
startListeningForParentLifecycleEvents,
stopListeningForParentLifecycleEvents,
highlightAccessible,
unhighlightAccessible,
} = this.accessibilityProxy;
this.postContentMessage("initialize", {
supports: this.accessibilityProxy.supports,
fluentBundles: this.fluentBundles,
toolbox: this._toolbox,
getAccessibilityTreeRoot: this.accessibilityProxy
.getAccessibilityTreeRoot,
startListeningForAccessibilityEvents: this.accessibilityProxy
.startListeningForAccessibilityEvents,
stopListeningForAccessibilityEvents: this.accessibilityProxy
.stopListeningForAccessibilityEvents,
audit: this.accessibilityProxy.audit,
simulate: this.accessibilityProxy.simulate,
enableAccessibility: this.accessibilityProxy.enableAccessibility,
disableAccessibility: this.accessibilityProxy.disableAccessibility,
resetAccessiblity: this.accessibilityProxy.resetAccessiblity,
startListeningForLifecycleEvents: this.accessibilityProxy
.startListeningForLifecycleEvents,
stopListeningForLifecycleEvents: this.accessibilityProxy
.stopListeningForLifecycleEvents,
highlightAccessible: this.accessibilityProxy.highlightAccessible,
unhighlightAccessible: this.accessibilityProxy.unhighlightAccessible,
supports,
getAccessibilityTreeRoot,
startListeningForAccessibilityEvents,
stopListeningForAccessibilityEvents,
audit,
simulate,
enableAccessibility,
disableAccessibility,
resetAccessiblity,
startListeningForLifecycleEvents,
stopListeningForLifecycleEvents,
startListeningForParentLifecycleEvents,
stopListeningForParentLifecycleEvents,
highlightAccessible,
unhighlightAccessible,
});
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment