| 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 treeElement = new WebInspector.LogTreeElement(this, logItem); |
| 277 treeOutline.appendChild(treeElement); |
| 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 this.hasChildren = !!this.representedObject.params; |
| 353 }, |
| 354 |
| 355 onexpand: function() |
| 356 { |
| 357 if (this._filled) |
| 358 return; |
| 359 this._filled = true; |
| 360 for (var param in this.representedObject.params) |
| 361 WebInspector.LogPropertyTreeElement._appendLogPropertyItem(this, par
am, this.representedObject.params[param]); |
| 362 }, |
| 363 |
| 365 /** | 364 /** |
| 366 * @param {!Object} param | 365 * @param {!Object} param |
| 367 * @param {string} name | 366 * @param {string} name |
| 368 * @return {string} | 367 * @return {string} |
| 369 */ | 368 */ |
| 370 _paramToString: function(param, name) | 369 _paramToString: function(param, name) |
| 371 { | 370 { |
| 372 if (typeof param !== "object") | 371 if (typeof param !== "object") |
| 373 return typeof param === "string" && param.length > 100 ? name : JSON
.stringify(param); | 372 return typeof param === "string" && param.length > 100 ? name : JSON
.stringify(param); |
| 374 var str = ""; | 373 var str = ""; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 396 str += this._paramToString(params[key], key); | 395 str += this._paramToString(params[key], key); |
| 397 } | 396 } |
| 398 return str; | 397 return str; |
| 399 }, | 398 }, |
| 400 | 399 |
| 401 _update: function() | 400 _update: function() |
| 402 { | 401 { |
| 403 var logItem = this.representedObject; | 402 var logItem = this.representedObject; |
| 404 var title = document.createDocumentFragment(); | 403 var title = document.createDocumentFragment(); |
| 405 title.createChild("div", "selection"); | 404 title.createChild("div", "selection"); |
| 406 var span = title.createChild("span"); | 405 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; | 406 this.title = title; |
| 412 }, | 407 }, |
| 413 | 408 |
| 414 /** | 409 /** |
| 415 * @param {boolean} hovered | 410 * @param {boolean} hovered |
| 416 */ | 411 */ |
| 417 setHovered: function(hovered) | 412 setHovered: function(hovered) |
| 418 { | 413 { |
| 419 this.listItemElement.classList.toggle("hovered", hovered); | 414 this.listItemElement.classList.toggle("hovered", hovered); |
| 420 var target = this._ownerView._target; | 415 var target = this._ownerView._target; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 438 { | 433 { |
| 439 if (node) | 434 if (node) |
| 440 node.highlight(); | 435 node.highlight(); |
| 441 } | 436 } |
| 442 }, | 437 }, |
| 443 | 438 |
| 444 __proto__: TreeElement.prototype | 439 __proto__: TreeElement.prototype |
| 445 }; | 440 }; |
| 446 | 441 |
| 447 /** | 442 /** |
| 443 * @constructor |
| 444 * @param {!{name: string, value}} property |
| 445 * @extends {TreeElement} |
| 446 */ |
| 447 WebInspector.LogPropertyTreeElement = function(property) |
| 448 { |
| 449 TreeElement.call(this, "", property); |
| 450 }; |
| 451 |
| 452 /** |
| 453 * @param {!TreeElement} element |
| 454 * @param {string} name |
| 455 * @param {*} value |
| 456 */ |
| 457 WebInspector.LogPropertyTreeElement._appendLogPropertyItem = function(element, n
ame, value) |
| 458 { |
| 459 var treeElement = new WebInspector.LogPropertyTreeElement({name: name, value
: value}); |
| 460 element.appendChild(treeElement); |
| 461 if (value && typeof value === "object") { |
| 462 for (var property in value) |
| 463 WebInspector.LogPropertyTreeElement._appendLogPropertyItem(treeEleme
nt, property, value[property]); |
| 464 } |
| 465 }; |
| 466 |
| 467 WebInspector.LogPropertyTreeElement.prototype = { |
| 468 onattach: function() |
| 469 { |
| 470 var property = this.representedObject; |
| 471 var title = document.createDocumentFragment(); |
| 472 title.createChild("div", "selection"); |
| 473 var nameElement = title.createChild("span", "name"); |
| 474 nameElement.textContent = property.name; |
| 475 var separatorElement = title.createChild("span", "separator"); |
| 476 separatorElement.textContent = ": "; |
| 477 if (property.value === null || typeof property.value !== "object") { |
| 478 var valueElement = title.createChild("span", "value"); |
| 479 valueElement.textContent = JSON.stringify(property.value); |
| 480 valueElement.classList.add("console-formatted-" + property.value ===
null ? "null" : typeof property.value); |
| 481 } |
| 482 this.title = title; |
| 483 }, |
| 484 |
| 485 __proto__: TreeElement.prototype |
| 486 } |
| 487 |
| 488 /** |
| 448 * @return {!Object.<string, !WebInspector.PaintProfilerCategory>} | 489 * @return {!Object.<string, !WebInspector.PaintProfilerCategory>} |
| 449 */ | 490 */ |
| 450 WebInspector.PaintProfilerView.categories = function() | 491 WebInspector.PaintProfilerView.categories = function() |
| 451 { | 492 { |
| 452 if (WebInspector.PaintProfilerView._categories) | 493 if (WebInspector.PaintProfilerView._categories) |
| 453 return WebInspector.PaintProfilerView._categories; | 494 return WebInspector.PaintProfilerView._categories; |
| 454 WebInspector.PaintProfilerView._categories = { | 495 WebInspector.PaintProfilerView._categories = { |
| 455 shapes: new WebInspector.PaintProfilerCategory("shapes", WebInspector.UI
String("Shapes"), "rgb(255, 161, 129)"), | 496 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)"), | 497 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)"), | 498 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(); | 575 var method = logItem.method.toTitleCase(); |
| 535 | 576 |
| 536 var logItemCategories = WebInspector.PaintProfilerView._initLogItemCategorie
s(); | 577 var logItemCategories = WebInspector.PaintProfilerView._initLogItemCategorie
s(); |
| 537 var result = logItemCategories[method]; | 578 var result = logItemCategories[method]; |
| 538 if (!result) { | 579 if (!result) { |
| 539 result = WebInspector.PaintProfilerView.categories()["misc"]; | 580 result = WebInspector.PaintProfilerView.categories()["misc"]; |
| 540 logItemCategories[method] = result; | 581 logItemCategories[method] = result; |
| 541 } | 582 } |
| 542 return result; | 583 return result; |
| 543 } | 584 } |
| OLD | NEW |