зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1602075 - make enable/disable panel UI conditional on the accessibility-panel-auto-init feature. r=mtigley
Differential Revision: https://phabricator.services.mozilla.com/D71584
This commit is contained in:
Родитель
e4233d8a2e
Коммит
5b77e1ed09
|
@ -56,6 +56,16 @@ class AccessibilityProxy {
|
|||
return this.accessibilityFront && this.accessibilityFront.enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the accessibility service is enabled.
|
||||
*/
|
||||
get canBeEnabled() {
|
||||
// TODO: Just use parentAccessibilityFront after Firefox 75.
|
||||
const { canBeEnabled } =
|
||||
this.parentAccessibilityFront || this.accessibilityFront;
|
||||
return canBeEnabled;
|
||||
}
|
||||
|
||||
get currentTarget() {
|
||||
return this._currentTarget;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ class Description extends Component {
|
|||
canBeEnabled: PropTypes.bool,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
enableAccessibility: PropTypes.func.isRequired,
|
||||
autoInit: PropTypes.bool.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -71,20 +72,37 @@ class Description extends Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { canBeEnabled } = this.props;
|
||||
const { enabling } = this.state;
|
||||
const enableButtonStr = enabling
|
||||
? "accessibility.enabling"
|
||||
: "accessibility.enable";
|
||||
const { canBeEnabled, autoInit } = this.props;
|
||||
let warningStringName = "accessibility.enable.disabledTitle";
|
||||
let button;
|
||||
if (!autoInit) {
|
||||
const { enabling } = this.state;
|
||||
const enableButtonStr = enabling
|
||||
? "accessibility.enabling"
|
||||
: "accessibility.enable";
|
||||
|
||||
let title;
|
||||
let disableButton = false;
|
||||
let title;
|
||||
let disableButton = false;
|
||||
|
||||
if (canBeEnabled) {
|
||||
title = L10N.getStr("accessibility.enable.enabledTitle");
|
||||
} else {
|
||||
disableButton = true;
|
||||
title = L10N.getStr("accessibility.enable.disabledTitle");
|
||||
if (canBeEnabled) {
|
||||
title = L10N.getStr("accessibility.enable.enabledTitle");
|
||||
} else {
|
||||
disableButton = true;
|
||||
title = L10N.getStr("accessibility.enable.disabledTitle");
|
||||
}
|
||||
|
||||
button = Button(
|
||||
{
|
||||
id: "accessibility-enable-button",
|
||||
onClick: this.onEnable,
|
||||
disabled: enabling || disableButton,
|
||||
busy: enabling,
|
||||
"data-standalone": true,
|
||||
title,
|
||||
},
|
||||
L10N.getStr(enableButtonStr)
|
||||
);
|
||||
warningStringName = "accessibility.description.general.p2";
|
||||
}
|
||||
|
||||
return div(
|
||||
|
@ -105,26 +123,22 @@ class Description extends Component {
|
|||
l10n: L10N,
|
||||
messageStringKey: "accessibility.description.general.p1",
|
||||
}),
|
||||
p({}, L10N.getStr("accessibility.description.general.p2"))
|
||||
p({}, L10N.getStr(warningStringName))
|
||||
)
|
||||
),
|
||||
Button(
|
||||
{
|
||||
id: "accessibility-enable-button",
|
||||
onClick: this.onEnable,
|
||||
disabled: enabling || disableButton,
|
||||
busy: enabling,
|
||||
"data-standalone": true,
|
||||
title,
|
||||
},
|
||||
L10N.getStr(enableButtonStr)
|
||||
)
|
||||
button
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = ({ ui }) => ({
|
||||
canBeEnabled: ui.canBeEnabled,
|
||||
const mapStateToProps = ({
|
||||
ui: {
|
||||
canBeEnabled,
|
||||
supports: { autoInit },
|
||||
},
|
||||
}) => ({
|
||||
canBeEnabled,
|
||||
autoInit,
|
||||
});
|
||||
|
||||
// Exports from this module
|
||||
|
|
|
@ -15,6 +15,7 @@ const {
|
|||
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
|
||||
const { connect } = require("devtools/client/shared/vendor/react-redux");
|
||||
const {
|
||||
enable,
|
||||
reset,
|
||||
updateCanBeEnabled,
|
||||
updateCanBeDisabled,
|
||||
|
@ -123,7 +124,15 @@ class MainFrame extends Component {
|
|||
}
|
||||
|
||||
onCanBeEnabledChange(canBeEnabled) {
|
||||
this.props.dispatch(updateCanBeEnabled(canBeEnabled));
|
||||
const {
|
||||
enableAccessibility,
|
||||
dispatch,
|
||||
supports: { autoInit },
|
||||
} = this.props;
|
||||
dispatch(updateCanBeEnabled(canBeEnabled));
|
||||
if (canBeEnabled && autoInit) {
|
||||
dispatch(enable(enableAccessibility));
|
||||
}
|
||||
}
|
||||
|
||||
onCanBeDisabledChange(canBeDisabled) {
|
||||
|
|
|
@ -41,6 +41,7 @@ class Toolbar extends Component {
|
|||
toolboxDoc: PropTypes.object.isRequired,
|
||||
audit: PropTypes.func.isRequired,
|
||||
simulate: PropTypes.func,
|
||||
autoInit: PropTypes.bool.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -64,7 +65,7 @@ class Toolbar extends Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { canBeDisabled, simulate, toolboxDoc, audit } = this.props;
|
||||
const { canBeDisabled, simulate, toolboxDoc, audit, autoInit } = this.props;
|
||||
const { disabling } = this.state;
|
||||
const disableButtonStr = disabling
|
||||
? "accessibility.disabling"
|
||||
|
@ -95,21 +96,23 @@ class Toolbar extends Component {
|
|||
className: "devtools-toolbar",
|
||||
role: "toolbar",
|
||||
},
|
||||
Button(
|
||||
{
|
||||
className: "disable",
|
||||
id: "accessibility-disable-button",
|
||||
onClick: this.onDisable,
|
||||
disabled: disabling || isDisabled,
|
||||
busy: disabling,
|
||||
title,
|
||||
},
|
||||
L10N.getStr(disableButtonStr)
|
||||
),
|
||||
div({
|
||||
role: "separator",
|
||||
className: "devtools-separator",
|
||||
}),
|
||||
!autoInit &&
|
||||
Button(
|
||||
{
|
||||
className: "disable",
|
||||
id: "accessibility-disable-button",
|
||||
onClick: this.onDisable,
|
||||
disabled: disabling || isDisabled,
|
||||
busy: disabling,
|
||||
title,
|
||||
},
|
||||
L10N.getStr(disableButtonStr)
|
||||
),
|
||||
!autoInit &&
|
||||
div({
|
||||
role: "separator",
|
||||
className: "devtools-separator",
|
||||
}),
|
||||
// @remove after release 68 (See Bug 1551574)
|
||||
span(
|
||||
{
|
||||
|
@ -131,8 +134,14 @@ class Toolbar extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = ({ ui }) => ({
|
||||
canBeDisabled: ui.canBeDisabled,
|
||||
const mapStateToProps = ({
|
||||
ui: {
|
||||
canBeDisabled,
|
||||
supports: { autoInit },
|
||||
},
|
||||
}) => ({
|
||||
canBeDisabled,
|
||||
autoInit,
|
||||
});
|
||||
|
||||
// Exports from this module
|
||||
|
|
|
@ -96,6 +96,16 @@ AccessibilityPanel.prototype = {
|
|||
this.onTargetAvailable
|
||||
);
|
||||
|
||||
// Bug 1602075: if auto init feature is enabled, enable accessibility
|
||||
// service if necessary.
|
||||
if (
|
||||
this.accessibilityProxy.supports.autoInit &&
|
||||
this.accessibilityProxy.canBeEnabled &&
|
||||
!this.accessibilityProxy.enabled
|
||||
) {
|
||||
await this.accessibilityProxy.enableAccessibility();
|
||||
}
|
||||
|
||||
this.picker = new Picker(this);
|
||||
this.fluentBundles = await this.createFluentBundles();
|
||||
|
||||
|
@ -185,7 +195,7 @@ AccessibilityPanel.prototype = {
|
|||
// Alright reset the flag we are about to refresh the panel.
|
||||
this.shouldRefresh = false;
|
||||
this.postContentMessage("initialize", {
|
||||
supports: this.supports,
|
||||
supports: this.accessibilityProxy.supports,
|
||||
fluentBundles: this.fluentBundles,
|
||||
toolbox: this._toolbox,
|
||||
getAccessibilityTreeRoot: this.accessibilityProxy
|
||||
|
|
|
@ -123,7 +123,7 @@ function onReceiveChildren(cache, action) {
|
|||
}
|
||||
|
||||
if (accessible.actorID) {
|
||||
console.warn(`Error fetching children: `, accessible, error);
|
||||
console.warn(`Error fetching children: `, error);
|
||||
return cache;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
const TEST_URI = '<h1 id="h1">header</h1><p id="p">paragraph</p>';
|
||||
|
||||
add_task(async function() {
|
||||
Services.prefs.setBoolPref("devtools.accessibility.auto-init.enabled", false);
|
||||
|
||||
const { toolbox: toolbox1 } = await addTestTab(buildURL(TEST_URI));
|
||||
const { toolbox: toolbox2 } = await addTestTab(buildURL(TEST_URI));
|
||||
const options = await openOptions(toolbox2);
|
||||
|
@ -42,6 +44,8 @@ add_task(async function() {
|
|||
|
||||
await checkHighlighted(toolbox1, false);
|
||||
await checkHighlighted(toolbox2, false);
|
||||
|
||||
Services.prefs.clearUserPref("devtools.accessibility.auto-init.enabled");
|
||||
});
|
||||
|
||||
async function openOptions(toolbox) {
|
||||
|
|
|
@ -156,6 +156,15 @@ async function addTestTab(url) {
|
|||
* cleanup function to make sure that the panel is still present.
|
||||
*/
|
||||
async function disableAccessibilityInspector(env) {
|
||||
if (
|
||||
Services.prefs.getBoolPref(
|
||||
"devtools.accessibility.auto-init.enabled",
|
||||
false
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { doc, win, panel } = env;
|
||||
// Disable accessibility service through the panel and wait for the shutdown
|
||||
// event.
|
||||
|
|
|
@ -397,7 +397,11 @@ const AccessibleActor = ActorClassWithSpec(accessibleSpec, {
|
|||
let relationObject;
|
||||
for (const target of targets) {
|
||||
// Target of the relation is not part of the current root document.
|
||||
if (target.rootDocument !== doc.rawAccessible) {
|
||||
try {
|
||||
if (target.rootDocument !== doc.rawAccessible) {
|
||||
continue;
|
||||
}
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -467,7 +467,7 @@ const AccessibleWalkerActor = ActorClassWithSpec(accessibleWalkerSpec, {
|
|||
}
|
||||
|
||||
const doc = this.getRawAccessibleFor(this.rootDoc);
|
||||
if (isStale(doc)) {
|
||||
if (!doc || isStale(doc)) {
|
||||
return this.once("document-ready").then(docAcc => this.addRef(docAcc));
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче