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