Changeset 126268 in webkit
- Timestamp:
- Aug 21, 2012 11:58:30 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r126266 r126268 1 2012-08-21 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: TabbedPane: measure tab widths in batches. 4 https://bugs.webkit.org/show_bug.cgi?id=94484 5 6 Reviewed by Vsevolod Vlasov. 7 8 * inspector/start-end-batch-update-expected.txt: Added. 9 * inspector/start-end-batch-update.html: Added. 10 * inspector/tabbed-pane-tabs-to-show.html: 11 1 12 2012-08-21 Dominic Cooney <dominicc@chromium.org> 2 13 -
trunk/LayoutTests/inspector/tabbed-pane-tabs-to-show.html
r103555 r126268 11 11 return title; 12 12 } 13 return { width: width, title: title, toString: toString };13 return { width: function() { return width; }, title: title, toString: toString }; 14 14 } 15 15 -
trunk/Source/WebCore/ChangeLog
r126262 r126268 1 2012-08-21 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: TabbedPane: measure tab widths in batches. 4 https://bugs.webkit.org/show_bug.cgi?id=94484 5 6 Reviewed by Vsevolod Vlasov. 7 8 - Introduces global batch update schema 9 - Migrates Toolbar and TabbedPane to the new schema 10 11 * inspector/front-end/ScriptsPanel.js: 12 (WebInspector.ScriptsPanel): 13 * inspector/front-end/TabbedPane.js: 14 (WebInspector.TabbedPane.prototype.appendTab): 15 (WebInspector.TabbedPane.prototype._updateTabElements): 16 (WebInspector.TabbedPane.prototype._innerUpdateTabElements): 17 (WebInspector.TabbedPane.prototype._updateWidths): 18 (WebInspector.TabbedPane.prototype._measureWidths): 19 (WebInspector.TabbedPaneTab): 20 (WebInspector.TabbedPaneTab.prototype.width): 21 (WebInspector.TabbedPaneTab.prototype.setWidth): 22 * inspector/front-end/Toolbar.js: 23 (WebInspector.Toolbar): 24 (WebInspector.Toolbar.prototype._updateDropdownButtonAndHideDropdown): 25 (WebInspector.Toolbar.prototype._innerUpdateDropdownButtonAndHideDropdown): 26 * inspector/front-end/UIUtils.js: 27 (WebInspector.startBatchUpdate): 28 (WebInspector.invokeOnceAfterBatchUpdate.get if): 29 (WebInspector.invokeOnceAfterBatchUpdate): 30 * inspector/front-end/inspector.js: 31 * inspector/front-end/utilities.js: 32 1 33 2012-08-21 Kentaro Hara <haraken@chromium.org> 2 34 -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r126162 r126268 186 186 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, this); 187 187 188 WebInspector.startBatchUpdate(); 188 189 var uiSourceCodes = this._workspace.uiSourceCodes(); 189 190 for (var i = 0; i < uiSourceCodes.length; ++i) 190 191 this._addUISourceCode(uiSourceCodes[i]); 192 WebInspector.endBatchUpdate(); 191 193 192 194 this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this); -
trunk/Source/WebCore/inspector/front-end/TabbedPane.js
r125005 r126268 102 102 appendTab: function(id, tabTitle, view, tabTooltip, userGesture) 103 103 { 104 var tab = new WebInspector.TabbedPaneTab(this, this._tabsElement,id, tabTitle, this._closeableTabs, view, tabTooltip);104 var tab = new WebInspector.TabbedPaneTab(this, id, tabTitle, this._closeableTabs, view, tabTooltip); 105 105 this._tabsById[id] = tab; 106 106 … … 255 255 _updateTabElements: function() 256 256 { 257 WebInspector.invokeOnceAfterBatchUpdate(this, this._innerUpdateTabElements); 258 }, 259 260 _innerUpdateTabElements: function() 261 { 257 262 if (!this.isShowing()) 258 263 return; … … 266 271 this._measureDropDownButton(); 267 272 268 if (this._shrinkableTabs) 269 this._updateWidths(); 270 273 this._updateWidths(); 271 274 this._updateTabsDropDown(); 272 275 }, … … 375 378 _updateWidths: function() 376 379 { 380 var measuredWidths = this._measureWidths(); 381 var maxWidth = this._shrinkableTabs ? this._calculateMaxWidth(measuredWidths.slice(), this._totalWidth()) : Number.MAX_VALUE; 382 383 var i = 0; 384 for (var tabId in this._tabs) { 385 var tab = this._tabs[tabId]; 386 tab.setWidth(Math.min(maxWidth, measuredWidths[i++])); 387 } 388 }, 389 390 _measureWidths: function() 391 { 392 // Add all elements to measure into this._tabsElement 393 var measuringTabElements = []; 394 for (var tabId in this._tabs) { 395 var tab = this._tabs[tabId]; 396 if (typeof tab._measuredWidth === "number") 397 continue; 398 var measuringTabElement = tab._createTabElement(true); 399 measuringTabElement.__tab = tab; 400 measuringTabElements.push(measuringTabElement); 401 this._tabsElement.appendChild(measuringTabElement); 402 } 403 404 // Perform measurement 405 for (var i = 0; i < measuringTabElements.length; ++i) 406 measuringTabElements[i].__tab._measuredWidth = measuringTabElements[i].getBoundingClientRect().width; 407 408 // Nuke elements from the UI 409 for (var i = 0; i < measuringTabElements.length; ++i) 410 measuringTabElements[i].parentElement.removeChild(measuringTabElements[i]); 411 412 // Combine the results. 377 413 var measuredWidths = []; 378 414 for (var tabId in this._tabs) 379 measuredWidths.push(this._tabs[tabId].measuredWidth); 380 381 var maxWidth = this._calculateMaxWidth(measuredWidths, this._totalWidth()); 382 383 for (var tabId in this._tabs) { 384 var tab = this._tabs[tabId]; 385 tab.width = Math.min(tab.measuredWidth, maxWidth); 386 } 415 measuredWidths.push(this._tabs[tabId]._measuredWidth); 416 417 return measuredWidths; 387 418 }, 388 419 … … 430 461 var totalTabsWidth = 0; 431 462 for (var i = 0; i < tabsHistory.length; ++i) { 432 totalTabsWidth += tabsHistory[i].width ;463 totalTabsWidth += tabsHistory[i].width(); 433 464 var minimalRequiredWidth = totalTabsWidth; 434 465 if (i !== tabsHistory.length - 1) … … 511 542 * @constructor 512 543 * @param {WebInspector.TabbedPane} tabbedPane 513 * @param {Element} measureElement514 544 * @param {string} id 515 545 * @param {string} title … … 518 548 * @param {string=} tooltip 519 549 */ 520 WebInspector.TabbedPaneTab = function(tabbedPane, measureElement,id, title, closeable, view, tooltip)550 WebInspector.TabbedPaneTab = function(tabbedPane, id, title, closeable, view, tooltip) 521 551 { 522 552 this._closeable = closeable; 523 553 this._tabbedPane = tabbedPane; 524 this._measureElement = measureElement;525 554 this._id = id; 526 555 this._title = title; … … 600 629 * @return {number} 601 630 */ 602 get measuredWidth() 603 { 604 if (typeof(this._measuredWidth) !== "undefined") 605 return this._measuredWidth; 606 607 this._measure(); 608 return this._measuredWidth; 609 }, 610 611 /** 612 * @return {number} 613 */ 614 get width() 615 { 616 return this._width || this.measuredWidth; 617 }, 618 619 set width(width) 631 width: function() 632 { 633 return this._width; 634 }, 635 636 /** 637 * @param {number} width 638 */ 639 setWidth: function(width) 620 640 { 621 641 this.tabElement.style.width = width + "px"; … … 658 678 }, 659 679 660 _measure: function()661 {662 var measuringTabElement = this._createTabElement(true);663 this._measureElement.appendChild(measuringTabElement);664 this._measuredWidth = measuringTabElement.getBoundingClientRect().width;665 this._measureElement.removeChild(measuringTabElement);666 },667 668 680 /** 669 681 * @param {Event} event -
trunk/Source/WebCore/inspector/front-end/Toolbar.js
r126001 r126268 43 43 document.getElementById("close-button-left").addEventListener("click", this._onClose, true); 44 44 document.getElementById("close-button-right").addEventListener("click", this._onClose, true); 45 this._coalescingLevel = 0;46 45 } 47 46 48 47 WebInspector.Toolbar.prototype = { 49 /**50 * @param {boolean} enabled51 */52 setCoalescingUpdate: function(enabled)53 {54 this._coalescingLevel += enabled ? 1 : -1;55 if (!this._coalescingLevel)56 this._updateDropdownButtonAndHideDropdown();57 },58 59 48 resize: function() 60 49 { … … 180 169 _updateDropdownButtonAndHideDropdown: function() 181 170 { 182 if (this._coalescingLevel) 183 return; 171 WebInspector.invokeOnceAfterBatchUpdate(this, this._innerUpdateDropdownButtonAndHideDropdown); 172 }, 173 174 _innerUpdateDropdownButtonAndHideDropdown: function() 175 { 184 176 this._setDropdownVisible(false); 185 177 -
trunk/Source/WebCore/inspector/front-end/UIUtils.js
r125882 r126268 1110 1110 } 1111 1111 1112 WebInspector._coalescingLevel = 0; 1113 1114 WebInspector.startBatchUpdate = function() 1115 { 1116 if (!WebInspector._coalescingLevel) 1117 WebInspector._postUpdateHandlers = new Map(); 1118 WebInspector._coalescingLevel++; 1119 } 1120 1121 WebInspector.endBatchUpdate = function() 1122 { 1123 if (--WebInspector._coalescingLevel) 1124 return; 1125 1126 var handlers = WebInspector._postUpdateHandlers; 1127 delete WebInspector._postUpdateHandlers; 1128 1129 var keys = handlers.keys(); 1130 for (var i = 0; i < keys.length; ++i) { 1131 var object = keys[i]; 1132 var methods = handlers.get(object).keys(); 1133 for (var j = 0; j < methods.length; ++j) 1134 methods[j].call(object); 1135 } 1136 } 1137 1138 /** 1139 * @param {Object} object 1140 * @param {function()} method 1141 */ 1142 WebInspector.invokeOnceAfterBatchUpdate = function(object, method) 1143 { 1144 if (!WebInspector._coalescingLevel) { 1145 method.call(object); 1146 return; 1147 } 1148 1149 var methods = WebInspector._postUpdateHandlers.get(object); 1150 if (!methods) { 1151 methods = new Map(); 1152 WebInspector._postUpdateHandlers.put(object, methods); 1153 } 1154 methods.put(method); 1155 } 1156 1112 1157 ;(function() { 1113 1158 -
trunk/Source/WebCore/inspector/front-end/inspector.js
r126215 r126268 528 528 529 529 this.toolbar = new WebInspector.Toolbar(); 530 this.toolbar.setCoalescingUpdate(true);530 WebInspector.startBatchUpdate(); 531 531 var panelDescriptors = this._panelDescriptors(); 532 532 for (var i = 0; i < panelDescriptors.length; ++i) 533 533 WebInspector.inspectorView.addPanel(panelDescriptors[i]); 534 this.toolbar.setCoalescingUpdate(false);534 WebInspector.endBatchUpdate(); 535 535 536 536 this.addMainEventListeners(document); -
trunk/Source/WebCore/inspector/front-end/utilities.js
r126215 r126268 691 691 key.__identifier = objectIdentifier; 692 692 } 693 this._map[objectIdentifier] = value;693 this._map[objectIdentifier] = [key, value]; 694 694 }, 695 695 696 696 /** 697 697 * @param {Object} key 698 * @return {Object} value699 698 */ 700 699 remove: function(key) … … 702 701 var result = this._map[key.__identifier]; 703 702 delete this._map[key.__identifier]; 704 return result; 705 }, 706 703 return result ? result[1] : undefined; 704 }, 705 706 /** 707 * @return {Array.<Object>} 708 */ 709 keys: function() 710 { 711 return this._list(0); 712 }, 713 707 714 values: function() 715 { 716 return this._list(1); 717 }, 718 719 /** 720 * @param {number} index 721 */ 722 _list: function(index) 708 723 { 709 724 var result = []; 710 725 for (var objectIdentifier in this._map) 711 result.push(this._map[objectIdentifier] );726 result.push(this._map[objectIdentifier][index]); 712 727 return result; 713 728 }, 714 729 715 730 /** 716 731 * @param {Object} key … … 718 733 get: function(key) 719 734 { 720 return this._map[key.__identifier]; 735 var entry = this._map[key.__identifier]; 736 return entry ? entry[1] : undefined; 721 737 }, 722 738 … … 725 741 this._map = {}; 726 742 } 727 }; 728 743 } 729 744 /** 730 745 * @param {string} url
Note: See TracChangeset
for help on using the changeset viewer.