Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js

Issue 2334693003: Add ARIA markup for tabs & tab panels (Closed)
Patch Set: fixed aboxhall comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/Panel.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 WebInspector.TabbedPane = function() 35 WebInspector.TabbedPane = function()
36 { 36 {
37 WebInspector.VBox.call(this, true); 37 WebInspector.VBox.call(this, true);
38 this.registerRequiredCSS("ui/tabbedPane.css"); 38 this.registerRequiredCSS("ui/tabbedPane.css");
39 this.element.classList.add("tabbed-pane"); 39 this.element.classList.add("tabbed-pane");
40 this.contentElement.classList.add("tabbed-pane-shadow"); 40 this.contentElement.classList.add("tabbed-pane-shadow");
41 this.contentElement.tabIndex = -1; 41 this.contentElement.tabIndex = -1;
42 this._headerElement = this.contentElement.createChild("div", "tabbed-pane-he ader"); 42 this._headerElement = this.contentElement.createChild("div", "tabbed-pane-he ader");
43 this._headerElement.createChild("content").select = ".tabbed-pane-header-bef ore"; 43 this._headerElement.createChild("content").select = ".tabbed-pane-header-bef ore";
44 this._headerContentsElement = this._headerElement.createChild("div", "tabbed -pane-header-contents"); 44 this._headerContentsElement = this._headerElement.createChild("div", "tabbed -pane-header-contents");
45 this._headerContentsElement.setAttribute("aria-label", WebInspector.UIString ("Panels"));
45 this._tabSlider = createElementWithClass("div", "tabbed-pane-tab-slider"); 46 this._tabSlider = createElementWithClass("div", "tabbed-pane-tab-slider");
46 this._headerElement.createChild("content").select = ".tabbed-pane-header-aft er"; 47 this._headerElement.createChild("content").select = ".tabbed-pane-header-aft er";
47 this._tabsElement = this._headerContentsElement.createChild("div", "tabbed-p ane-header-tabs"); 48 this._tabsElement = this._headerContentsElement.createChild("div", "tabbed-p ane-header-tabs");
49 this._tabsElement.setAttribute("role", "tablist");
48 this._contentElement = this.contentElement.createChild("div", "tabbed-pane-c ontent"); 50 this._contentElement = this.contentElement.createChild("div", "tabbed-pane-c ontent");
51 this._contentElement.setAttribute("role", "tabpanel");
49 this._contentElement.createChild("content"); 52 this._contentElement.createChild("content");
50 /** @type {!Array.<!WebInspector.TabbedPaneTab>} */ 53 /** @type {!Array.<!WebInspector.TabbedPaneTab>} */
51 this._tabs = []; 54 this._tabs = [];
52 /** @type {!Array.<!WebInspector.TabbedPaneTab>} */ 55 /** @type {!Array.<!WebInspector.TabbedPaneTab>} */
53 this._tabsHistory = []; 56 this._tabsHistory = [];
54 /** @type {!Object.<string, !WebInspector.TabbedPaneTab>} */ 57 /** @type {!Object.<string, !WebInspector.TabbedPaneTab>} */
55 this._tabsById = {}; 58 this._tabsById = {};
56 this._currentTabLocked = false; 59 this._currentTabLocked = false;
57 60
58 this._dropDownButton = this._createDropDownButton(); 61 this._dropDownButton = this._createDropDownButton();
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 this._hideTab(this._currentTab); 763 this._hideTab(this._currentTab);
761 delete this._currentTab; 764 delete this._currentTab;
762 }, 765 },
763 766
764 /** 767 /**
765 * @param {!WebInspector.TabbedPaneTab} tab 768 * @param {!WebInspector.TabbedPaneTab} tab
766 */ 769 */
767 _showTab: function(tab) 770 _showTab: function(tab)
768 { 771 {
769 tab.tabElement.classList.add("selected"); 772 tab.tabElement.classList.add("selected");
773 tab.tabElement.setAttribute("aria-selected", "true");
774 tab.tabElement.tabIndex = 0;
einbinder 2016/09/12 23:21:25 Let's move the tabIndex changes to the patch with
hhillen 2016/09/12 23:26:52 Done.
770 tab.view.showWidget(this.element); 775 tab.view.showWidget(this.element);
771 this._updateTabSlider(); 776 this._updateTabSlider();
772 }, 777 },
773 778
774 _updateTabSlider: function() 779 _updateTabSlider: function()
775 { 780 {
776 if (!this._currentTab || !this._sliderEnabled) 781 if (!this._currentTab || !this._sliderEnabled)
777 return; 782 return;
778 var left = 0; 783 var left = 0;
779 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs [i] && this._tabs[i]._shown; i++) 784 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs [i] && this._tabs[i]._shown; i++)
780 left += this._tabs[i]._measuredWidth; 785 left += this._tabs[i]._measuredWidth;
781 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWi dth : this._dropDownButton.offsetWidth; 786 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWi dth : this._dropDownButton.offsetWidth;
782 var scaleFactor = window.devicePixelRatio >= 1.5 ? " scaleY(0.75)" : ""; 787 var scaleFactor = window.devicePixelRatio >= 1.5 ? " scaleY(0.75)" : "";
783 this._tabSlider.style.transform = "translateX(" + left + "px)" + scaleFa ctor; 788 this._tabSlider.style.transform = "translateX(" + left + "px)" + scaleFa ctor;
784 this._tabSlider.style.width = sliderWidth + "px"; 789 this._tabSlider.style.width = sliderWidth + "px";
785 790
786 if (this._tabSlider.parentElement !== this._headerContentsElement) 791 if (this._tabSlider.parentElement !== this._headerContentsElement)
787 this._headerContentsElement.appendChild(this._tabSlider); 792 this._headerContentsElement.appendChild(this._tabSlider);
788 }, 793 },
789 794
790 /** 795 /**
791 * @param {!WebInspector.TabbedPaneTab} tab 796 * @param {!WebInspector.TabbedPaneTab} tab
792 */ 797 */
793 _hideTab: function(tab) 798 _hideTab: function(tab)
794 { 799 {
795 tab.tabElement.classList.remove("selected"); 800 tab.tabElement.classList.remove("selected");
801 tab.tabElement.setAttribute("aria-expanded", "false");
802 tab.tabElement.tabIndex = -1;
796 tab.view.hideWidget(); 803 tab.view.hideWidget();
797 }, 804 },
798 805
799 /** 806 /**
800 * @override 807 * @override
801 * @return {!Array.<!Element>} 808 * @return {!Array.<!Element>}
802 */ 809 */
803 elementsToRestoreScrollPositionsFor: function() 810 elementsToRestoreScrollPositionsFor: function()
804 { 811 {
805 return [ this._contentElement ]; 812 return [ this._contentElement ];
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1038
1032 /** 1039 /**
1033 * @param {boolean} measuring 1040 * @param {boolean} measuring
1034 * @return {!Element} 1041 * @return {!Element}
1035 */ 1042 */
1036 _createTabElement: function(measuring) 1043 _createTabElement: function(measuring)
1037 { 1044 {
1038 var tabElement = createElementWithClass("div", "tabbed-pane-header-tab") ; 1045 var tabElement = createElementWithClass("div", "tabbed-pane-header-tab") ;
1039 tabElement.id = "tab-" + this._id; 1046 tabElement.id = "tab-" + this._id;
1040 tabElement.tabIndex = -1; 1047 tabElement.tabIndex = -1;
1048 tabElement.setAttribute("role", "tab");
1049 tabElement.setAttribute("aria-expanded", "false");
1041 tabElement.selectTabForTest = this._tabbedPane.selectTab.bind(this._tabb edPane, this.id, true); 1050 tabElement.selectTabForTest = this._tabbedPane.selectTab.bind(this._tabb edPane, this.id, true);
1042 1051
1043 var titleElement = tabElement.createChild("span", "tabbed-pane-header-ta b-title"); 1052 var titleElement = tabElement.createChild("span", "tabbed-pane-header-ta b-title");
1044 titleElement.textContent = this.title; 1053 titleElement.textContent = this.title;
1045 titleElement.title = this.tooltip || ""; 1054 titleElement.title = this.tooltip || "";
1046 this._createIconElement(tabElement, titleElement); 1055 this._createIconElement(tabElement, titleElement);
1047 if (!measuring) 1056 if (!measuring)
1048 this._titleElement = titleElement; 1057 this._titleElement = titleElement;
1049 1058
1050 if (this._closeable) 1059 if (this._closeable)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 * @param {!Array.<string>} ids 1249 * @param {!Array.<string>} ids
1241 */ 1250 */
1242 closeTabs: function(tabbedPane, ids) { }, 1251 closeTabs: function(tabbedPane, ids) { },
1243 1252
1244 /** 1253 /**
1245 * @param {string} tabId 1254 * @param {string} tabId
1246 * @param {!WebInspector.ContextMenu} contextMenu 1255 * @param {!WebInspector.ContextMenu} contextMenu
1247 */ 1256 */
1248 onContextMenu: function(tabId, contextMenu) { } 1257 onContextMenu: function(tabId, contextMenu) { }
1249 } 1258 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/Panel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698