| 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 this._headerContentsElement.removeChild(this._dropDownButton); | 617 this._headerContentsElement.removeChild(this._dropDownButton); |
| 618 this._dropDownButton.classList.remove("measuring"); | 618 this._dropDownButton.classList.remove("measuring"); |
| 619 }, | 619 }, |
| 620 | 620 |
| 621 _updateWidths: function() | 621 _updateWidths: function() |
| 622 { | 622 { |
| 623 var measuredWidths = this._measureWidths(); | 623 var measuredWidths = this._measureWidths(); |
| 624 var maxWidth = this._shrinkableTabs ? this._calculateMaxWidth(measuredWi
dths.slice(), this._totalWidth()) : Number.MAX_VALUE; | 624 var maxWidth = this._shrinkableTabs ? this._calculateMaxWidth(measuredWi
dths.slice(), this._totalWidth()) : Number.MAX_VALUE; |
| 625 | 625 |
| 626 var i = 0; | 626 var i = 0; |
| 627 for (var tabId in this._tabs) { | 627 for (var tab of this._tabs) |
| 628 var tab = this._tabs[tabId]; | |
| 629 tab.setWidth(this._verticalTabLayout ? -1 : Math.min(maxWidth, measu
redWidths[i++])); | 628 tab.setWidth(this._verticalTabLayout ? -1 : Math.min(maxWidth, measu
redWidths[i++])); |
| 630 } | |
| 631 }, | 629 }, |
| 632 | 630 |
| 633 _measureWidths: function() | 631 _measureWidths: function() |
| 634 { | 632 { |
| 635 // Add all elements to measure into this._tabsElement | 633 // Add all elements to measure into this._tabsElement |
| 636 this._tabsElement.style.setProperty("width", "2000px"); | 634 this._tabsElement.style.setProperty("width", "2000px"); |
| 637 var measuringTabElements = []; | 635 var measuringTabElements = []; |
| 638 for (var tabId in this._tabs) { | 636 for (var tab of this._tabs) { |
| 639 var tab = this._tabs[tabId]; | |
| 640 if (typeof tab._measuredWidth === "number") | 637 if (typeof tab._measuredWidth === "number") |
| 641 continue; | 638 continue; |
| 642 var measuringTabElement = tab._createTabElement(true); | 639 var measuringTabElement = tab._createTabElement(true); |
| 643 measuringTabElement.__tab = tab; | 640 measuringTabElement.__tab = tab; |
| 644 measuringTabElements.push(measuringTabElement); | 641 measuringTabElements.push(measuringTabElement); |
| 645 this._tabsElement.appendChild(measuringTabElement); | 642 this._tabsElement.appendChild(measuringTabElement); |
| 646 } | 643 } |
| 647 | 644 |
| 648 // Perform measurement | 645 // Perform measurement |
| 649 for (var i = 0; i < measuringTabElements.length; ++i) { | 646 for (var i = 0; i < measuringTabElements.length; ++i) { |
| 650 var width = measuringTabElements[i].getBoundingClientRect().width; | 647 var width = measuringTabElements[i].getBoundingClientRect().width; |
| 651 measuringTabElements[i].__tab._measuredWidth = Math.ceil(width); | 648 measuringTabElements[i].__tab._measuredWidth = Math.ceil(width); |
| 652 } | 649 } |
| 653 | 650 |
| 654 // Nuke elements from the UI | 651 // Nuke elements from the UI |
| 655 for (var i = 0; i < measuringTabElements.length; ++i) | 652 for (var i = 0; i < measuringTabElements.length; ++i) |
| 656 measuringTabElements[i].remove(); | 653 measuringTabElements[i].remove(); |
| 657 | 654 |
| 658 // Combine the results. | 655 // Combine the results. |
| 659 var measuredWidths = []; | 656 var measuredWidths = []; |
| 660 for (var tabId in this._tabs) | 657 for (var tab of this._tabs) |
| 661 measuredWidths.push(this._tabs[tabId]._measuredWidth); | 658 measuredWidths.push(tab._measuredWidth); |
| 662 this._tabsElement.style.removeProperty("width"); | 659 this._tabsElement.style.removeProperty("width"); |
| 663 | 660 |
| 664 return measuredWidths; | 661 return measuredWidths; |
| 665 }, | 662 }, |
| 666 | 663 |
| 667 /** | 664 /** |
| 668 * @param {!Array.<number>} measuredWidths | 665 * @param {!Array.<number>} measuredWidths |
| 669 * @param {number} totalWidth | 666 * @param {number} totalWidth |
| 670 */ | 667 */ |
| 671 _calculateMaxWidth: function(measuredWidths, totalWidth) | 668 _calculateMaxWidth: function(measuredWidths, totalWidth) |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 if (this._viewCallback && view) | 1411 if (this._viewCallback && view) |
| 1415 this._viewCallback(id, view); | 1412 this._viewCallback(id, view); |
| 1416 var shouldFocus = this._tabbedPane.visibleView.element.isSelfOrAnces
tor(WebInspector.currentFocusElement()); | 1413 var shouldFocus = this._tabbedPane.visibleView.element.isSelfOrAnces
tor(WebInspector.currentFocusElement()); |
| 1417 this._tabbedPane.changeTabView(id, view); | 1414 this._tabbedPane.changeTabView(id, view); |
| 1418 if (shouldFocus) | 1415 if (shouldFocus) |
| 1419 view.focus(); | 1416 view.focus(); |
| 1420 return view; | 1417 return view; |
| 1421 } | 1418 } |
| 1422 } | 1419 } |
| 1423 } | 1420 } |
| OLD | NEW |