Commit 46cbf4cd authored by Michael Liao's avatar Michael Liao Committed by Commit Bot

DevTools [Common - Infobar]: Make infobars keyboard accessible

Changes:
- Infobar buttons are keyboard accessible

Infobar button focus:
https://imgur.com/a/z9r8wvt

Reduced button size and added margin (current implementation):
https://imgur.com/ZElowjJ

Bug: 963183

Change-Id: Ied028e357be961cc70fde45b952ce8dbf4a7c384
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1657229
Commit-Queue: Michael Liao <michael.liao@microsoft.com>
Reviewed-by: default avatarPeter Marshall <petermarshall@chromium.org>
Reviewed-by: default avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702653}
parent 1088ea4d
...@@ -1585,6 +1585,7 @@ Sources.DebuggerPlugin = class extends Sources.UISourceCodeFrame.Plugin { ...@@ -1585,6 +1585,7 @@ Sources.DebuggerPlugin = class extends Sources.UISourceCodeFrame.Plugin {
toolbar.element.style.verticalAlign = 'middle'; toolbar.element.style.verticalAlign = 'middle';
toolbar.element.style.marginBottom = '3px'; toolbar.element.style.marginBottom = '3px';
toolbar.element.style.pointerEvents = 'none'; toolbar.element.style.pointerEvents = 'none';
toolbar.element.tabIndex = -1;
const element = this._prettyPrintInfobar.createDetailsRowMessage(); const element = this._prettyPrintInfobar.createDetailsRowMessage();
element.appendChild(UI.formatLocalized( element.appendChild(UI.formatLocalized(
'You can click the %s button on the bottom status bar, and continue debugging with the new formatted source.', 'You can click the %s button on the bottom status bar, and continue debugging with the new formatted source.',
......
...@@ -21,20 +21,21 @@ export default class Infobar { ...@@ -21,20 +21,21 @@ export default class Infobar {
this._mainRowText.textContent = text; this._mainRowText.textContent = text;
this._detailsRows = this._contentElement.createChild('div', 'infobar-details-rows hidden'); this._detailsRows = this._contentElement.createChild('div', 'infobar-details-rows hidden');
this._toggleElement = this._mainRow.createChild('div', 'infobar-toggle hidden'); this._toggleElement =
this._toggleElement.addEventListener('click', this._onToggleDetails.bind(this), false); UI.createTextButton(ls`more`, this._onToggleDetails.bind(this), 'infobar-toggle link-style hidden');
this._toggleElement.textContent = Common.UIString('more'); this._mainRow.appendChild(this._toggleElement);
/** @type {?Common.Setting} */ /** @type {?Common.Setting} */
this._disableSetting = disableSetting || null; this._disableSetting = disableSetting || null;
if (disableSetting) { if (disableSetting) {
const disableButton = this._mainRow.createChild('div', 'infobar-toggle'); const disableButton =
disableButton.textContent = Common.UIString('never show'); UI.createTextButton(ls`never show`, this._onDisable.bind(this), 'infobar-toggle link-style');
disableButton.addEventListener('click', this._onDisable.bind(this), false); this._mainRow.appendChild(disableButton);
} }
this._closeButton = this._contentElement.createChild('div', 'close-button', 'dt-close-button'); this._closeButton = this._contentElement.createChild('div', 'close-button', 'dt-close-button');
this._closeButton.addEventListener('click', this.dispose.bind(this), false); this._closeButton.setTabbable(true);
self.onInvokeElement(this._closeButton, this.dispose.bind(this));
/** @type {?function()} */ /** @type {?function()} */
this._closeCallback = null; this._closeCallback = null;
......
...@@ -63,28 +63,6 @@ export default class Panel extends UI.VBox { ...@@ -63,28 +63,6 @@ export default class Panel extends UI.VBox {
elementsToRestoreScrollPositionsFor() { elementsToRestoreScrollPositionsFor() {
return []; return [];
} }
/**
* @param {!UI.Infobar} infobar
*/
showInfobar(infobar) {
infobar.setCloseCallback(this._onInfobarClosed.bind(this, infobar));
if (this.element.firstChild) {
this.element.insertBefore(infobar.element, this.element.firstChild);
} else {
this.element.appendChild(infobar.element);
}
infobar.setParentView(this);
this.doResize();
}
/**
* @param {!UI.Infobar} infobar
*/
_onInfobarClosed(infobar) {
infobar.element.remove();
this.doResize();
}
} }
/** /**
......
...@@ -1594,6 +1594,18 @@ registerCustomElement('div', 'dt-close-button', class extends HTMLDivElement { ...@@ -1594,6 +1594,18 @@ registerCustomElement('div', 'dt-close-button', class extends HTMLDivElement {
setAccessibleName(name) { setAccessibleName(name) {
UI.ARIAUtils.setAccessibleName(this._buttonElement, name); UI.ARIAUtils.setAccessibleName(this._buttonElement, name);
} }
/**
* @param {boolean} tabbable
* @this {Element}
*/
setTabbable(tabbable) {
if (tabbable) {
this._buttonElement.tabIndex = 0;
} else {
this._buttonElement.tabIndex = -1;
}
}
}); });
})(); })();
......
...@@ -25,6 +25,14 @@ ...@@ -25,6 +25,14 @@
display: block; display: block;
} }
.close-button[data-keyboard-focus="true"]:focus .default-icon, .close-button:active .default-icon {
display: none;
}
.close-button[data-keyboard-focus="true"]:focus .hover-icon {
display: block;
}
.close-button:active .hover-icon { .close-button:active .hover-icon {
display: none !important; display: none !important;
} }
......
...@@ -67,6 +67,8 @@ ...@@ -67,6 +67,8 @@
.infobar-toggle { .infobar-toggle {
color: hsl(214, 92%, 50%); color: hsl(214, 92%, 50%);
cursor: pointer; cursor: pointer;
margin-top: 5px;
margin-bottom: 5px;
} }
.infobar-toggle:hover { .infobar-toggle:hover {
......
...@@ -44,6 +44,15 @@ ...@@ -44,6 +44,15 @@
color: #fff; color: #fff;
} }
.text-button.link-style {
background: none;
border: none;
padding: 0!important;
font: inherit;
cursor: pointer;
height: 18px;
}
.text-button.primary-button:not(:disabled):focus, .text-button.primary-button:not(:disabled):focus,
.text-button.primary-button:not(:disabled):hover, .text-button.primary-button:not(:disabled):hover,
.text-button.primary-button:not(:disabled):active, -theme-preserve { .text-button.primary-button:not(:disabled):active, -theme-preserve {
......
Markdown is supported
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