Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @extends {WebInspector.VBox} | 32 * @extends {WebInspector.VBox} |
| 33 * @constructor | 33 * @constructor |
| 34 */ | 34 */ |
| 35 WebInspector.TabbedPane = function() | 35 WebInspector.TabbedPane = function() |
| 36 { | 36 { |
| 37 // change | |
|
aboxhall
2016/09/12 20:41:11
This probably isn't needed any more?
hhillen
2016/09/12 21:11:17
Done.
| |
| 37 WebInspector.VBox.call(this, true); | 38 WebInspector.VBox.call(this, true); |
| 38 this.registerRequiredCSS("ui/tabbedPane.css"); | 39 this.registerRequiredCSS("ui/tabbedPane.css"); |
| 39 this.element.classList.add("tabbed-pane"); | 40 this.element.classList.add("tabbed-pane"); |
| 40 this.contentElement.classList.add("tabbed-pane-shadow"); | 41 this.contentElement.classList.add("tabbed-pane-shadow"); |
| 41 this.contentElement.tabIndex = -1; | 42 this.contentElement.tabIndex = -1; |
| 42 this._headerElement = this.contentElement.createChild("div", "tabbed-pane-he ader"); | 43 this._headerElement = this.contentElement.createChild("div", "tabbed-pane-he ader"); |
| 43 this._headerElement.createChild("content").select = ".tabbed-pane-header-bef ore"; | 44 this._headerElement.createChild("content").select = ".tabbed-pane-header-bef ore"; |
| 44 this._headerContentsElement = this._headerElement.createChild("div", "tabbed -pane-header-contents"); | 45 this._headerContentsElement = this._headerElement.createChild("div", "tabbed -pane-header-contents"); |
| 46 this._headerContentsElement.setAttribute("role", "tablist"); | |
| 47 this._headerContentsElement.setAttribute("aria-label", WebInspector.UIString ("Panels")); | |
| 45 this._tabSlider = createElementWithClass("div", "tabbed-pane-tab-slider"); | 48 this._tabSlider = createElementWithClass("div", "tabbed-pane-tab-slider"); |
| 46 this._headerElement.createChild("content").select = ".tabbed-pane-header-aft er"; | 49 this._headerElement.createChild("content").select = ".tabbed-pane-header-aft er"; |
| 47 this._tabsElement = this._headerContentsElement.createChild("div", "tabbed-p ane-header-tabs"); | 50 this._tabsElement = this._headerContentsElement.createChild("div", "tabbed-p ane-header-tabs"); |
| 51 this._tabsElement.setAttribute("role", "presentation"); | |
|
aboxhall
2016/09/12 20:41:11
Is this so that the tabs end up being "direct" chi
hhillen
2016/09/12 21:11:17
Good point, made the change
| |
| 48 this._contentElement = this.contentElement.createChild("div", "tabbed-pane-c ontent"); | 52 this._contentElement = this.contentElement.createChild("div", "tabbed-pane-c ontent"); |
| 53 this._contentElement.setAttribute("role", "tabpanel"); | |
| 49 this._contentElement.createChild("content"); | 54 this._contentElement.createChild("content"); |
| 50 /** @type {!Array.<!WebInspector.TabbedPaneTab>} */ | 55 /** @type {!Array.<!WebInspector.TabbedPaneTab>} */ |
| 51 this._tabs = []; | 56 this._tabs = []; |
| 52 /** @type {!Array.<!WebInspector.TabbedPaneTab>} */ | 57 /** @type {!Array.<!WebInspector.TabbedPaneTab>} */ |
| 53 this._tabsHistory = []; | 58 this._tabsHistory = []; |
| 54 /** @type {!Object.<string, !WebInspector.TabbedPaneTab>} */ | 59 /** @type {!Object.<string, !WebInspector.TabbedPaneTab>} */ |
| 55 this._tabsById = {}; | 60 this._tabsById = {}; |
| 56 this._currentTabLocked = false; | 61 this._currentTabLocked = false; |
| 57 | 62 |
| 58 this._dropDownButton = this._createDropDownButton(); | 63 this._dropDownButton = this._createDropDownButton(); |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 760 this._hideTab(this._currentTab); | 765 this._hideTab(this._currentTab); |
| 761 delete this._currentTab; | 766 delete this._currentTab; |
| 762 }, | 767 }, |
| 763 | 768 |
| 764 /** | 769 /** |
| 765 * @param {!WebInspector.TabbedPaneTab} tab | 770 * @param {!WebInspector.TabbedPaneTab} tab |
| 766 */ | 771 */ |
| 767 _showTab: function(tab) | 772 _showTab: function(tab) |
| 768 { | 773 { |
| 769 tab.tabElement.classList.add("selected"); | 774 tab.tabElement.classList.add("selected"); |
| 775 tab.tabElement.setAttribute("aria-expanded", "true"); | |
|
aboxhall
2016/09/12 20:41:11
Should this be aria-selected per https://www.w3.or
hhillen
2016/09/12 21:11:17
Done.
| |
| 776 tab.tabElement.tabIndex = 0; | |
| 770 tab.view.showWidget(this.element); | 777 tab.view.showWidget(this.element); |
| 771 this._updateTabSlider(); | 778 this._updateTabSlider(); |
| 772 }, | 779 }, |
| 773 | 780 |
| 774 _updateTabSlider: function() | 781 _updateTabSlider: function() |
| 775 { | 782 { |
| 776 if (!this._currentTab || !this._sliderEnabled) | 783 if (!this._currentTab || !this._sliderEnabled) |
| 777 return; | 784 return; |
| 778 var left = 0; | 785 var left = 0; |
| 779 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs [i] && this._tabs[i]._shown; i++) | 786 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs [i] && this._tabs[i]._shown; i++) |
| 780 left += this._tabs[i]._measuredWidth; | 787 left += this._tabs[i]._measuredWidth; |
| 781 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWi dth : this._dropDownButton.offsetWidth; | 788 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWi dth : this._dropDownButton.offsetWidth; |
| 782 var scaleFactor = window.devicePixelRatio >= 1.5 ? " scaleY(0.75)" : ""; | 789 var scaleFactor = window.devicePixelRatio >= 1.5 ? " scaleY(0.75)" : ""; |
| 783 this._tabSlider.style.transform = "translateX(" + left + "px)" + scaleFa ctor; | 790 this._tabSlider.style.transform = "translateX(" + left + "px)" + scaleFa ctor; |
| 784 this._tabSlider.style.width = sliderWidth + "px"; | 791 this._tabSlider.style.width = sliderWidth + "px"; |
| 785 | 792 |
| 786 if (this._tabSlider.parentElement !== this._headerContentsElement) | 793 if (this._tabSlider.parentElement !== this._headerContentsElement) |
| 787 this._headerContentsElement.appendChild(this._tabSlider); | 794 this._headerContentsElement.appendChild(this._tabSlider); |
| 788 }, | 795 }, |
| 789 | 796 |
| 790 /** | 797 /** |
| 791 * @param {!WebInspector.TabbedPaneTab} tab | 798 * @param {!WebInspector.TabbedPaneTab} tab |
| 792 */ | 799 */ |
| 793 _hideTab: function(tab) | 800 _hideTab: function(tab) |
| 794 { | 801 { |
| 795 tab.tabElement.classList.remove("selected"); | 802 tab.tabElement.classList.remove("selected"); |
| 803 tab.tabElement.setAttribute("aria-expanded", "false"); | |
| 804 tab.tabElement.tabIndex = -1; | |
| 796 tab.view.hideWidget(); | 805 tab.view.hideWidget(); |
| 797 }, | 806 }, |
| 798 | 807 |
| 799 /** | 808 /** |
| 800 * @override | 809 * @override |
| 801 * @return {!Array.<!Element>} | 810 * @return {!Array.<!Element>} |
| 802 */ | 811 */ |
| 803 elementsToRestoreScrollPositionsFor: function() | 812 elementsToRestoreScrollPositionsFor: function() |
| 804 { | 813 { |
| 805 return [ this._contentElement ]; | 814 return [ this._contentElement ]; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1031 | 1040 |
| 1032 /** | 1041 /** |
| 1033 * @param {boolean} measuring | 1042 * @param {boolean} measuring |
| 1034 * @return {!Element} | 1043 * @return {!Element} |
| 1035 */ | 1044 */ |
| 1036 _createTabElement: function(measuring) | 1045 _createTabElement: function(measuring) |
| 1037 { | 1046 { |
| 1038 var tabElement = createElementWithClass("div", "tabbed-pane-header-tab") ; | 1047 var tabElement = createElementWithClass("div", "tabbed-pane-header-tab") ; |
| 1039 tabElement.id = "tab-" + this._id; | 1048 tabElement.id = "tab-" + this._id; |
| 1040 tabElement.tabIndex = -1; | 1049 tabElement.tabIndex = -1; |
| 1050 tabElement.setAttribute("role", "tab"); | |
| 1051 tabElement.setAttribute("aria-expanded", "false"); | |
| 1041 tabElement.selectTabForTest = this._tabbedPane.selectTab.bind(this._tabb edPane, this.id, true); | 1052 tabElement.selectTabForTest = this._tabbedPane.selectTab.bind(this._tabb edPane, this.id, true); |
| 1042 | 1053 |
| 1043 var titleElement = tabElement.createChild("span", "tabbed-pane-header-ta b-title"); | 1054 var titleElement = tabElement.createChild("span", "tabbed-pane-header-ta b-title"); |
| 1044 titleElement.textContent = this.title; | 1055 titleElement.textContent = this.title; |
| 1045 titleElement.title = this.tooltip || ""; | 1056 titleElement.title = this.tooltip || ""; |
| 1046 this._createIconElement(tabElement, titleElement); | 1057 this._createIconElement(tabElement, titleElement); |
| 1047 if (!measuring) | 1058 if (!measuring) |
| 1048 this._titleElement = titleElement; | 1059 this._titleElement = titleElement; |
| 1049 | 1060 |
| 1050 if (this._closeable) | 1061 if (this._closeable) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1240 * @param {!Array.<string>} ids | 1251 * @param {!Array.<string>} ids |
| 1241 */ | 1252 */ |
| 1242 closeTabs: function(tabbedPane, ids) { }, | 1253 closeTabs: function(tabbedPane, ids) { }, |
| 1243 | 1254 |
| 1244 /** | 1255 /** |
| 1245 * @param {string} tabId | 1256 * @param {string} tabId |
| 1246 * @param {!WebInspector.ContextMenu} contextMenu | 1257 * @param {!WebInspector.ContextMenu} contextMenu |
| 1247 */ | 1258 */ |
| 1248 onContextMenu: function(tabId, contextMenu) { } | 1259 onContextMenu: function(tabId, contextMenu) { } |
| 1249 } | 1260 } |
| OLD | NEW |