| 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 24 matching lines...) Expand all Loading... |
| 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 Loading... |
| 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"); |
| 770 tab.view.showWidget(this.element); | 774 tab.view.showWidget(this.element); |
| 771 this._updateTabSlider(); | 775 this._updateTabSlider(); |
| 772 }, | 776 }, |
| 773 | 777 |
| 774 _updateTabSlider: function() | 778 _updateTabSlider: function() |
| 775 { | 779 { |
| 776 if (!this._currentTab || !this._sliderEnabled) | 780 if (!this._currentTab || !this._sliderEnabled) |
| 777 return; | 781 return; |
| 778 var left = 0; | 782 var left = 0; |
| 779 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs
[i] && this._tabs[i]._shown; i++) | 783 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs
[i] && this._tabs[i]._shown; i++) |
| 780 left += this._tabs[i]._measuredWidth; | 784 left += this._tabs[i]._measuredWidth; |
| 781 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWi
dth : this._dropDownButton.offsetWidth; | 785 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWi
dth : this._dropDownButton.offsetWidth; |
| 782 var scaleFactor = window.devicePixelRatio >= 1.5 ? " scaleY(0.75)" : ""; | 786 var scaleFactor = window.devicePixelRatio >= 1.5 ? " scaleY(0.75)" : ""; |
| 783 this._tabSlider.style.transform = "translateX(" + left + "px)" + scaleFa
ctor; | 787 this._tabSlider.style.transform = "translateX(" + left + "px)" + scaleFa
ctor; |
| 784 this._tabSlider.style.width = sliderWidth + "px"; | 788 this._tabSlider.style.width = sliderWidth + "px"; |
| 785 | 789 |
| 786 if (this._tabSlider.parentElement !== this._headerContentsElement) | 790 if (this._tabSlider.parentElement !== this._headerContentsElement) |
| 787 this._headerContentsElement.appendChild(this._tabSlider); | 791 this._headerContentsElement.appendChild(this._tabSlider); |
| 788 }, | 792 }, |
| 789 | 793 |
| 790 /** | 794 /** |
| 791 * @param {!WebInspector.TabbedPaneTab} tab | 795 * @param {!WebInspector.TabbedPaneTab} tab |
| 792 */ | 796 */ |
| 793 _hideTab: function(tab) | 797 _hideTab: function(tab) |
| 794 { | 798 { |
| 795 tab.tabElement.classList.remove("selected"); | 799 tab.tabElement.classList.remove("selected"); |
| 800 tab.tabElement.setAttribute("aria-selected", "false"); |
| 796 tab.view.hideWidget(); | 801 tab.view.hideWidget(); |
| 797 }, | 802 }, |
| 798 | 803 |
| 799 /** | 804 /** |
| 800 * @override | 805 * @override |
| 801 * @return {!Array.<!Element>} | 806 * @return {!Array.<!Element>} |
| 802 */ | 807 */ |
| 803 elementsToRestoreScrollPositionsFor: function() | 808 elementsToRestoreScrollPositionsFor: function() |
| 804 { | 809 { |
| 805 return [ this._contentElement ]; | 810 return [ this._contentElement ]; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 | 1036 |
| 1032 /** | 1037 /** |
| 1033 * @param {boolean} measuring | 1038 * @param {boolean} measuring |
| 1034 * @return {!Element} | 1039 * @return {!Element} |
| 1035 */ | 1040 */ |
| 1036 _createTabElement: function(measuring) | 1041 _createTabElement: function(measuring) |
| 1037 { | 1042 { |
| 1038 var tabElement = createElementWithClass("div", "tabbed-pane-header-tab")
; | 1043 var tabElement = createElementWithClass("div", "tabbed-pane-header-tab")
; |
| 1039 tabElement.id = "tab-" + this._id; | 1044 tabElement.id = "tab-" + this._id; |
| 1040 tabElement.tabIndex = -1; | 1045 tabElement.tabIndex = -1; |
| 1046 tabElement.setAttribute("role", "tab"); |
| 1047 tabElement.setAttribute("aria-selected", "false"); |
| 1041 tabElement.selectTabForTest = this._tabbedPane.selectTab.bind(this._tabb
edPane, this.id, true); | 1048 tabElement.selectTabForTest = this._tabbedPane.selectTab.bind(this._tabb
edPane, this.id, true); |
| 1042 | 1049 |
| 1043 var titleElement = tabElement.createChild("span", "tabbed-pane-header-ta
b-title"); | 1050 var titleElement = tabElement.createChild("span", "tabbed-pane-header-ta
b-title"); |
| 1044 titleElement.textContent = this.title; | 1051 titleElement.textContent = this.title; |
| 1045 titleElement.title = this.tooltip || ""; | 1052 titleElement.title = this.tooltip || ""; |
| 1046 this._createIconElement(tabElement, titleElement); | 1053 this._createIconElement(tabElement, titleElement); |
| 1047 if (!measuring) | 1054 if (!measuring) |
| 1048 this._titleElement = titleElement; | 1055 this._titleElement = titleElement; |
| 1049 | 1056 |
| 1050 if (this._closeable) | 1057 if (this._closeable) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 * @param {!Array.<string>} ids | 1247 * @param {!Array.<string>} ids |
| 1241 */ | 1248 */ |
| 1242 closeTabs: function(tabbedPane, ids) { }, | 1249 closeTabs: function(tabbedPane, ids) { }, |
| 1243 | 1250 |
| 1244 /** | 1251 /** |
| 1245 * @param {string} tabId | 1252 * @param {string} tabId |
| 1246 * @param {!WebInspector.ContextMenu} contextMenu | 1253 * @param {!WebInspector.ContextMenu} contextMenu |
| 1247 */ | 1254 */ |
| 1248 onContextMenu: function(tabId, contextMenu) { } | 1255 onContextMenu: function(tabId, contextMenu) { } |
| 1249 } | 1256 } |
| OLD | NEW |