Changeset 55466 in webkit
- Timestamp:
- Mar 3, 2010 10:20:11 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r55465 r55466 1 2010-03-03 Alexander Pavlov <apavlov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: resources panel only shows uncompressed resource size. 6 https://bugs.webkit.org/show_bug.cgi?id=35403 7 8 * English.lproj/localizedStrings.js: 9 * inspector/InspectorResource.cpp: 10 (WebCore::InspectorResource::updateScriptObject): 11 * inspector/front-end/AbstractTimelinePanel.js: 12 (WebInspector.AbstractTimelinePanel.prototype.refresh): 13 * inspector/front-end/AuditRules.js: 14 (WebInspector.AuditRules.GzipRule.prototype.doRun): 15 (WebInspector.AuditRules.GzipRule.prototype._shouldCompress): 16 * inspector/front-end/ImageView.js: 17 (WebInspector.ImageView): 18 * inspector/front-end/Resource.js: 19 (WebInspector.Resource.prototype.get resourceSize): 20 (WebInspector.Resource.prototype.set resourceSize): 21 (WebInspector.Resource.prototype.get transferSize): 22 (WebInspector.Resource.CompareBySize): 23 (WebInspector.Resource.CompareByTransferSize): 24 * inspector/front-end/ResourcesPanel.js: 25 (WebInspector.ResourcesPanel.prototype.populateSidebar): 26 (WebInspector.ResourceTimeCalculator.prototype.computeBarGraphLabels): 27 (WebInspector.ResourceTransferSizeCalculator.prototype.computeBarGraphLabels): 28 (WebInspector.ResourceTransferSizeCalculator.prototype.computeBarGraphPercentages): 29 (WebInspector.ResourceTransferSizeCalculator.prototype._value): 30 (WebInspector.ResourceTransferSizeCalculator.prototype._networkBytes): 31 (WebInspector.ResourceSidebarTreeElement.CompareByDescendingTransferSize): 32 (WebInspector.ResourceGraph.prototype.refreshLabelPositions): 33 (WebInspector.ResourceGraph.prototype.refresh): 34 * inspector/front-end/inspector.css: 35 * inspector/front-end/inspector.js: 36 (WebInspector.updateResource): 37 1 38 2010-03-03 Dan Bernstein <mitz@apple.com> 2 39 -
trunk/WebCore/inspector/InspectorResource.cpp
r54343 r55466 181 181 182 182 if (m_changes.hasChange(LengthChange)) { 183 jsonObject.set(" contentLength", m_length);183 jsonObject.set("resourceSize", m_length); 184 184 jsonObject.set("didLengthChange", true); 185 185 } -
trunk/WebCore/inspector/front-end/AbstractTimelinePanel.js
r53545 r55466 309 309 } 310 310 311 312 const isBarOpaqueAtLeft = this.sidebarTree.selectedTreeElement && this.sidebarTree.selectedTreeElement.isBarOpaqueAtLeft; 311 313 for (var i = 0; i < staleItemsLength; ++i) 312 this._staleItems[i]._itemsTreeElement._itemGraph.refresh(this.calculator );314 this._staleItems[i]._itemsTreeElement._itemGraph.refresh(this.calculator, isBarOpaqueAtLeft); 313 315 314 316 this._staleItems = []; -
trunk/WebCore/inspector/front-end/AuditRules.js
r54591 r55466 108 108 var resource = resources[i]; 109 109 if (this._shouldCompress(resource)) { 110 var size = resource. contentLength;110 var size = resource.resourceSize; 111 111 candidateSize += size; 112 112 if (this._isCompressed(resource)) { … … 146 146 _shouldCompress: function(resource) 147 147 { 148 return WebInspector.Resource.Type.isTextType(resource.type) && resource.domain && resource. contentLength !== undefined && resource.contentLength> 150;148 return WebInspector.Resource.Type.isTextType(resource.type) && resource.domain && resource.resourceSize !== undefined && resource.resourceSize > 150; 149 149 } 150 150 } -
trunk/WebCore/inspector/front-end/ImageView.js
r48646 r55466 57 57 var imageProperties = [ 58 58 { name: WebInspector.UIString("Dimensions"), value: WebInspector.UIString("%d × %d", this.imagePreviewElement.naturalWidth, this.imagePreviewElement.height) }, 59 { name: WebInspector.UIString("File size"), value: Number.bytesToString(this.resource. contentLength, WebInspector.UIString.bind(WebInspector)) },59 { name: WebInspector.UIString("File size"), value: Number.bytesToString(this.resource.resourceSize, WebInspector.UIString.bind(WebInspector)) }, 60 60 { name: WebInspector.UIString("MIME type"), value: this.resource.mimeType } 61 61 ]; -
trunk/WebCore/inspector/front-end/Resource.js
r53405 r55466 273 273 }, 274 274 275 get contentLength()276 { 277 return this._ contentLength|| 0;278 }, 279 280 set contentLength(x)281 { 282 if (this._ contentLength=== x)283 return; 284 285 this._ contentLength= x;275 get resourceSize() 276 { 277 return this._resourceSize || 0; 278 }, 279 280 set resourceSize(x) 281 { 282 if (this._resourceSize === x) 283 return; 284 285 this._resourceSize = x; 286 286 287 287 if (WebInspector.panels.resources) 288 288 WebInspector.panels.resources.refreshResource(this); 289 }, 290 291 get transferSize() 292 { 293 // FIXME: this is wrong for chunked-encoding resources. 294 return this.cached ? 0 : Number(this.responseHeaders["Content-Length"] || this.resourceSize || 0); 289 295 }, 290 296 … … 604 610 WebInspector.Resource.CompareBySize = function(a, b) 605 611 { 606 return a.contentLength - b.contentLength; 607 } 612 return a.resourceSize - b.resourceSize; 613 } 614 615 WebInspector.Resource.CompareByTransferSize = function(a, b) 616 { 617 return a.transferSize - b.transferSize; 618 } 619 608 620 609 621 WebInspector.Resource.StatusTextForCode = function(code) -
trunk/WebCore/inspector/front-end/ResourcesPanel.js
r55231 r55466 99 99 ]; 100 100 101 timeGraphItem.isBarOpaqueAtLeft = false; 101 102 timeGraphItem.selectedSortingOptionIndex = 1; 102 103 … … 106 107 var transferSizeCalculator = new WebInspector.ResourceTransferSizeCalculator(); 107 108 sizeGraphItem.sortingOptions = [ 109 { name: WebInspector.UIString("Sort by Transfer Size"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingTransferSize, calculator: transferSizeCalculator }, 108 110 { name: WebInspector.UIString("Sort by Size"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingSize, calculator: transferSizeCalculator }, 109 111 ]; 110 112 113 sizeGraphItem.isBarOpaqueAtLeft = true; 111 114 sizeGraphItem.selectedSortingOptionIndex = 0; 112 115 … … 827 830 computeBarGraphLabels: function(resource) 828 831 { 829 var leftLabel = "";830 if (resource.latency > 0)831 leftLabel = this.formatValue(resource.latency);832 833 832 var rightLabel = ""; 834 833 if (resource.responseReceivedTime !== -1 && resource.endTime !== -1) 835 834 rightLabel = this.formatValue(resource.endTime - resource.responseReceivedTime); 836 835 837 if (leftLabel && rightLabel) { 836 var hasLatency = resource.latency > 0; 837 if (hasLatency) 838 var leftLabel = this.formatValue(resource.latency); 839 else 840 var leftLabel = rightLabel; 841 842 if (hasLatency && rightLabel) { 838 843 var total = this.formatValue(resource.duration); 839 844 var tooltip = WebInspector.UIString("%s latency, %s download (%s total)", leftLabel, rightLabel, total); 840 } else if ( leftLabel)845 } else if (hasLatency) 841 846 var tooltip = WebInspector.UIString("%s latency", leftLabel); 842 847 else if (rightLabel) … … 942 947 computeBarGraphLabels: function(resource) 943 948 { 944 const label = this.formatValue(this._value(resource)); 945 var tooltip = label; 949 var networkBytes = this._networkBytes(resource); 950 var resourceBytes = this._value(resource); 951 if (networkBytes && networkBytes !== resourceBytes) { 952 // Transferred size is not the same as reported resource length. 953 var networkBytesString = this.formatValue(networkBytes); 954 var left = networkBytesString; 955 var right = this.formatValue(resourceBytes); 956 var tooltip = right ? WebInspector.UIString("%s (%s transferred)", right, networkBytesString) : right; 957 } else { 958 var left = this.formatValue(resourceBytes); 959 var right = left; 960 var tooltip = left; 961 } 946 962 if (resource.cached) 947 963 tooltip = WebInspector.UIString("%s (from cache)", tooltip); 948 return {left: label, right: label, tooltip: tooltip}; 964 return {left: left, right: right, tooltip: tooltip}; 965 }, 966 967 computeBarGraphPercentages: function(item) 968 { 969 const resourceBytesAsPercent = (this._value(item) / this.boundarySpan) * 100; 970 const networkBytesAsPercent = this._networkBytes(item) ? (this._networkBytes(item) / this.boundarySpan) * 100 : resourceBytesAsPercent; 971 return {start: 0, middle: networkBytesAsPercent, end: resourceBytesAsPercent}; 949 972 }, 950 973 951 974 _value: function(resource) 952 975 { 953 return resource.contentLength; 976 return resource.resourceSize; 977 }, 978 979 _networkBytes: function(resource) 980 { 981 return resource.transferSize; 954 982 }, 955 983 … … 1142 1170 } 1143 1171 1172 WebInspector.ResourceSidebarTreeElement.CompareByDescendingTransferSize = function(a, b) 1173 { 1174 return -1 * WebInspector.Resource.CompareByTransferSize(a.resource, b.resource); 1175 } 1176 1144 1177 WebInspector.ResourceSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; 1145 1178 … … 1199 1232 const barRightElementOffsetWidth = this._barRightElement.offsetWidth; 1200 1233 const barLeftElementOffsetWidth = this._barLeftElement.offsetWidth; 1201 const rightBarWidth = (barRightElementOffsetWidth - labelPadding); 1202 const leftBarWidth = ((barLeftElementOffsetWidth - barRightElementOffsetWidth) - labelPadding); 1234 1235 if (this._isBarOpaqueAtLeft) { 1236 var leftBarWidth = barLeftElementOffsetWidth - labelPadding; 1237 var rightBarWidth = (barRightElementOffsetWidth - barLeftElementOffsetWidth) - labelPadding; 1238 } else { 1239 var leftBarWidth = (barLeftElementOffsetWidth - barRightElementOffsetWidth) - labelPadding; 1240 var rightBarWidth = barRightElementOffsetWidth - labelPadding; 1241 } 1242 1203 1243 const labelLeftElementOffsetWidth = this._labelLeftElement.offsetWidth; 1204 1244 const labelRightElementOffsetWidth = this._labelRightElement.offsetWidth; … … 1208 1248 const graphElementOffsetWidth = this._graphElement.offsetWidth; 1209 1249 1250 if (labelBefore && (graphElementOffsetWidth * (this._percentages.start / 100)) < (labelLeftElementOffsetWidth + 10)) 1251 var leftHidden = true; 1252 1253 if (labelAfter && (graphElementOffsetWidth * ((100 - this._percentages.end) / 100)) < (labelRightElementOffsetWidth + 10)) 1254 var rightHidden = true; 1255 1256 if (barLeftElementOffsetWidth == barRightElementOffsetWidth) { 1257 // The left/right label data are the same, so a before/after label can be replaced by an on-bar label. 1258 if (labelBefore && !labelAfter) 1259 leftHidden = true; 1260 else if (labelAfter && !labelBefore) 1261 rightHidden = true; 1262 } 1263 1210 1264 if (labelBefore) { 1211 if ( (graphElementOffsetWidth * (this._percentages.start / 100)) < (labelLeftElementOffsetWidth + 10))1265 if (leftHidden) 1212 1266 this._labelLeftElement.addStyleClass("hidden"); 1213 1267 this._labelLeftElement.style.setProperty("right", (100 - this._percentages.start) + "%"); … … 1219 1273 1220 1274 if (labelAfter) { 1221 if ( (graphElementOffsetWidth * ((100 - this._percentages.end) / 100)) < (labelRightElementOffsetWidth + 10))1275 if (rightHidden) 1222 1276 this._labelRightElement.addStyleClass("hidden"); 1223 1277 this._labelRightElement.style.setProperty("left", this._percentages.end + "%"); … … 1229 1283 }, 1230 1284 1231 refresh: function(calculator )1285 refresh: function(calculator, isBarOpaqueAtLeft) 1232 1286 { 1233 1287 var percentages = calculator.computeBarGraphPercentages(this.resource); … … 1244 1298 1245 1299 this._barLeftElement.style.setProperty("left", percentages.start + "%"); 1246 this._barLeftElement.style.setProperty("right", (100 - percentages.end) + "%");1247 1248 this._barRightElement.style.setProperty("left", percentages.middle + "%");1249 1300 this._barRightElement.style.setProperty("right", (100 - percentages.end) + "%"); 1301 1302 if (!isBarOpaqueAtLeft) { 1303 this._barLeftElement.style.setProperty("right", (100 - percentages.end) + "%"); 1304 this._barRightElement.style.setProperty("left", percentages.middle + "%"); 1305 1306 if (this._isBarOpaqueAtLeft != isBarOpaqueAtLeft) { 1307 this._barLeftElement.addStyleClass("waiting"); 1308 this._barRightElement.removeStyleClass("waiting-right"); 1309 this._labelLeftElement.addStyleClass("waiting"); 1310 this._labelRightElement.removeStyleClass("waiting-right"); 1311 } 1312 } else { 1313 this._barLeftElement.style.setProperty("right", (100 - percentages.middle) + "%"); 1314 this._barRightElement.style.setProperty("left", percentages.start + "%"); 1315 1316 if (this._isBarOpaqueAtLeft != isBarOpaqueAtLeft) { 1317 this._barLeftElement.removeStyleClass("waiting"); 1318 this._barRightElement.addStyleClass("waiting-right"); 1319 this._labelLeftElement.removeStyleClass("waiting"); 1320 this._labelRightElement.addStyleClass("waiting-right"); 1321 } 1322 } 1323 1324 this._isBarOpaqueAtLeft = isBarOpaqueAtLeft; 1250 1325 1251 1326 this._labelLeftElement.textContent = labels.left; -
trunk/WebCore/inspector/front-end/inspector.css
r55383 r55466 2762 2762 } 2763 2763 2764 .resources-graph-label.waiting-right { 2765 margin-left: 5px; 2766 } 2767 2764 2768 .resources-graph-label.before { 2765 2769 color: rgba(0, 0, 0, 0.7); … … 2830 2834 } 2831 2835 2832 .resources-graph-bar.waiting {2836 .resources-graph-bar.waiting, .resources-graph-bar.waiting-right { 2833 2837 opacity: 0.35; 2834 2838 } -
trunk/WebCore/inspector/front-end/inspector.js
r55464 r55466 1097 1097 1098 1098 if (payload.didLengthChange) { 1099 resource. contentLength = payload.contentLength;1099 resource.resourceSize = payload.resourceSize; 1100 1100 } 1101 1101
Note: See TracChangeset
for help on using the changeset viewer.