Changeset 112528 in webkit
- Timestamp:
- Mar 29, 2012 6:44:43 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r112527 r112528 1 2012-03-29 Andrey Kosyakov <caseq@chromium.org> 2 3 Web Inspector: use canvas to render bars in "vertical overview" mode 4 https://bugs.webkit.org/show_bug.cgi?id=82606 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/front-end/TimelineOverviewPane.js: Use canvas instead of DOM for rendering vertical overview bars. 9 (WebInspector.TimelineVerticalOverview): 10 (WebInspector.TimelineVerticalOverview.prototype.update): 11 (WebInspector.TimelineVerticalOverview.prototype._renderBars): 12 (WebInspector.TimelineVerticalOverview.prototype._renderBar): 13 (WebInspector.TimelineVerticalOverview.prototype.getWindowTimes): 14 * inspector/front-end/timelinePanel.css: Drop styles previously used for DOM-based vertical overview rendering. 15 (.timeline-vertical-overview-bars): 16 1 17 2012-03-29 Andrey Kosyakov <caseq@chromium.org> 2 18 -
trunk/Source/WebCore/inspector/front-end/TimelineOverviewPane.js
r112527 r112528 801 801 WebInspector.TimelineVerticalOverview = function(model) { 802 802 WebInspector.View.call(this); 803 this.element = document.createElement(" div");803 this.element = document.createElement("canvas"); 804 804 this.element.className = "timeline-vertical-overview-bars fill"; 805 this._model = model; 805 806 this.reset(); 806 this._model = model; 807 808 this._maxInnerBarWidth = 10; 809 this._context = this.element.getContext("2d"); 810 this._fillStyles = {}; 811 this._fillStyles.loading = this._context.createLinearGradient(0, 0, this._maxInnerBarWidth, 0); 812 this._fillStyles.loading.addColorStop(0, "rgb(201, 220, 245)"); 813 this._fillStyles.loading.addColorStop(1, "rgb(109, 157, 222)"); 814 this._fillStyles.scripting = this._context.createLinearGradient(0, 0, this._maxInnerBarWidth, 0); 815 this._fillStyles.scripting.addColorStop(0, "rgb(251, 222, 168)"); 816 this._fillStyles.scripting.addColorStop(1, "rgb(234, 182, 77)"); 817 this._fillStyles.rendering = this._context.createLinearGradient(0, 0, this._maxInnerBarWidth, 0); 818 this._fillStyles.rendering.addColorStop(0, "rgb(213, 185, 236)"); 819 this._fillStyles.rendering.addColorStop(1, "rgb(137, 62, 200)"); 820 821 this._borderStyles = {}; 822 this._borderStyles.loading = "rgb(106, 152, 213)"; 823 this._borderStyles.scripting = "rgb(223, 175, 77)"; 824 this._borderStyles.rendering = "rgb(130, 59, 190)"; 807 825 } 808 826 … … 835 853 this._recordsPerBar = Math.max(1, recordCount * minBarWidth / this.element.clientWidth); 836 854 var numberOfBars = Math.ceil(recordCount / this._recordsPerBar); 837 838 855 this._barTimes = []; 839 856 this._longestBarTime = 0; 840 this.element.removeChildren(); 841 var padding = this.element.createChild("div", "padding"); 842 843 var statistics = frameCount ? this._aggregateFrames(records, numberOfBars) : this._aggregateRecords(records, numberOfBars); 857 var barHeights = frameCount ? this._aggregateFrames(records, numberOfBars) : this._aggregateRecords(records, numberOfBars); 858 844 859 const paddingTop = 4; 845 860 var scale = (this.element.clientHeight - paddingTop) / this._longestBarTime; 846 861 847 for (var i = 0; i < statistics.length; ++i) 848 this.element.insertBefore(this._buildBar(statistics[i], scale), padding); 862 this._renderBars(barHeights, scale); 849 863 }, 850 864 … … 953 967 }, 954 968 955 _buildBar: function(statistics, scale) 956 { 957 var outer = document.createElement("div"); 958 outer.className = "timeline-bar-vertical"; 959 var categories = Object.keys(statistics); 960 for (var i = 0; i < categories.length; ++i) { 969 _renderBars: function(allBarHeights, scale) 970 { 971 // Use real world, 1:1 coordinates in canvas. This will also take care of clearing it. 972 this.element.width = this.element.clientWidth; 973 this.element.height = this.element.clientHeight; 974 975 const maxPadding = 5; 976 this._actualBarWidth = Math.min((this.element.width - 2 * maxPadding) / allBarHeights.length, this._maxInnerBarWidth + maxPadding); 977 var padding = Math.min(Math.floor(this._actualBarWidth / 3), maxPadding); 978 979 for (var i = 0; i < allBarHeights.length; ++i) 980 this._renderBar(maxPadding + this._actualBarWidth * i, this._actualBarWidth - padding , allBarHeights[i], scale); 981 }, 982 983 _renderBar: function(left, width, barHeights, scale) 984 { 985 var categories = Object.keys(barHeights); 986 if (!categories.length) 987 return; 988 for (var i = 0, bottomOffset = this.element.height; i < categories.length; ++i) { 961 989 var category = categories[i]; 962 var duration = statistics[category]; 990 var duration = barHeights[category]; 991 963 992 if (!duration) 964 993 continue; 965 var bar = outer.createChild("div", "timeline-" + category); 966 bar.style.height = (statistics[category] * scale) + "px"; 967 } 968 return outer; 994 var height = duration * scale; 995 996 this._context.save(); 997 this._context.translate(Math.floor(left) + 0.5, 0); 998 this._context.scale(width / this._maxInnerBarWidth, 1); 999 this._context.fillStyle = this._fillStyles[category]; 1000 this._context.fillRect(0, bottomOffset - height, this._maxInnerBarWidth, height); 1001 this._context.restore(); 1002 1003 this._context.strokeStyle = this._borderStyles[category]; 1004 this._context.strokeRect(Math.floor(left) + 0.5, Math.floor(bottomOffset - height) + 0.5, Math.floor(width), Math.floor(height)); 1005 bottomOffset -= height - 1; 1006 } 969 1007 }, 970 1008 … … 975 1013 var rightOffset = windowRight * windowSpan; 976 1014 var bars = this.element.children; 977 var offset0 = bars[0] ? bars[0].offsetLeft : 4; 978 var barWidth = 9; 979 if (bars.length > 2) { 980 var offset1 = bars[bars.length - 2].offsetLeft; 981 barWidth = (offset1 - offset0) / (bars.length - 2); 982 } 983 var firstBar = Math.floor(Math.max(leftOffset - offset0, 0) / barWidth); 984 var lastBar = Math.min(Math.ceil((rightOffset - offset0 - 2) / barWidth), this._barTimes.length - 1); 1015 var firstBar = Math.floor(Math.max(leftOffset, 0) / this._actualBarWidth); 1016 var lastBar = Math.min(Math.ceil((rightOffset - 2) / this._actualBarWidth), this._barTimes.length - 1); 985 1017 const snapToRightTolerancePixels = 3; 986 1018 return { -
trunk/Source/WebCore/inspector/front-end/timelinePanel.css
r109898 r112528 587 587 588 588 .timeline-vertical-overview-bars { 589 display: -webkit-box;590 -webkit-box-align: end;591 background-color: white;592 padding-left: 4px;593 padding-right: 4px;594 589 z-index: 200; 595 590 background-color: rgba(255, 255, 255, 0.8); 596 } 597 598 .timeline-vertical-overview-bars .padding { 599 -webkit-box-flex: 100000; 600 } 601 602 .timeline-vertical-overview-bars .timeline-bar-vertical { 603 display: -webkit-box; 604 -webkit-box-orient: vertical; 605 -webkit-box-pack: end; 606 width: 12px; 607 padding-right: 2px; 608 -webkit-box-flex: 1; 609 } 610 611 .timeline-bar-vertical div:first-child { 612 -webkit-border-top-left-radius: 2px; 613 -webkit-border-top-right-radius: 2px; 614 } 615 616 .timeline-bar-vertical .timeline-loading { 617 background: -webkit-linear-gradient(left, rgb(201, 220, 245), rgb(109, 157, 222)); 618 border: solid 1px rgb(106, 152, 213); 619 } 620 621 .timeline-bar-vertical .timeline-scripting { 622 background: -webkit-linear-gradient(left, rgb(251, 222, 168), rgb(234, 182, 77)); 623 border: solid 1px rgb(223, 175, 77); 624 } 625 626 .timeline-bar-vertical .timeline-rendering { 627 background: -webkit-linear-gradient(left, rgb(213, 185, 236), rgb(137, 62, 200)); 628 border: solid 1px rgb(130, 59, 190); 591 width: 100%; 592 height: 100%; 629 593 } 630 594
Note: See TracChangeset
for help on using the changeset viewer.