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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 cell.colSpan = 3; | 271 cell.colSpan = 3; |
272 cell.createTextChild(WebInspector.UIString("CAUTION: request is not fini shed yet!")); | 272 cell.createTextChild(WebInspector.UIString("CAUTION: request is not fini shed yet!")); |
273 } | 273 } |
274 | 274 |
275 var footer = tableElement.createChild("tr", "network-timing-footer"); | 275 var footer = tableElement.createChild("tr", "network-timing-footer"); |
276 var note = footer.createChild("td"); | 276 var note = footer.createChild("td"); |
277 note.colSpan = 2; | 277 note.colSpan = 2; |
278 note.appendChild(WebInspector.linkifyDocumentationURLAsNode("profile/network -performance/resource-loading#view-network-timing-details-for-a-specific-resourc e", WebInspector.UIString("Explanation"))); | 278 note.appendChild(WebInspector.linkifyDocumentationURLAsNode("profile/network -performance/resource-loading#view-network-timing-details-for-a-specific-resourc e", WebInspector.UIString("Explanation"))); |
279 footer.createChild("td").createTextChild(Number.secondsToString(totalDuratio n, true)); | 279 footer.createChild("td").createTextChild(Number.secondsToString(totalDuratio n, true)); |
280 | 280 |
281 var serverTimings = request.serverTimings; | |
282 if (!serverTimings) | |
283 return tableElement; | |
284 | |
285 var breakEl = tableElement.createChild("tr", "network-timing-table-header"). createChild("td"); | |
caseq
2016/04/26 03:56:42
nit: breakElement, blink's code style doesn't favo
| |
286 breakEl.colSpan = 3; | |
287 breakEl.createChild("hr", "break"); | |
288 var serverHeader = tableElement.createChild("tr", "network-timing-table-head er"); | |
289 serverHeader.createChild("td").createTextChild(WebInspector.UIString("Server Timing")); | |
290 serverHeader.createChild("td"); | |
291 serverHeader.createChild("td").createTextChild(WebInspector.UIString("TIME") ); | |
292 | |
293 var colorGenerator = new WebInspector.FlameChart.ColorGenerator( | |
294 { min: 0, max: 360, count:36 }, | |
295 { min: 50, max: 80 }, | |
296 80 | |
297 ); | |
298 | |
299 /** | |
300 * @param {!WebInspector.ServerTiming} serverTiming | |
301 */ | |
302 function addTiming(serverTiming) | |
303 { | |
304 var isTotal = serverTiming.metric.toLowerCase() === "total"; | |
305 var tr = tableElement.createChild("tr", isTotal ? "network-timing-footer " : ""); | |
306 var metric = tr.createChild("td", "network-timing-metric"); | |
307 metric.createTextChild(serverTiming.description || serverTiming.metric); | |
308 var row = tr.createChild("td").createChild("div", "network-timing-row"); | |
309 var left = scale * (endTime - startTime - serverTiming.value); | |
310 if (serverTiming.value && left >= 0) { // don't chart values too big or too small | |
311 var bar = row.createChild("span", "network-timing-bar server-timing" ); | |
312 bar.style.left = left + "%"; | |
313 bar.style.right = right + "%"; | |
caseq
2016/04/26 03:56:42
let's avoid using right from the closure, especial
| |
314 bar.textContent = "\u200B"; // Important for 0-time items to have 0 width. | |
315 if (!isTotal) | |
316 bar.style.backgroundColor = colorGenerator.colorForID(serverTimi ng.metric); | |
317 } | |
318 var label = tr.createChild("td").createChild("div", "network-timing-bar- title"); | |
319 if (typeof serverTiming.value === "number") // a metric timing value is optional | |
320 label.textContent = Number.secondsToString(serverTiming.value, true) ; | |
321 } | |
322 | |
323 serverTimings.filter(item => item.metric.toLowerCase() !== "total").forEach( addTiming); | |
324 serverTimings.filter(item => item.metric.toLowerCase() === "total").forEach( addTiming); | |
325 | |
281 return tableElement; | 326 return tableElement; |
282 } | 327 } |
OLD | NEW |