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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 { | 201 { |
202 isCloseable = typeof isCloseable === "boolean" ? isCloseable : this._clo
seableTabs; | 202 isCloseable = typeof isCloseable === "boolean" ? isCloseable : this._clo
seableTabs; |
203 var tab = new WebInspector.TabbedPaneTab(this, id, tabTitle, isCloseable
, view, tabTooltip); | 203 var tab = new WebInspector.TabbedPaneTab(this, id, tabTitle, isCloseable
, view, tabTooltip); |
204 tab.setDelegate(this._delegate); | 204 tab.setDelegate(this._delegate); |
205 this._tabsById[id] = tab; | 205 this._tabsById[id] = tab; |
206 if (index !== undefined) | 206 if (index !== undefined) |
207 this._tabs.splice(index, 0, tab); | 207 this._tabs.splice(index, 0, tab); |
208 else | 208 else |
209 this._tabs.push(tab); | 209 this._tabs.push(tab); |
210 this._tabsHistory.push(tab); | 210 this._tabsHistory.push(tab); |
211 view.attach(this.element); | |
212 if (this._tabsHistory[0] === tab && this.isShowing()) | 211 if (this._tabsHistory[0] === tab && this.isShowing()) |
213 this.selectTab(tab.id, userGesture); | 212 this.selectTab(tab.id, userGesture); |
214 this._updateTabElements(); | 213 this._updateTabElements(); |
215 }, | 214 }, |
216 | 215 |
217 /** | 216 /** |
218 * @param {string} id | 217 * @param {string} id |
219 * @param {boolean=} userGesture | 218 * @param {boolean=} userGesture |
220 */ | 219 */ |
221 closeTab: function(id, userGesture) | 220 closeTab: function(id, userGesture) |
(...skipping 30 matching lines...) Expand all Loading... |
252 if (this._currentTab && this._currentTab.id === id) | 251 if (this._currentTab && this._currentTab.id === id) |
253 this._hideCurrentTab(); | 252 this._hideCurrentTab(); |
254 | 253 |
255 var tab = this._tabsById[id]; | 254 var tab = this._tabsById[id]; |
256 delete this._tabsById[id]; | 255 delete this._tabsById[id]; |
257 | 256 |
258 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1); | 257 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1); |
259 this._tabs.splice(this._tabs.indexOf(tab), 1); | 258 this._tabs.splice(this._tabs.indexOf(tab), 1); |
260 if (tab._shown) | 259 if (tab._shown) |
261 this._hideTabElement(tab); | 260 this._hideTabElement(tab); |
262 tab.view.detach(); | |
263 | 261 |
264 var eventData = { tabId: id, view: tab.view, isUserGesture: userGesture
}; | 262 var eventData = { tabId: id, view: tab.view, isUserGesture: userGesture
}; |
265 this.dispatchEventToListeners(WebInspector.TabbedPane.EventTypes.TabClos
ed, eventData); | 263 this.dispatchEventToListeners(WebInspector.TabbedPane.EventTypes.TabClos
ed, eventData); |
266 return true; | 264 return true; |
267 }, | 265 }, |
268 | 266 |
269 /** | 267 /** |
270 * @param {string} tabId | 268 * @param {string} tabId |
271 * @return {boolean} | 269 * @return {boolean} |
272 */ | 270 */ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 { | 322 { |
325 if (this._currentTabLocked) | 323 if (this._currentTabLocked) |
326 return false; | 324 return false; |
327 var focused = this.hasFocus(); | 325 var focused = this.hasFocus(); |
328 var tab = this._tabsById[id]; | 326 var tab = this._tabsById[id]; |
329 if (!tab) | 327 if (!tab) |
330 return false; | 328 return false; |
331 if (this._currentTab && this._currentTab.id === id) | 329 if (this._currentTab && this._currentTab.id === id) |
332 return true; | 330 return true; |
333 | 331 |
334 this.suspendInvalidations(); | |
335 this._hideCurrentTab(); | 332 this._hideCurrentTab(); |
336 this._showTab(tab); | 333 this._showTab(tab); |
337 this.resumeInvalidations(); | |
338 this._currentTab = tab; | 334 this._currentTab = tab; |
339 | 335 |
340 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1); | 336 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1); |
341 this._tabsHistory.splice(0, 0, tab); | 337 this._tabsHistory.splice(0, 0, tab); |
342 | 338 |
343 this._updateTabElements(); | 339 this._updateTabElements(); |
344 if (focused) | 340 if (focused) |
345 this.focus(); | 341 this.focus(); |
346 | 342 |
347 var eventData = { tabId: id, view: tab.view, isUserGesture: userGesture
}; | 343 var eventData = { tabId: id, view: tab.view, isUserGesture: userGesture
}; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 this._updateTabElements(); | 416 this._updateTabElements(); |
421 }, | 417 }, |
422 | 418 |
423 /** | 419 /** |
424 * @param {string} id | 420 * @param {string} id |
425 * @param {!WebInspector.Widget} view | 421 * @param {!WebInspector.Widget} view |
426 */ | 422 */ |
427 changeTabView: function(id, view) | 423 changeTabView: function(id, view) |
428 { | 424 { |
429 var tab = this._tabsById[id]; | 425 var tab = this._tabsById[id]; |
430 if (tab.view === view) | 426 if (this._currentTab && this._currentTab.id === tab.id) { |
431 return; | 427 if (tab.view !== view) |
432 | 428 this._hideTab(tab); |
433 this.suspendInvalidations(); | 429 tab.view = view; |
434 var isSelected = this._currentTab && this._currentTab.id === id; | |
435 if (isSelected) | |
436 this._hideTab(tab); | |
437 tab.view.detach(); | |
438 tab.view = view; | |
439 tab.view.attach(this.element); | |
440 if (isSelected) | |
441 this._showTab(tab); | 430 this._showTab(tab); |
442 this.resumeInvalidations(); | 431 } else |
| 432 tab.view = view; |
443 }, | 433 }, |
444 | 434 |
445 onResize: function() | 435 onResize: function() |
446 { | 436 { |
447 this._updateTabElements(); | 437 this._updateTabElements(); |
448 }, | 438 }, |
449 | 439 |
450 headerResized: function() | 440 headerResized: function() |
451 { | 441 { |
452 this._updateTabElements(); | 442 this._updateTabElements(); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 this._hideTab(this._currentTab); | 752 this._hideTab(this._currentTab); |
763 delete this._currentTab; | 753 delete this._currentTab; |
764 }, | 754 }, |
765 | 755 |
766 /** | 756 /** |
767 * @param {!WebInspector.TabbedPaneTab} tab | 757 * @param {!WebInspector.TabbedPaneTab} tab |
768 */ | 758 */ |
769 _showTab: function(tab) | 759 _showTab: function(tab) |
770 { | 760 { |
771 tab.tabElement.classList.add("selected"); | 761 tab.tabElement.classList.add("selected"); |
772 tab.view.showWidget(); | 762 tab.view.show(this.element); |
773 this._updateTabSlider(); | 763 this._updateTabSlider(); |
774 }, | 764 }, |
775 | 765 |
776 _updateTabSlider: function() | 766 _updateTabSlider: function() |
777 { | 767 { |
778 if (!this._currentTab || !this._sliderEnabled) | 768 if (!this._currentTab || !this._sliderEnabled) |
779 return; | 769 return; |
780 var left = 0; | 770 var left = 0; |
781 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs
[i] && this._tabs[i]._shown; i++) | 771 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs
[i] && this._tabs[i]._shown; i++) |
782 left += this._tabs[i]._measuredWidth; | 772 left += this._tabs[i]._measuredWidth; |
783 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWi
dth : this._dropDownButton.offsetWidth; | 773 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWi
dth : this._dropDownButton.offsetWidth; |
784 var scaleFactor = window.devicePixelRatio >= 1.5 ? " scaleY(0.75)" : ""; | 774 var scaleFactor = window.devicePixelRatio >= 1.5 ? " scaleY(0.75)" : ""; |
785 this._tabSlider.style.transform = "translateX(" + left + "px)" + scaleFa
ctor; | 775 this._tabSlider.style.transform = "translateX(" + left + "px)" + scaleFa
ctor; |
786 this._tabSlider.style.width = sliderWidth + "px"; | 776 this._tabSlider.style.width = sliderWidth + "px"; |
787 | 777 |
788 if (this._tabSlider.parentElement !== this._headerContentsElement) | 778 if (this._tabSlider.parentElement !== this._headerContentsElement) |
789 this._headerContentsElement.appendChild(this._tabSlider); | 779 this._headerContentsElement.appendChild(this._tabSlider); |
790 }, | 780 }, |
791 | 781 |
792 /** | 782 /** |
793 * @param {!WebInspector.TabbedPaneTab} tab | 783 * @param {!WebInspector.TabbedPaneTab} tab |
794 */ | 784 */ |
795 _hideTab: function(tab) | 785 _hideTab: function(tab) |
796 { | 786 { |
797 tab.tabElement.classList.remove("selected"); | 787 tab.tabElement.classList.remove("selected"); |
798 tab.view.hideWidget(); | 788 tab.view.detach(); |
799 }, | 789 }, |
800 | 790 |
801 /** | 791 /** |
802 * @override | 792 * @override |
803 * @return {!Array.<!Element>} | 793 * @return {!Array.<!Element>} |
804 */ | 794 */ |
805 elementsToRestoreScrollPositionsFor: function() | 795 elementsToRestoreScrollPositionsFor: function() |
806 { | 796 { |
807 return [ this._contentElement ]; | 797 return [ this._contentElement ]; |
808 }, | 798 }, |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 if (this._viewCallback && view) | 1423 if (this._viewCallback && view) |
1434 this._viewCallback(id, view); | 1424 this._viewCallback(id, view); |
1435 var shouldFocus = this._tabbedPane.visibleView.element.isSelfOrAnces
tor(WebInspector.currentFocusElement()); | 1425 var shouldFocus = this._tabbedPane.visibleView.element.isSelfOrAnces
tor(WebInspector.currentFocusElement()); |
1436 this._tabbedPane.changeTabView(id, view); | 1426 this._tabbedPane.changeTabView(id, view); |
1437 if (shouldFocus) | 1427 if (shouldFocus) |
1438 view.focus(); | 1428 view.focus(); |
1439 return view; | 1429 return view; |
1440 } | 1430 } |
1441 } | 1431 } |
1442 } | 1432 } |
OLD | NEW |