OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 }; | 238 }; |
239 | 239 |
240 /** | 240 /** |
241 * @constructor | 241 * @constructor |
242 * @extends {WebInspector.VBox} | 242 * @extends {WebInspector.VBox} |
243 */ | 243 */ |
244 WebInspector.PaintProfilerCommandLogView = function() | 244 WebInspector.PaintProfilerCommandLogView = function() |
245 { | 245 { |
246 WebInspector.VBox.call(this); | 246 WebInspector.VBox.call(this); |
247 this.setMinimumSize(100, 25); | 247 this.setMinimumSize(100, 25); |
248 this.element.classList.add("outline-disclosure"); | 248 this.element.classList.add("outline-disclosure", "profiler-log-view", "secti on"); |
249 var sidebarTreeElement = this.element.createChild("ol", "sidebar-tree"); | 249 var sidebarTreeElement = this.element.createChild("ol", "sidebar-tree proper ties monospace"); |
250 sidebarTreeElement.addEventListener("mousemove", this._onMouseMove.bind(this ), false); | 250 sidebarTreeElement.addEventListener("mousemove", this._onMouseMove.bind(this ), false); |
251 sidebarTreeElement.addEventListener("mouseout", this._onMouseMove.bind(this) , false); | 251 sidebarTreeElement.addEventListener("mouseout", this._onMouseMove.bind(this) , false); |
252 sidebarTreeElement.addEventListener("contextmenu", this._onContextMenu.bind( this), true); | 252 sidebarTreeElement.addEventListener("contextmenu", this._onContextMenu.bind( this), true); |
253 this.sidebarTree = new TreeOutline(sidebarTreeElement); | 253 this.sidebarTree = new TreeOutline(sidebarTreeElement); |
254 this._popoverHelper = new WebInspector.ObjectPopoverHelper(this.element, thi s._getHoverAnchor.bind(this), this._resolveObjectForPopover.bind(this), undefine d, true); | |
255 | 254 |
256 this._reset(); | 255 this._reset(); |
257 } | 256 } |
258 | 257 |
259 WebInspector.PaintProfilerCommandLogView.prototype = { | 258 WebInspector.PaintProfilerCommandLogView.prototype = { |
260 /** | 259 /** |
261 * @param {?WebInspector.Target} target | 260 * @param {?WebInspector.Target} target |
262 * @param {!Array.<!WebInspector.PaintProfilerLogItem>=} log | 261 * @param {!Array.<!WebInspector.PaintProfilerLogItem>=} log |
263 */ | 262 */ |
264 setCommandLog: function(target, log) | 263 setCommandLog: function(target, log) |
265 { | 264 { |
266 this._target = target; | 265 this._target = target; |
267 this._log = log; | 266 this._log = log; |
268 this.updateWindow(); | 267 this.updateWindow(); |
269 }, | 268 }, |
270 | 269 |
271 /** | 270 /** |
271 * @param {!TreeOutline} treeOutline | |
272 * @param {!WebInspector.PaintProfilerLogItem} logItem | |
273 */ | |
274 _appendLogItem: function(treeOutline, logItem) | |
275 { | |
276 var first = new WebInspector.LogTreeElement(this, logItem); | |
277 treeOutline.appendChild(first); | |
278 // for (var param in logItem.params) | |
caseq
2014/07/31 13:48:39
please remove
malch
2014/07/31 13:55:54
Done.
| |
279 // WebInspector.LogPropertyTreeElement.appendLogPropertyItem(first, param, logItem.params[param]); | |
280 }, | |
281 | |
282 /** | |
272 * @param {number=} stepLeft | 283 * @param {number=} stepLeft |
273 * @param {number=} stepRight | 284 * @param {number=} stepRight |
274 */ | 285 */ |
275 updateWindow: function(stepLeft, stepRight) | 286 updateWindow: function(stepLeft, stepRight) |
276 { | 287 { |
277 stepLeft = stepLeft || 0; | 288 stepLeft = stepLeft || 0; |
278 stepRight = stepRight || this._log.length - 1; | 289 stepRight = stepRight || this._log.length - 1; |
279 this.sidebarTree.removeChildren(); | 290 this.sidebarTree.removeChildren(); |
280 for (var i = stepLeft; i <= stepRight; ++i) { | 291 for (var i = stepLeft; i <= stepRight; ++i) { |
caseq
2014/07/31 13:48:39
{} are redundant
malch
2014/07/31 13:55:54
Done.
| |
281 var node = new WebInspector.LogTreeElement(this, this._log[i]); | 292 this._appendLogItem(this.sidebarTree, this._log[i]); |
282 this.sidebarTree.appendChild(node); | |
283 } | 293 } |
284 }, | 294 }, |
285 | 295 |
286 _reset: function() | 296 _reset: function() |
287 { | 297 { |
288 this._log = []; | 298 this._log = []; |
289 }, | 299 }, |
290 | 300 |
291 /** | 301 /** |
292 * @param {!Element} target | |
293 * @return {!Element} | |
294 */ | |
295 _getHoverAnchor: function(target) | |
296 { | |
297 return /** @type {!Element} */ (target.enclosingNodeOrSelfWithNodeName(" span")); | |
298 }, | |
299 | |
300 /** | |
301 * @param {!Element} element | |
302 * @param {function(!WebInspector.RemoteObject, boolean, !Element=):undefine d} showCallback | |
303 */ | |
304 _resolveObjectForPopover: function(element, showCallback) | |
305 { | |
306 var liElement = element.enclosingNodeOrSelfWithNodeName("li"); | |
307 var logItem = liElement.treeElement.representedObject; | |
308 var obj = {"method": logItem.method}; | |
309 if (logItem.params) | |
310 obj.params = logItem.params; | |
311 showCallback(WebInspector.RemoteObject.fromLocalObject(obj), false); | |
312 }, | |
313 | |
314 /** | |
315 * @param {?Event} event | 302 * @param {?Event} event |
316 */ | 303 */ |
317 _onMouseMove: function(event) | 304 _onMouseMove: function(event) |
318 { | 305 { |
319 var node = this.sidebarTree.treeElementFromPoint(event.pageX, event.page Y); | 306 var node = this.sidebarTree.treeElementFromPoint(event.pageX, event.page Y); |
320 if (node === this._lastHoveredNode) | 307 if (node === this._lastHoveredNode || !(node instanceof WebInspector.Log TreeElement)) |
321 return; | 308 return; |
322 if (this._lastHoveredNode) | 309 if (this._lastHoveredNode) |
323 this._lastHoveredNode.setHovered(false); | 310 this._lastHoveredNode.setHovered(false); |
324 this._lastHoveredNode = node; | 311 this._lastHoveredNode = node; |
325 if (this._lastHoveredNode) | 312 if (this._lastHoveredNode) |
326 this._lastHoveredNode.setHovered(true); | 313 this._lastHoveredNode.setHovered(true); |
327 }, | 314 }, |
328 | 315 |
329 /** | 316 /** |
330 * @param {?Event} event | 317 * @param {?Event} event |
331 */ | 318 */ |
332 _onContextMenu: function(event) | 319 _onContextMenu: function(event) |
333 { | 320 { |
334 if (!this._target) | 321 if (!this._target) |
335 return; | 322 return; |
336 var node = this.sidebarTree.treeElementFromPoint(event.pageX, event.page Y); | 323 var node = this.sidebarTree.treeElementFromPoint(event.pageX, event.page Y); |
337 if (!node || !node.representedObject) | 324 if (!node || !node.representedObject || !(node instanceof WebInspector.L ogTreeElement)) |
338 return; | 325 return; |
339 var logItem = /** @type {!WebInspector.PaintProfilerLogItem} */ (node.re presentedObject); | 326 var logItem = /** @type {!WebInspector.PaintProfilerLogItem} */ (node.re presentedObject); |
340 if (!logItem.nodeId()) | 327 if (!logItem.nodeId()) |
341 return; | 328 return; |
342 var contextMenu = new WebInspector.ContextMenu(event); | 329 var contextMenu = new WebInspector.ContextMenu(event); |
343 var domNode = new WebInspector.DeferredDOMNode(this._target, logItem.nod eId()); | 330 var domNode = new WebInspector.DeferredDOMNode(this._target, logItem.nod eId()); |
344 contextMenu.appendApplicableItems(domNode); | 331 contextMenu.appendApplicableItems(domNode); |
345 contextMenu.show(); | 332 contextMenu.show(); |
346 }, | 333 }, |
347 | 334 |
348 __proto__: WebInspector.VBox.prototype | 335 __proto__: WebInspector.VBox.prototype |
349 }; | 336 }; |
350 | 337 |
351 /** | 338 /** |
352 * @constructor | 339 * @constructor |
353 * @param {!WebInspector.PaintProfilerCommandLogView} ownerView | 340 * @param {!WebInspector.PaintProfilerCommandLogView} ownerView |
354 * @param {!WebInspector.PaintProfilerLogItem} logItem | 341 * @param {!WebInspector.PaintProfilerLogItem} logItem |
355 * @extends {TreeElement} | 342 * @extends {TreeElement} |
356 */ | 343 */ |
357 WebInspector.LogTreeElement = function(ownerView, logItem) | 344 WebInspector.LogTreeElement = function(ownerView, logItem) |
358 { | 345 { |
359 TreeElement.call(this, "", logItem); | 346 TreeElement.call(this, "", logItem); |
360 this._ownerView = ownerView; | 347 this._ownerView = ownerView; |
361 this._update(); | 348 this._filled = false; |
362 } | 349 } |
363 | 350 |
364 WebInspector.LogTreeElement.prototype = { | 351 WebInspector.LogTreeElement.prototype = { |
352 onattach: function() | |
353 { | |
354 this._update(); | |
355 if (this.representedObject.params) | |
356 this.hasChildren = true; | |
357 }, | |
358 | |
359 onexpand: function() | |
360 { | |
361 if (this._filled) | |
362 return; | |
363 this._filled = true; | |
364 for (var param in this.representedObject.params) | |
365 WebInspector.LogPropertyTreeElement.appendLogPropertyItem(this, para m, this.representedObject.params[param]); | |
366 }, | |
367 | |
365 /** | 368 /** |
366 * @param {!Object} param | 369 * @param {!Object} param |
367 * @param {string} name | 370 * @param {string} name |
368 * @return {string} | 371 * @return {string} |
369 */ | 372 */ |
370 _paramToString: function(param, name) | 373 _paramToString: function(param, name) |
371 { | 374 { |
372 if (typeof param !== "object") | 375 if (typeof param !== "object") |
373 return typeof param === "string" && param.length > 100 ? name : JSON .stringify(param); | 376 return typeof param === "string" && param.length > 100 ? name : JSON .stringify(param); |
374 var str = ""; | 377 var str = ""; |
(...skipping 21 matching lines...) Expand all Loading... | |
396 str += this._paramToString(params[key], key); | 399 str += this._paramToString(params[key], key); |
397 } | 400 } |
398 return str; | 401 return str; |
399 }, | 402 }, |
400 | 403 |
401 _update: function() | 404 _update: function() |
402 { | 405 { |
403 var logItem = this.representedObject; | 406 var logItem = this.representedObject; |
404 var title = document.createDocumentFragment(); | 407 var title = document.createDocumentFragment(); |
405 title.createChild("div", "selection"); | 408 title.createChild("div", "selection"); |
406 var span = title.createChild("span"); | 409 title.createTextChild(logItem.method + "(" + this._paramsToString(logIte m.params) + ")"); |
407 var textContent = logItem.method; | |
408 if (logItem.params) | |
409 textContent += "(" + this._paramsToString(logItem.params) + ")"; | |
410 span.textContent = textContent; | |
411 this.title = title; | 410 this.title = title; |
412 }, | 411 }, |
413 | 412 |
414 /** | 413 /** |
415 * @param {boolean} hovered | 414 * @param {boolean} hovered |
416 */ | 415 */ |
417 setHovered: function(hovered) | 416 setHovered: function(hovered) |
418 { | 417 { |
419 this.listItemElement.classList.toggle("hovered", hovered); | 418 this.listItemElement.classList.toggle("hovered", hovered); |
420 var target = this._ownerView._target; | 419 var target = this._ownerView._target; |
(...skipping 17 matching lines...) Expand all Loading... | |
438 { | 437 { |
439 if (node) | 438 if (node) |
440 node.highlight(); | 439 node.highlight(); |
441 } | 440 } |
442 }, | 441 }, |
443 | 442 |
444 __proto__: TreeElement.prototype | 443 __proto__: TreeElement.prototype |
445 }; | 444 }; |
446 | 445 |
447 /** | 446 /** |
447 * @constructor | |
448 * @param {!{name: string, value}} property | |
449 * @extends {TreeElement} | |
450 */ | |
451 WebInspector.LogPropertyTreeElement = function(property) | |
452 { | |
453 TreeElement.call(this, "", property); | |
454 }; | |
455 | |
456 WebInspector.LogPropertyTreeElement.prototype = { | |
457 onattach: function() | |
458 { | |
459 this._update(); | |
460 }, | |
461 | |
462 /** | |
463 * @param {*} value | |
464 * @return {string} | |
465 */ | |
466 _type: function(value) | |
467 { | |
468 return value === null ? "null" : typeof value; | |
469 }, | |
470 | |
471 _update: function() | |
472 { | |
473 var property = this.representedObject; | |
474 var title = document.createDocumentFragment(); | |
475 title.createChild("div", "selection"); | |
476 var nameElement = title.createChild("span", "name"); | |
477 nameElement.textContent = property.name; | |
478 var separatorElement = title.createChild("span", "separator"); | |
479 separatorElement.textContent = ": "; | |
480 if (property.value === null || typeof property.value !== "object") { | |
481 var valueElement = title.createChild("span", "value"); | |
482 valueElement.textContent = JSON.stringify(property.value); | |
483 valueElement.classList.add("console-formatted-" + this._type(propert y.value)); | |
484 } | |
485 this.title = title; | |
486 }, | |
487 | |
488 __proto__: TreeElement.prototype | |
489 }; | |
490 | |
491 /** | |
492 * @param {!TreeElement} element | |
493 * @param {string} name | |
494 * @param {*} value | |
495 */ | |
496 WebInspector.LogPropertyTreeElement.appendLogPropertyItem = function(element, na me, value) | |
497 { | |
498 var treeElement = new WebInspector.LogPropertyTreeElement({name: name, value : value}); | |
499 element.appendChild(treeElement); | |
500 if (value && typeof value === "object") { | |
501 for (var property in value) | |
502 WebInspector.LogPropertyTreeElement.appendLogPropertyItem(treeElemen t, property, value[property]); | |
503 } | |
504 }; | |
505 | |
506 /** | |
448 * @return {!Object.<string, !WebInspector.PaintProfilerCategory>} | 507 * @return {!Object.<string, !WebInspector.PaintProfilerCategory>} |
449 */ | 508 */ |
450 WebInspector.PaintProfilerView.categories = function() | 509 WebInspector.PaintProfilerView.categories = function() |
451 { | 510 { |
452 if (WebInspector.PaintProfilerView._categories) | 511 if (WebInspector.PaintProfilerView._categories) |
453 return WebInspector.PaintProfilerView._categories; | 512 return WebInspector.PaintProfilerView._categories; |
454 WebInspector.PaintProfilerView._categories = { | 513 WebInspector.PaintProfilerView._categories = { |
455 shapes: new WebInspector.PaintProfilerCategory("shapes", WebInspector.UI String("Shapes"), "rgb(255, 161, 129)"), | 514 shapes: new WebInspector.PaintProfilerCategory("shapes", WebInspector.UI String("Shapes"), "rgb(255, 161, 129)"), |
456 bitmap: new WebInspector.PaintProfilerCategory("bitmap", WebInspector.UI String("Bitmap"), "rgb(136, 196, 255)"), | 515 bitmap: new WebInspector.PaintProfilerCategory("bitmap", WebInspector.UI String("Bitmap"), "rgb(136, 196, 255)"), |
457 text: new WebInspector.PaintProfilerCategory("text", WebInspector.UIStri ng("Text"), "rgb(180, 255, 137)"), | 516 text: new WebInspector.PaintProfilerCategory("text", WebInspector.UIStri ng("Text"), "rgb(180, 255, 137)"), |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 var method = logItem.method.toTitleCase(); | 593 var method = logItem.method.toTitleCase(); |
535 | 594 |
536 var logItemCategories = WebInspector.PaintProfilerView._initLogItemCategorie s(); | 595 var logItemCategories = WebInspector.PaintProfilerView._initLogItemCategorie s(); |
537 var result = logItemCategories[method]; | 596 var result = logItemCategories[method]; |
538 if (!result) { | 597 if (!result) { |
539 result = WebInspector.PaintProfilerView.categories()["misc"]; | 598 result = WebInspector.PaintProfilerView.categories()["misc"]; |
540 logItemCategories[method] = result; | 599 logItemCategories[method] = result; |
541 } | 600 } |
542 return result; | 601 return result; |
543 } | 602 } |
OLD | NEW |