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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.TabbedPane = class extends WebInspector.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', WebInspector.UIString ('Panels')); 43 this._headerContentsElement.setAttribute('aria-label', Common.UIString('Pane ls'));
44 this._tabSlider = createElementWithClass('div', 'tabbed-pane-tab-slider'); 44 this._tabSlider = createElementWithClass('div', 'tabbed-pane-tab-slider');
45 this._tabsElement = this._headerContentsElement.createChild('div', 'tabbed-p ane-header-tabs'); 45 this._tabsElement = this._headerContentsElement.createChild('div', 'tabbed-p ane-header-tabs');
46 this._tabsElement.setAttribute('role', 'tablist'); 46 this._tabsElement.setAttribute('role', 'tablist');
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.<!WebInspector.TabbedPaneTab>} */ 50 /** @type {!Array.<!UI.TabbedPaneTab>} */
51 this._tabs = []; 51 this._tabs = [];
52 /** @type {!Array.<!WebInspector.TabbedPaneTab>} */ 52 /** @type {!Array.<!UI.TabbedPaneTab>} */
53 this._tabsHistory = []; 53 this._tabsHistory = [];
54 /** @type {!Object.<string, !WebInspector.TabbedPaneTab>} */ 54 /** @type {!Object.<string, !UI.TabbedPaneTab>} */
55 this._tabsById = {}; 55 this._tabsById = {};
56 this._currentTabLocked = false; 56 this._currentTabLocked = false;
57 this._autoSelectFirstItemOnShow = true; 57 this._autoSelectFirstItemOnShow = true;
58 58
59 this._dropDownButton = this._createDropDownButton(); 59 this._dropDownButton = this._createDropDownButton();
60 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo omChanged, this._zoomChanged, this); 60 UI.zoomManager.addEventListener(UI.ZoomManager.Events.ZoomChanged, this._zoo mChanged, this);
61 } 61 }
62 62
63 /** 63 /**
64 * @param {boolean} locked 64 * @param {boolean} locked
65 */ 65 */
66 setCurrentTabLocked(locked) { 66 setCurrentTabLocked(locked) {
67 this._currentTabLocked = locked; 67 this._currentTabLocked = locked;
68 this._headerElement.classList.toggle('locked', this._currentTabLocked); 68 this._headerElement.classList.toggle('locked', this._currentTabLocked);
69 } 69 }
70 70
71 /** 71 /**
72 * @param {boolean} autoSelect 72 * @param {boolean} autoSelect
73 */ 73 */
74 setAutoSelectFirstItemOnShow(autoSelect) { 74 setAutoSelectFirstItemOnShow(autoSelect) {
75 this._autoSelectFirstItemOnShow = autoSelect; 75 this._autoSelectFirstItemOnShow = autoSelect;
76 } 76 }
77 77
78 /** 78 /**
79 * @return {?WebInspector.Widget} 79 * @return {?UI.Widget}
80 */ 80 */
81 get visibleView() { 81 get visibleView() {
82 return this._currentTab ? this._currentTab.view : null; 82 return this._currentTab ? this._currentTab.view : null;
83 } 83 }
84 84
85 /** 85 /**
86 * @return {!Array.<string>} 86 * @return {!Array.<string>}
87 */ 87 */
88 tabIds() { 88 tabIds() {
89 return this._tabs.map(tab => tab._id); 89 return this._tabs.map(tab => tab._id);
90 } 90 }
91 91
92 /** 92 /**
93 * @param {string} tabId 93 * @param {string} tabId
94 * @return {number} 94 * @return {number}
95 */ 95 */
96 tabIndex(tabId) { 96 tabIndex(tabId) {
97 return this._tabs.findIndex(tab => tab.id === tabId); 97 return this._tabs.findIndex(tab => tab.id === tabId);
98 } 98 }
99 99
100 /** 100 /**
101 * @return {!Array.<!WebInspector.Widget>} 101 * @return {!Array.<!UI.Widget>}
102 */ 102 */
103 tabViews() { 103 tabViews() {
104 return this._tabs.map(tab => tab.view); 104 return this._tabs.map(tab => tab.view);
105 } 105 }
106 106
107 /** 107 /**
108 * @param {string} tabId 108 * @param {string} tabId
109 * @return {?WebInspector.Widget} 109 * @return {?UI.Widget}
110 */ 110 */
111 tabView(tabId) { 111 tabView(tabId) {
112 return this._tabsById[tabId] ? this._tabsById[tabId].view : null; 112 return this._tabsById[tabId] ? this._tabsById[tabId].view : null;
113 } 113 }
114 114
115 /** 115 /**
116 * @return {?string} 116 * @return {?string}
117 */ 117 */
118 get selectedTabId() { 118 get selectedTabId() {
119 return this._currentTab ? this._currentTab.id : null; 119 return this._currentTab ? this._currentTab.id : null;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 /** 162 /**
163 * @param {string} id 163 * @param {string} id
164 * @return {boolean} 164 * @return {boolean}
165 */ 165 */
166 isTabCloseable(id) { 166 isTabCloseable(id) {
167 var tab = this._tabsById[id]; 167 var tab = this._tabsById[id];
168 return tab ? tab.isCloseable() : false; 168 return tab ? tab.isCloseable() : false;
169 } 169 }
170 170
171 /** 171 /**
172 * @param {!WebInspector.TabbedPaneTabDelegate} delegate 172 * @param {!UI.TabbedPaneTabDelegate} delegate
173 */ 173 */
174 setTabDelegate(delegate) { 174 setTabDelegate(delegate) {
175 var tabs = this._tabs.slice(); 175 var tabs = this._tabs.slice();
176 for (var i = 0; i < tabs.length; ++i) 176 for (var i = 0; i < tabs.length; ++i)
177 tabs[i].setDelegate(delegate); 177 tabs[i].setDelegate(delegate);
178 this._delegate = delegate; 178 this._delegate = delegate;
179 } 179 }
180 180
181 /** 181 /**
182 * @param {string} id 182 * @param {string} id
183 * @param {string} tabTitle 183 * @param {string} tabTitle
184 * @param {!WebInspector.Widget} view 184 * @param {!UI.Widget} view
185 * @param {string=} tabTooltip 185 * @param {string=} tabTooltip
186 * @param {boolean=} userGesture 186 * @param {boolean=} userGesture
187 * @param {boolean=} isCloseable 187 * @param {boolean=} isCloseable
188 * @param {number=} index 188 * @param {number=} index
189 */ 189 */
190 appendTab(id, tabTitle, view, tabTooltip, userGesture, isCloseable, index) { 190 appendTab(id, tabTitle, view, tabTooltip, userGesture, isCloseable, index) {
191 isCloseable = typeof isCloseable === 'boolean' ? isCloseable : this._closeab leTabs; 191 isCloseable = typeof isCloseable === 'boolean' ? isCloseable : this._closeab leTabs;
192 var tab = new WebInspector.TabbedPaneTab(this, id, tabTitle, isCloseable, vi ew, tabTooltip); 192 var tab = new UI.TabbedPaneTab(this, id, tabTitle, isCloseable, view, tabToo ltip);
193 tab.setDelegate(this._delegate); 193 tab.setDelegate(this._delegate);
194 this._tabsById[id] = tab; 194 this._tabsById[id] = tab;
195 if (index !== undefined) 195 if (index !== undefined)
196 this._tabs.splice(index, 0, tab); 196 this._tabs.splice(index, 0, tab);
197 else 197 else
198 this._tabs.push(tab); 198 this._tabs.push(tab);
199 this._tabsHistory.push(tab); 199 this._tabsHistory.push(tab);
200 view.attach(this); 200 view.attach(this);
201 if (this._tabsHistory[0] === tab && this.isShowing()) 201 if (this._tabsHistory[0] === tab && this.isShowing())
202 this.selectTab(tab.id, userGesture); 202 this.selectTab(tab.id, userGesture);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 var tab = this._tabsById[id]; 241 var tab = this._tabsById[id];
242 delete this._tabsById[id]; 242 delete this._tabsById[id];
243 243
244 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1); 244 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1);
245 this._tabs.splice(this._tabs.indexOf(tab), 1); 245 this._tabs.splice(this._tabs.indexOf(tab), 1);
246 if (tab._shown) 246 if (tab._shown)
247 this._hideTabElement(tab); 247 this._hideTabElement(tab);
248 tab.view.detach(); 248 tab.view.detach();
249 249
250 var eventData = {tabId: id, view: tab.view, isUserGesture: userGesture}; 250 var eventData = {tabId: id, view: tab.view, isUserGesture: userGesture};
251 this.dispatchEventToListeners(WebInspector.TabbedPane.Events.TabClosed, even tData); 251 this.dispatchEventToListeners(UI.TabbedPane.Events.TabClosed, eventData);
252 return true; 252 return true;
253 } 253 }
254 254
255 /** 255 /**
256 * @param {string} tabId 256 * @param {string} tabId
257 * @return {boolean} 257 * @return {boolean}
258 */ 258 */
259 hasTab(tabId) { 259 hasTab(tabId) {
260 return !!this._tabsById[tabId]; 260 return !!this._tabsById[tabId];
261 } 261 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 this._currentTab = tab; 323 this._currentTab = tab;
324 324
325 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1); 325 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1);
326 this._tabsHistory.splice(0, 0, tab); 326 this._tabsHistory.splice(0, 0, tab);
327 327
328 this._updateTabElements(); 328 this._updateTabElements();
329 if (focused) 329 if (focused)
330 this.focus(); 330 this.focus();
331 331
332 var eventData = {tabId: id, view: tab.view, isUserGesture: userGesture}; 332 var eventData = {tabId: id, view: tab.view, isUserGesture: userGesture};
333 this.dispatchEventToListeners(WebInspector.TabbedPane.Events.TabSelected, ev entData); 333 this.dispatchEventToListeners(UI.TabbedPane.Events.TabSelected, eventData);
334 return true; 334 return true;
335 } 335 }
336 336
337 /** 337 /**
338 * @param {number} tabsCount 338 * @param {number} tabsCount
339 * @return {!Array.<string>} 339 * @return {!Array.<string>}
340 */ 340 */
341 lastOpenedTabIds(tabsCount) { 341 lastOpenedTabIds(tabsCount) {
342 function tabToTabId(tab) { 342 function tabToTabId(tab) {
343 return tab.id; 343 return tab.id;
(...skipping 27 matching lines...) Expand all
371 * @param {string} className 371 * @param {string} className
372 * @param {boolean=} force 372 * @param {boolean=} force
373 */ 373 */
374 toggleTabClass(id, className, force) { 374 toggleTabClass(id, className, force) {
375 var tab = this._tabsById[id]; 375 var tab = this._tabsById[id];
376 if (tab._toggleClass(className, force)) 376 if (tab._toggleClass(className, force))
377 this._updateTabElements(); 377 this._updateTabElements();
378 } 378 }
379 379
380 /** 380 /**
381 * @param {!WebInspector.Event} event 381 * @param {!Common.Event} event
382 */ 382 */
383 _zoomChanged(event) { 383 _zoomChanged(event) {
384 for (var i = 0; i < this._tabs.length; ++i) 384 for (var i = 0; i < this._tabs.length; ++i)
385 delete this._tabs[i]._measuredWidth; 385 delete this._tabs[i]._measuredWidth;
386 if (this.isShowing()) 386 if (this.isShowing())
387 this._updateTabElements(); 387 this._updateTabElements();
388 } 388 }
389 389
390 /** 390 /**
391 * @param {string} id 391 * @param {string} id
392 * @param {string} tabTitle 392 * @param {string} tabTitle
393 * @param {string=} tabTooltip 393 * @param {string=} tabTooltip
394 */ 394 */
395 changeTabTitle(id, tabTitle, tabTooltip) { 395 changeTabTitle(id, tabTitle, tabTooltip) {
396 var tab = this._tabsById[id]; 396 var tab = this._tabsById[id];
397 if (tabTooltip !== undefined) 397 if (tabTooltip !== undefined)
398 tab.tooltip = tabTooltip; 398 tab.tooltip = tabTooltip;
399 if (tab.title !== tabTitle) { 399 if (tab.title !== tabTitle) {
400 tab.title = tabTitle; 400 tab.title = tabTitle;
401 this._updateTabElements(); 401 this._updateTabElements();
402 } 402 }
403 } 403 }
404 404
405 /** 405 /**
406 * @param {string} id 406 * @param {string} id
407 * @param {!WebInspector.Widget} view 407 * @param {!UI.Widget} view
408 */ 408 */
409 changeTabView(id, view) { 409 changeTabView(id, view) {
410 var tab = this._tabsById[id]; 410 var tab = this._tabsById[id];
411 if (tab.view === view) 411 if (tab.view === view)
412 return; 412 return;
413 413
414 var shouldFocus = tab.view.hasFocus(); 414 var shouldFocus = tab.view.hasFocus();
415 415
416 this.suspendInvalidations(); 416 this.suspendInvalidations();
417 417
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 var minContentConstraints = new Constraints(new Size(0, 0), new Size(50, 50) ); 466 var minContentConstraints = new Constraints(new Size(0, 0), new Size(50, 50) );
467 constraints = constraints.widthToMax(minContentConstraints).heightToMax(minC ontentConstraints); 467 constraints = constraints.widthToMax(minContentConstraints).heightToMax(minC ontentConstraints);
468 if (this._verticalTabLayout) 468 if (this._verticalTabLayout)
469 constraints = constraints.addWidth(new Constraints(new Size(120, 0))); 469 constraints = constraints.addWidth(new Constraints(new Size(120, 0)));
470 else 470 else
471 constraints = constraints.addHeight(new Constraints(new Size(0, 30))); 471 constraints = constraints.addHeight(new Constraints(new Size(0, 30)));
472 return constraints; 472 return constraints;
473 } 473 }
474 474
475 _updateTabElements() { 475 _updateTabElements() {
476 WebInspector.invokeOnceAfterBatchUpdate(this, this._innerUpdateTabElements); 476 UI.invokeOnceAfterBatchUpdate(this, this._innerUpdateTabElements);
477 } 477 }
478 478
479 /** 479 /**
480 * @param {string} text 480 * @param {string} text
481 */ 481 */
482 setPlaceholderText(text) { 482 setPlaceholderText(text) {
483 this._noTabsMessage = text; 483 this._noTabsMessage = text;
484 } 484 }
485 485
486 _innerUpdateTabElements() { 486 _innerUpdateTabElements() {
(...skipping 15 matching lines...) Expand all
502 } 502 }
503 503
504 this._measureDropDownButton(); 504 this._measureDropDownButton();
505 this._updateWidths(); 505 this._updateWidths();
506 this._updateTabsDropDown(); 506 this._updateTabsDropDown();
507 this._updateTabSlider(); 507 this._updateTabSlider();
508 } 508 }
509 509
510 /** 510 /**
511 * @param {number} index 511 * @param {number} index
512 * @param {!WebInspector.TabbedPaneTab} tab 512 * @param {!UI.TabbedPaneTab} tab
513 */ 513 */
514 _showTabElement(index, tab) { 514 _showTabElement(index, tab) {
515 if (index >= this._tabsElement.children.length) 515 if (index >= this._tabsElement.children.length)
516 this._tabsElement.appendChild(tab.tabElement); 516 this._tabsElement.appendChild(tab.tabElement);
517 else 517 else
518 this._tabsElement.insertBefore(tab.tabElement, this._tabsElement.children[ index]); 518 this._tabsElement.insertBefore(tab.tabElement, this._tabsElement.children[ index]);
519 tab._shown = true; 519 tab._shown = true;
520 } 520 }
521 521
522 /** 522 /**
523 * @param {!WebInspector.TabbedPaneTab} tab 523 * @param {!UI.TabbedPaneTab} tab
524 */ 524 */
525 _hideTabElement(tab) { 525 _hideTabElement(tab) {
526 this._tabsElement.removeChild(tab.tabElement); 526 this._tabsElement.removeChild(tab.tabElement);
527 tab._shown = false; 527 tab._shown = false;
528 } 528 }
529 529
530 _createDropDownButton() { 530 _createDropDownButton() {
531 var dropDownContainer = createElementWithClass('div', 'tabbed-pane-header-ta bs-drop-down-container'); 531 var dropDownContainer = createElementWithClass('div', 'tabbed-pane-header-ta bs-drop-down-container');
532 dropDownContainer.createChild('div', 'glyph'); 532 dropDownContainer.createChild('div', 'glyph');
533 this._dropDownMenu = new WebInspector.DropDownMenu(dropDownContainer); 533 this._dropDownMenu = new UI.DropDownMenu(dropDownContainer);
534 this._dropDownMenu.addEventListener( 534 this._dropDownMenu.addEventListener(
535 WebInspector.DropDownMenu.Events.ItemSelected, this._dropDownMenuItemSel ected, this); 535 UI.DropDownMenu.Events.ItemSelected, this._dropDownMenuItemSelected, thi s);
536 536
537 return dropDownContainer; 537 return dropDownContainer;
538 } 538 }
539 539
540 /** 540 /**
541 * @param {!WebInspector.Event} event 541 * @param {!Common.Event} event
542 */ 542 */
543 _dropDownMenuItemSelected(event) { 543 _dropDownMenuItemSelected(event) {
544 var tabId = /** @type {string} */ (event.data); 544 var tabId = /** @type {string} */ (event.data);
545 this._lastSelectedOverflowTab = this._tabsById[tabId]; 545 this._lastSelectedOverflowTab = this._tabsById[tabId];
546 this.selectTab(tabId, true); 546 this.selectTab(tabId, true);
547 } 547 }
548 548
549 _totalWidth() { 549 _totalWidth() {
550 return this._headerContentsElement.getBoundingClientRect().width; 550 return this._headerContentsElement.getBoundingClientRect().width;
551 } 551 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 692
693 if (totalWidth + totalExtraWidth >= totalMeasuredWidth) 693 if (totalWidth + totalExtraWidth >= totalMeasuredWidth)
694 return measuredWidths[i - 1] + 694 return measuredWidths[i - 1] +
695 (totalWidth + totalExtraWidth - totalMeasuredWidth) / (measuredWidth s.length - i); 695 (totalWidth + totalExtraWidth - totalMeasuredWidth) / (measuredWidth s.length - i);
696 } 696 }
697 697
698 return totalWidth / measuredWidths.length; 698 return totalWidth / measuredWidths.length;
699 } 699 }
700 700
701 /** 701 /**
702 * @param {!Array.<!WebInspector.TabbedPaneTab>} tabsOrdered 702 * @param {!Array.<!UI.TabbedPaneTab>} tabsOrdered
703 * @param {!Array.<!WebInspector.TabbedPaneTab>} tabsHistory 703 * @param {!Array.<!UI.TabbedPaneTab>} tabsHistory
704 * @param {number} totalWidth 704 * @param {number} totalWidth
705 * @param {number} measuredDropDownButtonWidth 705 * @param {number} measuredDropDownButtonWidth
706 * @return {!Array.<number>} 706 * @return {!Array.<number>}
707 */ 707 */
708 _tabsToShowIndexes(tabsOrdered, tabsHistory, totalWidth, measuredDropDownButto nWidth) { 708 _tabsToShowIndexes(tabsOrdered, tabsHistory, totalWidth, measuredDropDownButto nWidth) {
709 var tabsToShowIndexes = []; 709 var tabsToShowIndexes = [];
710 710
711 var totalTabsWidth = 0; 711 var totalTabsWidth = 0;
712 var tabCount = tabsOrdered.length; 712 var tabCount = tabsOrdered.length;
713 var tabsToLookAt = tabsOrdered.slice(0); 713 var tabsToLookAt = tabsOrdered.slice(0);
(...skipping 21 matching lines...) Expand all
735 735
736 _hideCurrentTab() { 736 _hideCurrentTab() {
737 if (!this._currentTab) 737 if (!this._currentTab)
738 return; 738 return;
739 739
740 this._hideTab(this._currentTab); 740 this._hideTab(this._currentTab);
741 delete this._currentTab; 741 delete this._currentTab;
742 } 742 }
743 743
744 /** 744 /**
745 * @param {!WebInspector.TabbedPaneTab} tab 745 * @param {!UI.TabbedPaneTab} tab
746 */ 746 */
747 _showTab(tab) { 747 _showTab(tab) {
748 tab.tabElement.classList.add('selected'); 748 tab.tabElement.classList.add('selected');
749 tab.tabElement.setAttribute('aria-selected', 'true'); 749 tab.tabElement.setAttribute('aria-selected', 'true');
750 tab.view.showWidget(this.element); 750 tab.view.showWidget(this.element);
751 this._updateTabSlider(); 751 this._updateTabSlider();
752 } 752 }
753 753
754 _updateTabSlider() { 754 _updateTabSlider() {
755 if (!this._currentTab || !this._sliderEnabled) 755 if (!this._currentTab || !this._sliderEnabled)
756 return; 756 return;
757 var left = 0; 757 var left = 0;
758 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs[i] && this._tabs[i]._shown; i++) 758 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs[i] && this._tabs[i]._shown; i++)
759 left += this._tabs[i]._measuredWidth; 759 left += this._tabs[i]._measuredWidth;
760 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWidth : this._dropDownButton.offsetWidth; 760 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWidth : this._dropDownButton.offsetWidth;
761 var scaleFactor = window.devicePixelRatio >= 1.5 ? ' scaleY(0.75)' : ''; 761 var scaleFactor = window.devicePixelRatio >= 1.5 ? ' scaleY(0.75)' : '';
762 this._tabSlider.style.transform = 'translateX(' + left + 'px)' + scaleFactor ; 762 this._tabSlider.style.transform = 'translateX(' + left + 'px)' + scaleFactor ;
763 this._tabSlider.style.width = sliderWidth + 'px'; 763 this._tabSlider.style.width = sliderWidth + 'px';
764 764
765 if (this._tabSlider.parentElement !== this._headerContentsElement) 765 if (this._tabSlider.parentElement !== this._headerContentsElement)
766 this._headerContentsElement.appendChild(this._tabSlider); 766 this._headerContentsElement.appendChild(this._tabSlider);
767 } 767 }
768 768
769 /** 769 /**
770 * @param {!WebInspector.TabbedPaneTab} tab 770 * @param {!UI.TabbedPaneTab} tab
771 */ 771 */
772 _hideTab(tab) { 772 _hideTab(tab) {
773 tab.tabElement.classList.remove('selected'); 773 tab.tabElement.classList.remove('selected');
774 tab.tabElement.setAttribute('aria-selected', 'false'); 774 tab.tabElement.setAttribute('aria-selected', 'false');
775 tab.view.hideWidget(); 775 tab.view.hideWidget();
776 } 776 }
777 777
778 /** 778 /**
779 * @override 779 * @override
780 * @return {!Array.<!Element>} 780 * @return {!Array.<!Element>}
781 */ 781 */
782 elementsToRestoreScrollPositionsFor() { 782 elementsToRestoreScrollPositionsFor() {
783 return [this._contentElement]; 783 return [this._contentElement];
784 } 784 }
785 785
786 /** 786 /**
787 * @param {!WebInspector.TabbedPaneTab} tab 787 * @param {!UI.TabbedPaneTab} tab
788 * @param {number} index 788 * @param {number} index
789 */ 789 */
790 _insertBefore(tab, index) { 790 _insertBefore(tab, index) {
791 this._tabsElement.insertBefore(tab._tabElement || null, this._tabsElement.ch ildNodes[index]); 791 this._tabsElement.insertBefore(tab._tabElement || null, this._tabsElement.ch ildNodes[index]);
792 var oldIndex = this._tabs.indexOf(tab); 792 var oldIndex = this._tabs.indexOf(tab);
793 this._tabs.splice(oldIndex, 1); 793 this._tabs.splice(oldIndex, 1);
794 if (oldIndex < index) 794 if (oldIndex < index)
795 --index; 795 --index;
796 this._tabs.splice(index, 0, tab); 796 this._tabs.splice(index, 0, tab);
797 this.dispatchEventToListeners(WebInspector.TabbedPane.Events.TabOrderChanged , this._tabs); 797 this.dispatchEventToListeners(UI.TabbedPane.Events.TabOrderChanged, this._ta bs);
798 } 798 }
799 799
800 /** 800 /**
801 * @return {!WebInspector.Toolbar} 801 * @return {!UI.Toolbar}
802 */ 802 */
803 leftToolbar() { 803 leftToolbar() {
804 if (!this._leftToolbar) { 804 if (!this._leftToolbar) {
805 this._leftToolbar = new WebInspector.Toolbar('tabbed-pane-left-toolbar'); 805 this._leftToolbar = new UI.Toolbar('tabbed-pane-left-toolbar');
806 this._headerElement.insertBefore(this._leftToolbar.element, this._headerEl ement.firstChild); 806 this._headerElement.insertBefore(this._leftToolbar.element, this._headerEl ement.firstChild);
807 } 807 }
808 return this._leftToolbar; 808 return this._leftToolbar;
809 } 809 }
810 810
811 /** 811 /**
812 * @return {!WebInspector.Toolbar} 812 * @return {!UI.Toolbar}
813 */ 813 */
814 rightToolbar() { 814 rightToolbar() {
815 if (!this._rightToolbar) { 815 if (!this._rightToolbar) {
816 this._rightToolbar = new WebInspector.Toolbar('tabbed-pane-right-toolbar') ; 816 this._rightToolbar = new UI.Toolbar('tabbed-pane-right-toolbar');
817 this._headerElement.appendChild(this._rightToolbar.element); 817 this._headerElement.appendChild(this._rightToolbar.element);
818 } 818 }
819 return this._rightToolbar; 819 return this._rightToolbar;
820 } 820 }
821 821
822 renderWithNoHeaderBackground() { 822 renderWithNoHeaderBackground() {
823 this._headerElement.classList.add('tabbed-pane-no-header-background'); 823 this._headerElement.classList.add('tabbed-pane-no-header-background');
824 } 824 }
825 825
826 /** 826 /**
827 * @param {boolean} allow 827 * @param {boolean} allow
828 * @param {boolean=} automatic 828 * @param {boolean=} automatic
829 */ 829 */
830 setAllowTabReorder(allow, automatic) { 830 setAllowTabReorder(allow, automatic) {
831 this._allowTabReorder = allow; 831 this._allowTabReorder = allow;
832 this._automaticReorder = automatic; 832 this._automaticReorder = automatic;
833 } 833 }
834 }; 834 };
835 835
836 /** @enum {symbol} */ 836 /** @enum {symbol} */
837 WebInspector.TabbedPane.Events = { 837 UI.TabbedPane.Events = {
838 TabSelected: Symbol('TabSelected'), 838 TabSelected: Symbol('TabSelected'),
839 TabClosed: Symbol('TabClosed'), 839 TabClosed: Symbol('TabClosed'),
840 TabOrderChanged: Symbol('TabOrderChanged') 840 TabOrderChanged: Symbol('TabOrderChanged')
841 }; 841 };
842 842
843 /** 843 /**
844 * @unrestricted 844 * @unrestricted
845 */ 845 */
846 WebInspector.TabbedPaneTab = class { 846 UI.TabbedPaneTab = class {
847 /** 847 /**
848 * @param {!WebInspector.TabbedPane} tabbedPane 848 * @param {!UI.TabbedPane} tabbedPane
849 * @param {string} id 849 * @param {string} id
850 * @param {string} title 850 * @param {string} title
851 * @param {boolean} closeable 851 * @param {boolean} closeable
852 * @param {!WebInspector.Widget} view 852 * @param {!UI.Widget} view
853 * @param {string=} tooltip 853 * @param {string=} tooltip
854 */ 854 */
855 constructor(tabbedPane, id, title, closeable, view, tooltip) { 855 constructor(tabbedPane, id, title, closeable, view, tooltip) {
856 this._closeable = closeable; 856 this._closeable = closeable;
857 this._tabbedPane = tabbedPane; 857 this._tabbedPane = tabbedPane;
858 this._id = id; 858 this._id = id;
859 this._title = title; 859 this._title = title;
860 this._tooltip = tooltip; 860 this._tooltip = tooltip;
861 this._view = view; 861 this._view = view;
862 this._shown = false; 862 this._shown = false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 var element = this.tabElement; 922 var element = this.tabElement;
923 var hasClass = element.classList.contains(className); 923 var hasClass = element.classList.contains(className);
924 if (hasClass === force) 924 if (hasClass === force)
925 return false; 925 return false;
926 element.classList.toggle(className, force); 926 element.classList.toggle(className, force);
927 delete this._measuredWidth; 927 delete this._measuredWidth;
928 return true; 928 return true;
929 } 929 }
930 930
931 /** 931 /**
932 * @return {!WebInspector.Widget} 932 * @return {!UI.Widget}
933 */ 933 */
934 get view() { 934 get view() {
935 return this._view; 935 return this._view;
936 } 936 }
937 937
938 /** 938 /**
939 * @param {!WebInspector.Widget} view 939 * @param {!UI.Widget} view
940 */ 940 */
941 set view(view) { 941 set view(view) {
942 this._view = view; 942 this._view = view;
943 } 943 }
944 944
945 /** 945 /**
946 * @return {string|undefined} 946 * @return {string|undefined}
947 */ 947 */
948 get tooltip() { 948 get tooltip() {
949 return this._tooltip; 949 return this._tooltip;
(...skipping 27 matching lines...) Expand all
977 977
978 /** 978 /**
979 * @param {number} width 979 * @param {number} width
980 */ 980 */
981 setWidth(width) { 981 setWidth(width) {
982 this.tabElement.style.width = width === -1 ? '' : (width + 'px'); 982 this.tabElement.style.width = width === -1 ? '' : (width + 'px');
983 this._width = width; 983 this._width = width;
984 } 984 }
985 985
986 /** 986 /**
987 * @param {!WebInspector.TabbedPaneTabDelegate} delegate 987 * @param {!UI.TabbedPaneTabDelegate} delegate
988 */ 988 */
989 setDelegate(delegate) { 989 setDelegate(delegate) {
990 this._delegate = delegate; 990 this._delegate = delegate;
991 } 991 }
992 992
993 /** 993 /**
994 * @param {!Element} tabElement 994 * @param {!Element} tabElement
995 * @param {!Element} titleElement 995 * @param {!Element} titleElement
996 */ 996 */
997 _createIconElement(tabElement, titleElement) { 997 _createIconElement(tabElement, titleElement) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 if (measuring) { 1033 if (measuring) {
1034 tabElement.classList.add('measuring'); 1034 tabElement.classList.add('measuring');
1035 } else { 1035 } else {
1036 tabElement.addEventListener('click', this._tabClicked.bind(this), false); 1036 tabElement.addEventListener('click', this._tabClicked.bind(this), false);
1037 tabElement.addEventListener('auxclick', this._tabClicked.bind(this), false ); 1037 tabElement.addEventListener('auxclick', this._tabClicked.bind(this), false );
1038 tabElement.addEventListener('mousedown', this._tabMouseDown.bind(this), fa lse); 1038 tabElement.addEventListener('mousedown', this._tabMouseDown.bind(this), fa lse);
1039 tabElement.addEventListener('mouseup', this._tabMouseUp.bind(this), false) ; 1039 tabElement.addEventListener('mouseup', this._tabMouseUp.bind(this), false) ;
1040 1040
1041 tabElement.addEventListener('contextmenu', this._tabContextMenu.bind(this) , false); 1041 tabElement.addEventListener('contextmenu', this._tabContextMenu.bind(this) , false);
1042 if (this._tabbedPane._allowTabReorder) 1042 if (this._tabbedPane._allowTabReorder)
1043 WebInspector.installDragHandle( 1043 UI.installDragHandle(
1044 tabElement, this._startTabDragging.bind(this), this._tabDragging.bin d(this), 1044 tabElement, this._startTabDragging.bind(this), this._tabDragging.bin d(this),
1045 this._endTabDragging.bind(this), '-webkit-grabbing', 'pointer', 200) ; 1045 this._endTabDragging.bind(this), '-webkit-grabbing', 'pointer', 200) ;
1046 } 1046 }
1047 1047
1048 return tabElement; 1048 return tabElement;
1049 } 1049 }
1050 1050
1051 /** 1051 /**
1052 * @param {!Event} event 1052 * @param {!Event} event
1053 */ 1053 */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 _closeTabs(ids) { 1086 _closeTabs(ids) {
1087 if (this._delegate) { 1087 if (this._delegate) {
1088 this._delegate.closeTabs(this._tabbedPane, ids); 1088 this._delegate.closeTabs(this._tabbedPane, ids);
1089 return; 1089 return;
1090 } 1090 }
1091 this._tabbedPane.closeTabs(ids, true); 1091 this._tabbedPane.closeTabs(ids, true);
1092 } 1092 }
1093 1093
1094 _tabContextMenu(event) { 1094 _tabContextMenu(event) {
1095 /** 1095 /**
1096 * @this {WebInspector.TabbedPaneTab} 1096 * @this {UI.TabbedPaneTab}
1097 */ 1097 */
1098 function close() { 1098 function close() {
1099 this._closeTabs([this.id]); 1099 this._closeTabs([this.id]);
1100 } 1100 }
1101 1101
1102 /** 1102 /**
1103 * @this {WebInspector.TabbedPaneTab} 1103 * @this {UI.TabbedPaneTab}
1104 */ 1104 */
1105 function closeOthers() { 1105 function closeOthers() {
1106 this._closeTabs(this._tabbedPane.otherTabs(this.id)); 1106 this._closeTabs(this._tabbedPane.otherTabs(this.id));
1107 } 1107 }
1108 1108
1109 /** 1109 /**
1110 * @this {WebInspector.TabbedPaneTab} 1110 * @this {UI.TabbedPaneTab}
1111 */ 1111 */
1112 function closeAll() { 1112 function closeAll() {
1113 this._closeTabs(this._tabbedPane.allTabs()); 1113 this._closeTabs(this._tabbedPane.allTabs());
1114 } 1114 }
1115 1115
1116 /** 1116 /**
1117 * @this {WebInspector.TabbedPaneTab} 1117 * @this {UI.TabbedPaneTab}
1118 */ 1118 */
1119 function closeToTheRight() { 1119 function closeToTheRight() {
1120 this._closeTabs(this._tabbedPane._tabsToTheRight(this.id)); 1120 this._closeTabs(this._tabbedPane._tabsToTheRight(this.id));
1121 } 1121 }
1122 1122
1123 var contextMenu = new WebInspector.ContextMenu(event); 1123 var contextMenu = new UI.ContextMenu(event);
1124 if (this._closeable) { 1124 if (this._closeable) {
1125 contextMenu.appendItem(WebInspector.UIString.capitalize('Close'), close.bi nd(this)); 1125 contextMenu.appendItem(Common.UIString.capitalize('Close'), close.bind(thi s));
1126 contextMenu.appendItem(WebInspector.UIString.capitalize('Close ^others'), closeOthers.bind(this)); 1126 contextMenu.appendItem(Common.UIString.capitalize('Close ^others'), closeO thers.bind(this));
1127 contextMenu.appendItem(WebInspector.UIString.capitalize('Close ^tabs to th e ^right'), closeToTheRight.bind(this)); 1127 contextMenu.appendItem(Common.UIString.capitalize('Close ^tabs to the ^rig ht'), closeToTheRight.bind(this));
1128 contextMenu.appendItem(WebInspector.UIString.capitalize('Close ^all'), clo seAll.bind(this)); 1128 contextMenu.appendItem(Common.UIString.capitalize('Close ^all'), closeAll. bind(this));
1129 } 1129 }
1130 if (this._delegate) 1130 if (this._delegate)
1131 this._delegate.onContextMenu(this.id, contextMenu); 1131 this._delegate.onContextMenu(this.id, contextMenu);
1132 contextMenu.show(); 1132 contextMenu.show();
1133 } 1133 }
1134 1134
1135 /** 1135 /**
1136 * @param {!Event} event 1136 * @param {!Event} event
1137 * @return {boolean} 1137 * @return {boolean}
1138 */ 1138 */
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 this._tabElement.classList.remove('dragging'); 1193 this._tabElement.classList.remove('dragging');
1194 this._tabElement.style.removeProperty('left'); 1194 this._tabElement.style.removeProperty('left');
1195 delete this._dragStartX; 1195 delete this._dragStartX;
1196 this._tabbedPane._updateTabSlider(); 1196 this._tabbedPane._updateTabSlider();
1197 } 1197 }
1198 }; 1198 };
1199 1199
1200 /** 1200 /**
1201 * @interface 1201 * @interface
1202 */ 1202 */
1203 WebInspector.TabbedPaneTabDelegate = function() {}; 1203 UI.TabbedPaneTabDelegate = function() {};
1204 1204
1205 WebInspector.TabbedPaneTabDelegate.prototype = { 1205 UI.TabbedPaneTabDelegate.prototype = {
1206 /** 1206 /**
1207 * @param {!WebInspector.TabbedPane} tabbedPane 1207 * @param {!UI.TabbedPane} tabbedPane
1208 * @param {!Array.<string>} ids 1208 * @param {!Array.<string>} ids
1209 */ 1209 */
1210 closeTabs: function(tabbedPane, ids) {}, 1210 closeTabs: function(tabbedPane, ids) {},
1211 1211
1212 /** 1212 /**
1213 * @param {string} tabId 1213 * @param {string} tabId
1214 * @param {!WebInspector.ContextMenu} contextMenu 1214 * @param {!UI.ContextMenu} contextMenu
1215 */ 1215 */
1216 onContextMenu: function(tabId, contextMenu) {} 1216 onContextMenu: function(tabId, contextMenu) {}
1217 }; 1217 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698