Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js

Issue 1636853002: Timeline: simplify handling of event category colors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 171
172 /** 172 /**
173 * @param {!WebInspector.TracingModel.Event} event 173 * @param {!WebInspector.TracingModel.Event} event
174 * @return {string} 174 * @return {string}
175 */ 175 */
176 WebInspector.TimelineUIUtils.eventColor = function(event) 176 WebInspector.TimelineUIUtils.eventColor = function(event)
177 { 177 {
178 if (event.name === WebInspector.TimelineModel.RecordType.JSFrame) 178 if (event.name === WebInspector.TimelineModel.RecordType.JSFrame)
179 return WebInspector.TimelineUIUtils.colorForURL(event.args["data"]["url" ]); 179 return WebInspector.TimelineUIUtils.colorForURL(event.args["data"]["url" ]);
180 return WebInspector.TimelineUIUtils.eventStyle(event).category.fillColorStop 1; 180 return WebInspector.TimelineUIUtils.eventStyle(event).category.color;
181 } 181 }
182 182
183 /** 183 /**
184 * @param {!WebInspector.TracingModel.Event} event 184 * @param {!WebInspector.TracingModel.Event} event
185 * @return {string} 185 * @return {string}
186 */ 186 */
187 WebInspector.TimelineUIUtils.eventTitle = function(event) 187 WebInspector.TimelineUIUtils.eventTitle = function(event)
188 { 188 {
189 var title = WebInspector.TimelineUIUtils.eventStyle(event).title; 189 var title = WebInspector.TimelineUIUtils.eventStyle(event).title;
190 if (event.hasCategory(WebInspector.TimelineModel.Category.Console)) 190 if (event.hasCategory(WebInspector.TimelineModel.Category.Console))
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 } 1378 }
1379 1379
1380 /** 1380 /**
1381 * @return {!Object.<string, !WebInspector.TimelineCategory>} 1381 * @return {!Object.<string, !WebInspector.TimelineCategory>}
1382 */ 1382 */
1383 WebInspector.TimelineUIUtils.categories = function() 1383 WebInspector.TimelineUIUtils.categories = function()
1384 { 1384 {
1385 if (WebInspector.TimelineUIUtils._categories) 1385 if (WebInspector.TimelineUIUtils._categories)
1386 return WebInspector.TimelineUIUtils._categories; 1386 return WebInspector.TimelineUIUtils._categories;
1387 WebInspector.TimelineUIUtils._categories = { 1387 WebInspector.TimelineUIUtils._categories = {
1388 loading: new WebInspector.TimelineCategory("loading", WebInspector.UIStr ing("Loading"), true, "hsl(214, 53%, 58%)", "hsl(214, 67%, 90%)", "hsl(214, 67%, 74%)", "hsl(214, 67%, 66%)"), 1388 loading: new WebInspector.TimelineCategory("loading", WebInspector.UIStr ing("Loading"), true, "hsl(214, 67%, 74%)", "hsl(214, 67%, 66%)"),
1389 scripting: new WebInspector.TimelineCategory("scripting", WebInspector.U IString("Scripting"), true, "hsl(43, 90%, 45%)", "hsl(43, 83%, 90%)", "hsl(43, 8 3%, 72%)", "hsl(43, 83%, 64%) "), 1389 scripting: new WebInspector.TimelineCategory("scripting", WebInspector.U IString("Scripting"), true, "hsl(43, 83%, 72%)", "hsl(43, 83%, 64%) "),
1390 rendering: new WebInspector.TimelineCategory("rendering", WebInspector.U IString("Rendering"), true, "hsl(256, 50%, 60%)", "hsl(256, 67%, 90%)", "hsl(256 , 67%, 76%)", "hsl(256, 67%, 70%)"), 1390 rendering: new WebInspector.TimelineCategory("rendering", WebInspector.U IString("Rendering"), true, "hsl(256, 67%, 76%)", "hsl(256, 67%, 70%)"),
1391 painting: new WebInspector.TimelineCategory("painting", WebInspector.UIS tring("Painting"), true, "hsl(109, 33%, 47%)", "hsl(109, 33%, 90%)", "hsl(109, 3 3%, 64%)", "hsl(109, 33%, 55%)"), 1391 painting: new WebInspector.TimelineCategory("painting", WebInspector.UIS tring("Painting"), true, "hsl(109, 33%, 64%)", "hsl(109, 33%, 55%)"),
1392 gpu: new WebInspector.TimelineCategory("gpu", WebInspector.UIString("GPU "), false, "hsl(240, 24%, 45%)", "hsl(240, 24%, 90%)", "hsl(240, 24%, 73%)", "hs l(240, 24%, 66%)"), 1392 gpu: new WebInspector.TimelineCategory("gpu", WebInspector.UIString("GPU "), false, "hsl(240, 24%, 73%)", "hsl(240, 24%, 66%)"),
1393 other: new WebInspector.TimelineCategory("other", WebInspector.UIString( "Other"), false, "hsl(0, 0%, 73%)", "hsl(0, 0%, 90%)", "hsl(0, 0%, 87%)", "hsl(0 , 0%, 79%)"), 1393 other: new WebInspector.TimelineCategory("other", WebInspector.UIString( "Other"), false, "hsl(0, 0%, 87%)", "hsl(0, 0%, 79%)"),
1394 idle: new WebInspector.TimelineCategory("idle", WebInspector.UIString("I dle"), false, "hsl(0, 0%, 87%)", "hsl(0, 100%, 100%)", "hsl(0, 100%, 100%)", "hs l(0, 100%, 100%)") 1394 idle: new WebInspector.TimelineCategory("idle", WebInspector.UIString("I dle"), false, "hsl(0, 100%, 100%)", "hsl(0, 100%, 100%)")
1395 }; 1395 };
1396 return WebInspector.TimelineUIUtils._categories; 1396 return WebInspector.TimelineUIUtils._categories;
1397 }; 1397 };
1398 1398
1399 /** 1399 /**
1400 * @constructor 1400 * @constructor
1401 * @param {string} title 1401 * @param {string} title
1402 */ 1402 */
1403 WebInspector.AsyncEventGroup = function(title) 1403 WebInspector.AsyncEventGroup = function(title)
1404 { 1404 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 * @param {number} value 1447 * @param {number} value
1448 * @param {string} color 1448 * @param {string} color
1449 */ 1449 */
1450 function appendLegendRow(name, title, value, color) 1450 function appendLegendRow(name, title, value, color)
1451 { 1451 {
1452 if (!value) 1452 if (!value)
1453 return; 1453 return;
1454 pieChart.addSlice(value, color); 1454 pieChart.addSlice(value, color);
1455 var rowElement = footerElement.createChild("div"); 1455 var rowElement = footerElement.createChild("div");
1456 rowElement.createChild("span", "timeline-aggregated-legend-value").text Content = Number.preciseMillisToString(value, 1); 1456 rowElement.createChild("span", "timeline-aggregated-legend-value").text Content = Number.preciseMillisToString(value, 1);
1457 rowElement.createChild("span", "timeline-aggregated-legend-swatch timel ine-" + name); 1457 rowElement.createChild("span", "timeline-aggregated-legend-swatch").sty le.backgroundColor = color;
1458 rowElement.createChild("span", "timeline-aggregated-legend-title").text Content = title; 1458 rowElement.createChild("span", "timeline-aggregated-legend-title").text Content = title;
1459 } 1459 }
1460 1460
1461 // In case of self time, first add self, then children of the same category. 1461 // In case of self time, first add self, then children of the same category.
1462 if (selfCategory) { 1462 if (selfCategory) {
1463 if (selfTime) 1463 if (selfTime)
1464 appendLegendRow(selfCategory.name, WebInspector.UIString("%s (self)" , selfCategory.title), selfTime, selfCategory.fillColorStop1); 1464 appendLegendRow(selfCategory.name, WebInspector.UIString("%s (self)" , selfCategory.title), selfTime, selfCategory.color);
1465 // Children of the same category. 1465 // Children of the same category.
1466 var categoryTime = aggregatedStats[selfCategory.name]; 1466 var categoryTime = aggregatedStats[selfCategory.name];
1467 var value = categoryTime - selfTime; 1467 var value = categoryTime - selfTime;
1468 if (value > 0) 1468 if (value > 0)
1469 appendLegendRow(selfCategory.name, WebInspector.UIString("%s (childr en)", selfCategory.title), value, selfCategory.fillColorStop0); 1469 appendLegendRow(selfCategory.name, WebInspector.UIString("%s (childr en)", selfCategory.title), value, selfCategory.childColor);
1470 } 1470 }
1471 1471
1472 // Add other categories. 1472 // Add other categories.
1473 for (var categoryName in WebInspector.TimelineUIUtils.categories()) { 1473 for (var categoryName in WebInspector.TimelineUIUtils.categories()) {
1474 var category = WebInspector.TimelineUIUtils.categories()[categoryName]; 1474 var category = WebInspector.TimelineUIUtils.categories()[categoryName];
1475 if (category === selfCategory) 1475 if (category === selfCategory)
1476 continue; 1476 continue;
1477 appendLegendRow(category.name, category.title, aggregatedStats[category. name], category.fillColorStop0); 1477 appendLegendRow(category.name, category.title, aggregatedStats[category. name], category.childColor);
1478 } 1478 }
1479 return element; 1479 return element;
1480 } 1480 }
1481 1481
1482 /** 1482 /**
1483 * @param {!WebInspector.TimelineFrameModelBase} frameModel 1483 * @param {!WebInspector.TimelineFrameModelBase} frameModel
1484 * @param {!WebInspector.TimelineFrame} frame 1484 * @param {!WebInspector.TimelineFrame} frame
1485 * @param {?WebInspector.FilmStripModel.Frame} filmStripFrame 1485 * @param {?WebInspector.FilmStripModel.Frame} filmStripFrame
1486 * @return {!Element} 1486 * @return {!Element}
1487 */ 1487 */
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 { 1561 {
1562 var gradient = context.createLinearGradient(0, 0, width, height); 1562 var gradient = context.createLinearGradient(0, 0, width, height);
1563 gradient.addColorStop(0, color0); 1563 gradient.addColorStop(0, color0);
1564 gradient.addColorStop(0.25, color1); 1564 gradient.addColorStop(0.25, color1);
1565 gradient.addColorStop(0.75, color1); 1565 gradient.addColorStop(0.75, color1);
1566 gradient.addColorStop(1, color2); 1566 gradient.addColorStop(1, color2);
1567 return gradient; 1567 return gradient;
1568 } 1568 }
1569 1569
1570 /** 1570 /**
1571 * @param {!CanvasRenderingContext2D} context
1572 * @param {number} width
1573 * @param {number} height
1574 * @param {!WebInspector.TimelineCategory} category
1575 * @return {!CanvasGradient}
1576 */
1577 WebInspector.TimelineUIUtils.createFillStyleForCategory = function(context, widt h, height, category)
1578 {
1579 return WebInspector.TimelineUIUtils.createFillStyle(context, width, height, category.fillColorStop0, category.fillColorStop1, category.borderColor);
1580 }
1581
1582 /**
1583 * @param {!WebInspector.TimelineCategory} category
1584 * @return {string}
1585 */
1586 WebInspector.TimelineUIUtils.createStyleRuleForCategory = function(category)
1587 {
1588 var selector = ".timeline-category-" + category.name + " .timeline-graph-bar , " +
1589 ".timeline-details-view .timeline-" + category.name + ", " +
1590 ".timeline-category-" + category.name + " .timeline-tree-icon";
1591
1592 return selector + " { background-image: linear-gradient(" +
1593 category.fillColorStop0 + ", " + category.fillColorStop1 + " 25%, " + cat egory.fillColorStop1 + " 25%, " + category.fillColorStop1 + ");" +
1594 " border-color: " + category.borderColor +
1595 "}";
1596 }
1597
1598 /**
1599 * @param {!Array.<number>} quad 1571 * @param {!Array.<number>} quad
1600 * @return {number} 1572 * @return {number}
1601 */ 1573 */
1602 WebInspector.TimelineUIUtils.quadWidth = function(quad) 1574 WebInspector.TimelineUIUtils.quadWidth = function(quad)
1603 { 1575 {
1604 return Math.round(Math.sqrt(Math.pow(quad[0] - quad[2], 2) + Math.pow(quad[1 ] - quad[3], 2))); 1576 return Math.round(Math.sqrt(Math.pow(quad[0] - quad[2], 2) + Math.pow(quad[1 ] - quad[3], 2)));
1605 } 1577 }
1606 1578
1607 /** 1579 /**
1608 * @param {!Array.<number>} quad 1580 * @param {!Array.<number>} quad
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 ]; 1620 ];
1649 return WebInspector.TimelineUIUtils._eventDispatchDesciptors; 1621 return WebInspector.TimelineUIUtils._eventDispatchDesciptors;
1650 } 1622 }
1651 1623
1652 /** 1624 /**
1653 * @constructor 1625 * @constructor
1654 * @extends {WebInspector.Object} 1626 * @extends {WebInspector.Object}
1655 * @param {string} name 1627 * @param {string} name
1656 * @param {string} title 1628 * @param {string} title
1657 * @param {boolean} visible 1629 * @param {boolean} visible
1658 * @param {string} borderColor 1630 * @param {string} childColor
1659 * @param {string} backgroundColor 1631 * @param {string} color
1660 * @param {string} fillColorStop0
1661 * @param {string} fillColorStop1
1662 */ 1632 */
1663 WebInspector.TimelineCategory = function(name, title, visible, borderColor, back groundColor, fillColorStop0, fillColorStop1) 1633 WebInspector.TimelineCategory = function(name, title, visible, childColor, color )
1664 { 1634 {
1665 this.name = name; 1635 this.name = name;
1666 this.title = title; 1636 this.title = title;
1667 this.visible = visible; 1637 this.visible = visible;
1668 this.borderColor = borderColor; 1638 this.childColor = childColor;
1669 this.backgroundColor = backgroundColor; 1639 this.color = color;
1670 this.fillColorStop0 = fillColorStop0;
1671 this.fillColorStop1 = fillColorStop1;
1672 this.hidden = false; 1640 this.hidden = false;
1673 } 1641 }
1674 1642
1675 WebInspector.TimelineCategory.Events = { 1643 WebInspector.TimelineCategory.Events = {
1676 VisibilityChanged: "VisibilityChanged" 1644 VisibilityChanged: "VisibilityChanged"
1677 }; 1645 };
1678 1646
1679 WebInspector.TimelineCategory.prototype = { 1647 WebInspector.TimelineCategory.prototype = {
1680 /** 1648 /**
1681 * @return {boolean} 1649 * @return {boolean}
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 if (!this._tableElement.hasChildNodes()) { 1856 if (!this._tableElement.hasChildNodes()) {
1889 this.element.removeChildren(); 1857 this.element.removeChildren();
1890 } else { 1858 } else {
1891 this.element = createElementWithClass("div", "timeline-details-view- block"); 1859 this.element = createElementWithClass("div", "timeline-details-view- block");
1892 this.fragment.appendChild(this.element); 1860 this.fragment.appendChild(this.element);
1893 } 1861 }
1894 1862
1895 if (title) { 1863 if (title) {
1896 var titleElement = this.element.createChild("div", "timeline-details -chip-title"); 1864 var titleElement = this.element.createChild("div", "timeline-details -chip-title");
1897 if (category) 1865 if (category)
1898 titleElement.createChild("div", "timeline-" + category.name); 1866 titleElement.createChild("div").style.backgroundColor = category .color;
1899 titleElement.createTextChild(title); 1867 titleElement.createTextChild(title);
1900 } 1868 }
1901 1869
1902 this._tableElement = this.element.createChild("div", "vbox timeline-deta ils-chip-body"); 1870 this._tableElement = this.element.createChild("div", "vbox timeline-deta ils-chip-body");
1903 this.fragment.appendChild(this.element); 1871 this.fragment.appendChild(this.element);
1904 }, 1872 },
1905 1873
1906 /** 1874 /**
1907 * @return {?WebInspector.Linkifier} 1875 * @return {?WebInspector.Linkifier}
1908 */ 1876 */
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 case warnings.V8Deopt: 2011 case warnings.V8Deopt:
2044 span.appendChild(WebInspector.linkifyURLAsNode("https://github.com/Googl eChrome/devtools-docs/issues/53", 2012 span.appendChild(WebInspector.linkifyURLAsNode("https://github.com/Googl eChrome/devtools-docs/issues/53",
2045 WebInspector.UIString("Not optimized"), undefined, true)); 2013 WebInspector.UIString("Not optimized"), undefined, true));
2046 span.createTextChild(WebInspector.UIString(": %s", eventData["deoptReaso n"])); 2014 span.createTextChild(WebInspector.UIString(": %s", eventData["deoptReaso n"]));
2047 break; 2015 break;
2048 default: 2016 default:
2049 console.assert(false, "Unhandled TimelineModel.WarningType"); 2017 console.assert(false, "Unhandled TimelineModel.WarningType");
2050 } 2018 }
2051 return span; 2019 return span;
2052 } 2020 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698