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

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

Issue 2892333002: DevTools: Render third-party badges in timeline tree view (Closed)
Patch Set: . Created 3 years, 7 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 static eventColor(event) { 326 static eventColor(event) {
327 if (event.name === TimelineModel.TimelineModel.RecordType.JSFrame) { 327 if (event.name === TimelineModel.TimelineModel.RecordType.JSFrame) {
328 var frame = event.args['data']; 328 var frame = event.args['data'];
329 if (Timeline.TimelineUIUtils.isUserFrame(frame)) 329 if (Timeline.TimelineUIUtils.isUserFrame(frame))
330 return Timeline.TimelineUIUtils.colorForId(frame.url); 330 return Timeline.TimelineUIUtils.colorForId(frame.url);
331 } 331 }
332 return Timeline.TimelineUIUtils.eventStyle(event).category.color; 332 return Timeline.TimelineUIUtils.eventStyle(event).category.color;
333 } 333 }
334 334
335 /** 335 /**
336 * @param {!ProductRegistry.Registry} productRegistry
337 * @param {!TimelineModel.TimelineModel} model
338 * @param {!Map<string, string>} urlToColorCache
339 * @param {!SDK.TracingModel.Event} event
340 * @return {string}
341 */
342 static eventColorByProduct(productRegistry, model, urlToColorCache, event) {
343 var url = Timeline.TimelineUIUtils.eventURL(event) || '';
344 var color = urlToColorCache.get(url);
345 if (!color) {
caseq 2017/05/24 01:36:26 if (color) return color;
alph 2017/05/24 02:00:49 Done.
346 var defaultColor = '#f2ecdc';
347 var parsedURL = url.asParsedURL();
348 if (!parsedURL)
349 return defaultColor;
350 var name = productRegistry && productRegistry.nameForUrl(parsedURL);
351 if (!name) {
352 name = parsedURL.host;
353 var rootFrames = model.rootFrames();
354 if (rootFrames.some(pageFrame => new Common.ParsedURL(pageFrame.url).hos t === name))
355 color = defaultColor;
356 }
357 if (!color)
358 color = name ? ProductRegistry.BadgePool.colorForEntryName(name) : defau ltColor;
359 urlToColorCache.set(url, color);
360 }
361 return color;
362 }
363
364 /**
336 * @param {!SDK.TracingModel.Event} event 365 * @param {!SDK.TracingModel.Event} event
337 * @return {string} 366 * @return {string}
338 */ 367 */
339 static eventTitle(event) { 368 static eventTitle(event) {
340 const recordType = TimelineModel.TimelineModel.RecordType; 369 const recordType = TimelineModel.TimelineModel.RecordType;
341 const eventData = event.args['data']; 370 const eventData = event.args['data'];
342 if (event.name === recordType.JSFrame) 371 if (event.name === recordType.JSFrame)
343 return Timeline.TimelineUIUtils.frameDisplayName(eventData); 372 return Timeline.TimelineUIUtils.frameDisplayName(eventData);
344 const title = Timeline.TimelineUIUtils.eventStyle(event).title; 373 const title = Timeline.TimelineUIUtils.eventStyle(event).title;
345 if (event.hasCategory(TimelineModel.TimelineModel.Category.Console)) 374 if (event.hasCategory(TimelineModel.TimelineModel.Category.Console))
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 } 977 }
949 978
950 /** 979 /**
951 * @param {!Timeline.TimelineDetailsContentHelper} contentHelper 980 * @param {!Timeline.TimelineDetailsContentHelper} contentHelper
952 * @param {!ProductRegistry.BadgePool} badgePool 981 * @param {!ProductRegistry.BadgePool} badgePool
953 * @param {?string} url 982 * @param {?string} url
954 */ 983 */
955 static _maybeAppendProductToDetails(contentHelper, badgePool, url) { 984 static _maybeAppendProductToDetails(contentHelper, badgePool, url) {
956 var parsedURL = url ? url.asParsedURL() : null; 985 var parsedURL = url ? url.asParsedURL() : null;
957 if (parsedURL) 986 if (parsedURL)
958 contentHelper.appendElementRow('', badgePool.badgeForURL(parsedURL, true)) ; 987 contentHelper.appendElementRow('', badgePool.badgeForURL(parsedURL));
959 } 988 }
960 989
961 /** 990 /**
962 * @param {!TimelineModel.TimelineModel} model 991 * @param {!TimelineModel.TimelineModel} model
963 * @param {number} startTime 992 * @param {number} startTime
964 * @param {number} endTime 993 * @param {number} endTime
965 * @return {!DocumentFragment} 994 * @return {!DocumentFragment}
966 */ 995 */
967 static buildRangeStats(model, startTime, endTime) { 996 static buildRangeStats(model, startTime, endTime) {
968 var aggregatedStats = Timeline.TimelineUIUtils.statsForTimeRange(model, star tTime, endTime); 997 var aggregatedStats = Timeline.TimelineUIUtils.statsForTimeRange(model, star tTime, endTime);
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 * @param {string=} warningType 2313 * @param {string=} warningType
2285 */ 2314 */
2286 appendWarningRow(event, warningType) { 2315 appendWarningRow(event, warningType) {
2287 var warning = Timeline.TimelineUIUtils.eventWarning(event, warningType); 2316 var warning = Timeline.TimelineUIUtils.eventWarning(event, warningType);
2288 if (warning) 2317 if (warning)
2289 this.appendElementRow(Common.UIString('Warning'), warning, true); 2318 this.appendElementRow(Common.UIString('Warning'), warning, true);
2290 } 2319 }
2291 }; 2320 };
2292 2321
2293 Timeline.TimelineUIUtils._categoryBreakdownCacheSymbol = Symbol('categoryBreakdo wnCache'); 2322 Timeline.TimelineUIUtils._categoryBreakdownCacheSymbol = Symbol('categoryBreakdo wnCache');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698