 Chromium Code Reviews
 Chromium Code Reviews Issue 2655393003:
  DevTools: Introduce ARIAUtils  (Closed)
    
  
    Issue 2655393003:
  DevTools: Introduce ARIAUtils  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 
| 3 * | 3 * | 
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without | 
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are | 
| 6 * met: | 6 * met: | 
| 7 * | 7 * | 
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright | 
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. | 
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above | 
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 */ | 33 */ | 
| 34 UI.TabbedPane = class extends UI.VBox { | 34 UI.TabbedPane = class extends UI.VBox { | 
| 35 constructor() { | 35 constructor() { | 
| 36 super(true); | 36 super(true); | 
| 37 this.registerRequiredCSS('ui/tabbedPane.css'); | 37 this.registerRequiredCSS('ui/tabbedPane.css'); | 
| 38 this.element.classList.add('tabbed-pane'); | 38 this.element.classList.add('tabbed-pane'); | 
| 39 this.contentElement.classList.add('tabbed-pane-shadow'); | 39 this.contentElement.classList.add('tabbed-pane-shadow'); | 
| 40 this.contentElement.tabIndex = -1; | 40 this.contentElement.tabIndex = -1; | 
| 41 this._headerElement = this.contentElement.createChild('div', 'tabbed-pane-he ader'); | 41 this._headerElement = this.contentElement.createChild('div', 'tabbed-pane-he ader'); | 
| 42 this._headerContentsElement = this._headerElement.createChild('div', 'tabbed -pane-header-contents'); | 42 this._headerContentsElement = this._headerElement.createChild('div', 'tabbed -pane-header-contents'); | 
| 43 this._headerContentsElement.setAttribute('aria-label', Common.UIString('Pane ls')); | |
| 44 this._tabSlider = createElementWithClass('div', 'tabbed-pane-tab-slider'); | 43 this._tabSlider = createElementWithClass('div', 'tabbed-pane-tab-slider'); | 
| 45 this._tabsElement = this._headerContentsElement.createChild('div', 'tabbed-p ane-header-tabs'); | 44 this._tabsElement = this._headerContentsElement.createChild('div', 'tabbed-p ane-header-tabs'); | 
| 46 this._tabsElement.setAttribute('role', 'tablist'); | 45 this._tabsElement.setAttribute('role', 'tablist'); | 
| 46 UI.ARIAUtils.setAccessibleName(this._tabsElement, Common.UIString('Panels')) ; | |
| 
dgozman
2017/01/27 23:12:59
This should be in InspectorView.
 
einbinder
2017/02/02 22:53:32
Done.
 | |
| 47 this._contentElement = this.contentElement.createChild('div', 'tabbed-pane-c ontent'); | 47 this._contentElement = this.contentElement.createChild('div', 'tabbed-pane-c ontent'); | 
| 48 this._contentElement.setAttribute('role', 'tabpanel'); | 48 this._contentElement.setAttribute('role', 'tabpanel'); | 
| 49 this._contentElement.createChild('content'); | 49 this._contentElement.createChild('content'); | 
| 50 /** @type {!Array.<!UI.TabbedPaneTab>} */ | 50 /** @type {!Array.<!UI.TabbedPaneTab>} */ | 
| 51 this._tabs = []; | 51 this._tabs = []; | 
| 52 /** @type {!Array.<!UI.TabbedPaneTab>} */ | 52 /** @type {!Array.<!UI.TabbedPaneTab>} */ | 
| 53 this._tabsHistory = []; | 53 this._tabsHistory = []; | 
| 54 /** @type {!Map<string, !UI.TabbedPaneTab>} */ | 54 /** @type {!Map<string, !UI.TabbedPaneTab>} */ | 
| 55 this._tabsById = new Map(); | 55 this._tabsById = new Map(); | 
| 56 this._currentTabLocked = false; | 56 this._currentTabLocked = false; | 
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 | 745 | 
| 746 this._hideTab(this._currentTab); | 746 this._hideTab(this._currentTab); | 
| 747 delete this._currentTab; | 747 delete this._currentTab; | 
| 748 } | 748 } | 
| 749 | 749 | 
| 750 /** | 750 /** | 
| 751 * @param {!UI.TabbedPaneTab} tab | 751 * @param {!UI.TabbedPaneTab} tab | 
| 752 */ | 752 */ | 
| 753 _showTab(tab) { | 753 _showTab(tab) { | 
| 754 tab.tabElement.classList.add('selected'); | 754 tab.tabElement.classList.add('selected'); | 
| 755 tab.tabElement.setAttribute('aria-selected', 'true'); | 755 UI.ARIAUtils.setSelected(tab.tabElement, false); | 
| 
dgozman
2017/01/27 23:12:59
true
 
einbinder
2017/02/02 22:53:32
Done.
 | |
| 756 tab.view.show(this.element); | 756 tab.view.show(this.element); | 
| 757 this._updateTabSlider(); | 757 this._updateTabSlider(); | 
| 758 } | 758 } | 
| 759 | 759 | 
| 760 _updateTabSlider() { | 760 _updateTabSlider() { | 
| 761 if (!this._currentTab || !this._sliderEnabled) | 761 if (!this._currentTab || !this._sliderEnabled) | 
| 762 return; | 762 return; | 
| 763 var left = 0; | 763 var left = 0; | 
| 764 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs[i] && this._tabs[i]._shown; i++) | 764 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs[i] && this._tabs[i]._shown; i++) | 
| 765 left += this._tabs[i]._measuredWidth; | 765 left += this._tabs[i]._measuredWidth; | 
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 } | 1015 } | 
| 1016 | 1016 | 
| 1017 /** | 1017 /** | 
| 1018 * @param {boolean} measuring | 1018 * @param {boolean} measuring | 
| 1019 * @return {!Element} | 1019 * @return {!Element} | 
| 1020 */ | 1020 */ | 
| 1021 _createTabElement(measuring) { | 1021 _createTabElement(measuring) { | 
| 1022 var tabElement = createElementWithClass('div', 'tabbed-pane-header-tab'); | 1022 var tabElement = createElementWithClass('div', 'tabbed-pane-header-tab'); | 
| 1023 tabElement.id = 'tab-' + this._id; | 1023 tabElement.id = 'tab-' + this._id; | 
| 1024 tabElement.tabIndex = -1; | 1024 tabElement.tabIndex = -1; | 
| 1025 tabElement.setAttribute('role', 'tab'); | 1025 UI.ARIAUtils.markAsTab(tabElement); | 
| 1026 tabElement.setAttribute('aria-selected', 'false'); | 1026 UI.ARIAUtils.setSelected(tabElement, false); | 
| 1027 tabElement.selectTabForTest = this._tabbedPane.selectTab.bind(this._tabbedPa ne, this.id, true); | 1027 tabElement.selectTabForTest = this._tabbedPane.selectTab.bind(this._tabbedPa ne, this.id, true); | 
| 1028 | 1028 | 
| 1029 var titleElement = tabElement.createChild('span', 'tabbed-pane-header-tab-ti tle'); | 1029 var titleElement = tabElement.createChild('span', 'tabbed-pane-header-tab-ti tle'); | 
| 1030 titleElement.textContent = this.title; | 1030 titleElement.textContent = this.title; | 
| 1031 titleElement.title = this.tooltip || ''; | 1031 titleElement.title = this.tooltip || ''; | 
| 1032 this._createIconElement(tabElement, titleElement, measuring); | 1032 this._createIconElement(tabElement, titleElement, measuring); | 
| 1033 if (!measuring) | 1033 if (!measuring) | 
| 1034 this._titleElement = titleElement; | 1034 this._titleElement = titleElement; | 
| 1035 | 1035 | 
| 1036 if (this._closeable) | 1036 if (this._closeable) | 
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1215 * @param {!Array.<string>} ids | 1215 * @param {!Array.<string>} ids | 
| 1216 */ | 1216 */ | 
| 1217 closeTabs(tabbedPane, ids) {}, | 1217 closeTabs(tabbedPane, ids) {}, | 
| 1218 | 1218 | 
| 1219 /** | 1219 /** | 
| 1220 * @param {string} tabId | 1220 * @param {string} tabId | 
| 1221 * @param {!UI.ContextMenu} contextMenu | 1221 * @param {!UI.ContextMenu} contextMenu | 
| 1222 */ | 1222 */ | 
| 1223 onContextMenu(tabId, contextMenu) {} | 1223 onContextMenu(tabId, contextMenu) {} | 
| 1224 }; | 1224 }; | 
| OLD | NEW |