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); | |
caseq
2014/07/31 14:20:37
s/first/treeElement/?
malch
2014/07/31 14:27:33
Done.
| |
277 treeOutline.appendChild(first); | |
278 }, | |
279 | |
280 /** | |
272 * @param {number=} stepLeft | 281 * @param {number=} stepLeft |
273 * @param {number=} stepRight | 282 * @param {number=} stepRight |
274 */ | 283 */ |
275 updateWindow: function(stepLeft, stepRight) | 284 updateWindow: function(stepLeft, stepRight) |
276 { | 285 { |
277 stepLeft = stepLeft || 0; | 286 stepLeft = stepLeft || 0; |
278 stepRight = stepRight || this._log.length - 1; | 287 stepRight = stepRight || this._log.length - 1; |
279 this.sidebarTree.removeChildren(); | 288 this.sidebarTree.removeChildren(); |
280 for (var i = stepLeft; i <= stepRight; ++i) { | 289 for (var i = stepLeft; i <= stepRight; ++i) |
281 var node = new WebInspector.LogTreeElement(this, this._log[i]); | 290 this._appendLogItem(this.sidebarTree, this._log[i]); |
282 this.sidebarTree.appendChild(node); | |
283 } | |
284 }, | 291 }, |
285 | 292 |
286 _reset: function() | 293 _reset: function() |
287 { | 294 { |
288 this._log = []; | 295 this._log = []; |
289 }, | 296 }, |
290 | 297 |
291 /** | 298 /** |
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 | 299 * @param {?Event} event |
316 */ | 300 */ |
317 _onMouseMove: function(event) | 301 _onMouseMove: function(event) |
318 { | 302 { |
319 var node = this.sidebarTree.treeElementFromPoint(event.pageX, event.page Y); | 303 var node = this.sidebarTree.treeElementFromPoint(event.pageX, event.page Y); |
320 if (node === this._lastHoveredNode) | 304 if (node === this._lastHoveredNode || !(node instanceof WebInspector.Log TreeElement)) |
321 return; | 305 return; |
322 if (this._lastHoveredNode) | 306 if (this._lastHoveredNode) |
323 this._lastHoveredNode.setHovered(false); | 307 this._lastHoveredNode.setHovered(false); |
324 this._lastHoveredNode = node; | 308 this._lastHoveredNode = node; |
325 if (this._lastHoveredNode) | 309 if (this._lastHoveredNode) |
326 this._lastHoveredNode.setHovered(true); | 310 this._lastHoveredNode.setHovered(true); |
327 }, | 311 }, |
328 | 312 |
329 /** | 313 /** |
330 * @param {?Event} event | 314 * @param {?Event} event |
331 */ | 315 */ |
332 _onContextMenu: function(event) | 316 _onContextMenu: function(event) |
333 { | 317 { |
334 if (!this._target) | 318 if (!this._target) |
335 return; | 319 return; |
336 var node = this.sidebarTree.treeElementFromPoint(event.pageX, event.page Y); | 320 var node = this.sidebarTree.treeElementFromPoint(event.pageX, event.page Y); |
337 if (!node || !node.representedObject) | 321 if (!node || !node.representedObject || !(node instanceof WebInspector.L ogTreeElement)) |
338 return; | 322 return; |
339 var logItem = /** @type {!WebInspector.PaintProfilerLogItem} */ (node.re presentedObject); | 323 var logItem = /** @type {!WebInspector.PaintProfilerLogItem} */ (node.re presentedObject); |
340 if (!logItem.nodeId()) | 324 if (!logItem.nodeId()) |
341 return; | 325 return; |
342 var contextMenu = new WebInspector.ContextMenu(event); | 326 var contextMenu = new WebInspector.ContextMenu(event); |
343 var domNode = new WebInspector.DeferredDOMNode(this._target, logItem.nod eId()); | 327 var domNode = new WebInspector.DeferredDOMNode(this._target, logItem.nod eId()); |
344 contextMenu.appendApplicableItems(domNode); | 328 contextMenu.appendApplicableItems(domNode); |
345 contextMenu.show(); | 329 contextMenu.show(); |
346 }, | 330 }, |
347 | 331 |
348 __proto__: WebInspector.VBox.prototype | 332 __proto__: WebInspector.VBox.prototype |
349 }; | 333 }; |
350 | 334 |
351 /** | 335 /** |
352 * @constructor | 336 * @constructor |
353 * @param {!WebInspector.PaintProfilerCommandLogView} ownerView | 337 * @param {!WebInspector.PaintProfilerCommandLogView} ownerView |
354 * @param {!WebInspector.PaintProfilerLogItem} logItem | 338 * @param {!WebInspector.PaintProfilerLogItem} logItem |
355 * @extends {TreeElement} | 339 * @extends {TreeElement} |
356 */ | 340 */ |
357 WebInspector.LogTreeElement = function(ownerView, logItem) | 341 WebInspector.LogTreeElement = function(ownerView, logItem) |
358 { | 342 { |
359 TreeElement.call(this, "", logItem); | 343 TreeElement.call(this, "", logItem); |
360 this._ownerView = ownerView; | 344 this._ownerView = ownerView; |
361 this._update(); | 345 this._filled = false; |
362 } | 346 } |
363 | 347 |
364 WebInspector.LogTreeElement.prototype = { | 348 WebInspector.LogTreeElement.prototype = { |
349 onattach: function() | |
350 { | |
351 this._update(); | |
352 if (this.representedObject.params) | |
353 this.hasChildren = true; | |
caseq
2014/07/31 14:20:37
nit: this.hasChildren = !!this.representedObject.p
malch
2014/07/31 14:27:33
Done.
| |
354 }, | |
355 | |
356 onexpand: function() | |
357 { | |
358 if (this._filled) | |
359 return; | |
360 this._filled = true; | |
361 for (var param in this.representedObject.params) | |
362 WebInspector.LogPropertyTreeElement._appendLogPropertyItem(this, par am, this.representedObject.params[param]); | |
363 }, | |
364 | |
365 /** | 365 /** |
366 * @param {!Object} param | 366 * @param {!Object} param |
367 * @param {string} name | 367 * @param {string} name |
368 * @return {string} | 368 * @return {string} |
369 */ | 369 */ |
370 _paramToString: function(param, name) | 370 _paramToString: function(param, name) |
371 { | 371 { |
372 if (typeof param !== "object") | 372 if (typeof param !== "object") |
373 return typeof param === "string" && param.length > 100 ? name : JSON .stringify(param); | 373 return typeof param === "string" && param.length > 100 ? name : JSON .stringify(param); |
374 var str = ""; | 374 var str = ""; |
(...skipping 21 matching lines...) Expand all Loading... | |
396 str += this._paramToString(params[key], key); | 396 str += this._paramToString(params[key], key); |
397 } | 397 } |
398 return str; | 398 return str; |
399 }, | 399 }, |
400 | 400 |
401 _update: function() | 401 _update: function() |
402 { | 402 { |
403 var logItem = this.representedObject; | 403 var logItem = this.representedObject; |
404 var title = document.createDocumentFragment(); | 404 var title = document.createDocumentFragment(); |
405 title.createChild("div", "selection"); | 405 title.createChild("div", "selection"); |
406 var span = title.createChild("span"); | 406 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; | 407 this.title = title; |
412 }, | 408 }, |
413 | 409 |
414 /** | 410 /** |
415 * @param {boolean} hovered | 411 * @param {boolean} hovered |
416 */ | 412 */ |
417 setHovered: function(hovered) | 413 setHovered: function(hovered) |
418 { | 414 { |
419 this.listItemElement.classList.toggle("hovered", hovered); | 415 this.listItemElement.classList.toggle("hovered", hovered); |
420 var target = this._ownerView._target; | 416 var target = this._ownerView._target; |
(...skipping 17 matching lines...) Expand all Loading... | |
438 { | 434 { |
439 if (node) | 435 if (node) |
440 node.highlight(); | 436 node.highlight(); |
441 } | 437 } |
442 }, | 438 }, |
443 | 439 |
444 __proto__: TreeElement.prototype | 440 __proto__: TreeElement.prototype |
445 }; | 441 }; |
446 | 442 |
447 /** | 443 /** |
444 * @constructor | |
445 * @param {!{name: string, value}} property | |
446 * @extends {TreeElement} | |
447 */ | |
448 WebInspector.LogPropertyTreeElement = function(property) | |
449 { | |
450 TreeElement.call(this, "", property); | |
451 }; | |
452 | |
453 /** | |
454 * @param {!TreeElement} element | |
455 * @param {string} name | |
456 * @param {*} value | |
457 */ | |
458 WebInspector.LogPropertyTreeElement._appendLogPropertyItem = function(element, n ame, value) | |
459 { | |
460 var treeElement = new WebInspector.LogPropertyTreeElement({name: name, value : value}); | |
461 element.appendChild(treeElement); | |
462 if (value && typeof value === "object") { | |
463 for (var property in value) | |
464 WebInspector.LogPropertyTreeElement._appendLogPropertyItem(treeEleme nt, property, value[property]); | |
465 } | |
466 }; | |
467 | |
468 WebInspector.LogPropertyTreeElement.prototype = { | |
469 onattach: function() | |
470 { | |
471 this._update(); | |
472 }, | |
473 | |
474 /** | |
475 * @param {*} value | |
476 * @return {string} | |
477 */ | |
478 _type: function(value) | |
479 { | |
480 return value === null ? "null" : typeof value; | |
481 }, | |
482 | |
483 _update: function() | |
484 { | |
485 var property = this.representedObject; | |
486 var title = document.createDocumentFragment(); | |
487 title.createChild("div", "selection"); | |
488 var nameElement = title.createChild("span", "name"); | |
489 nameElement.textContent = property.name; | |
490 var separatorElement = title.createChild("span", "separator"); | |
491 separatorElement.textContent = ": "; | |
492 if (property.value === null || typeof property.value !== "object") { | |
493 var valueElement = title.createChild("span", "value"); | |
494 valueElement.textContent = JSON.stringify(property.value); | |
495 valueElement.classList.add("console-formatted-" + this._type(propert y.value)); | |
496 } | |
497 this.title = title; | |
498 }, | |
499 | |
500 __proto__: TreeElement.prototype | |
501 }; | |
502 | |
503 /** | |
448 * @return {!Object.<string, !WebInspector.PaintProfilerCategory>} | 504 * @return {!Object.<string, !WebInspector.PaintProfilerCategory>} |
449 */ | 505 */ |
450 WebInspector.PaintProfilerView.categories = function() | 506 WebInspector.PaintProfilerView.categories = function() |
451 { | 507 { |
452 if (WebInspector.PaintProfilerView._categories) | 508 if (WebInspector.PaintProfilerView._categories) |
453 return WebInspector.PaintProfilerView._categories; | 509 return WebInspector.PaintProfilerView._categories; |
454 WebInspector.PaintProfilerView._categories = { | 510 WebInspector.PaintProfilerView._categories = { |
455 shapes: new WebInspector.PaintProfilerCategory("shapes", WebInspector.UI String("Shapes"), "rgb(255, 161, 129)"), | 511 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)"), | 512 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)"), | 513 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(); | 590 var method = logItem.method.toTitleCase(); |
535 | 591 |
536 var logItemCategories = WebInspector.PaintProfilerView._initLogItemCategorie s(); | 592 var logItemCategories = WebInspector.PaintProfilerView._initLogItemCategorie s(); |
537 var result = logItemCategories[method]; | 593 var result = logItemCategories[method]; |
538 if (!result) { | 594 if (!result) { |
539 result = WebInspector.PaintProfilerView.categories()["misc"]; | 595 result = WebInspector.PaintProfilerView.categories()["misc"]; |
540 logItemCategories[method] = result; | 596 logItemCategories[method] = result; |
541 } | 597 } |
542 return result; | 598 return result; |
543 } | 599 } |
OLD | NEW |