Changeset 126308 in webkit
- Timestamp:
- Aug 22, 2012 8:54:59 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126306 r126308 1 2012-08-22 Andrey Adaikin <aandrey@chromium.org> 2 3 Web Inspector: [WebGL] Support the communication protocol from the injected script 4 https://bugs.webkit.org/show_bug.cgi?id=94689 5 6 Reviewed by Pavel Feldman. 7 8 Support the WebGL communication protocol from the injected script module. 9 10 * inspector/InjectedScriptWebGLModuleSource.js: 11 (.): 12 1 13 2012-08-22 Gustavo Noronha Silva <gns@gnome.org> 2 14 -
trunk/Source/WebCore/inspector/InjectedScriptWebGLModuleSource.js
r126283 r126308 140 140 /** 141 141 * @constructor 142 * @param {ReplayableResource} thisObject 143 * @param {string} functionName 144 * @param {Array.<ReplayableResource|*>} args 145 * @param {ReplayableResource|*} result 146 */ 147 function ReplayableCall(thisObject, functionName, args, result) 148 { 149 this._thisObject = thisObject; 150 this._functionName = functionName; 151 this._args = args; 152 this._result = result; 153 } 154 155 ReplayableCall.prototype = { 156 /** 157 * @return {ReplayableResource} 158 */ 159 resource: function() 160 { 161 return this._thisObject; 162 }, 163 164 /** 165 * @return {string} 166 */ 167 functionName: function() 168 { 169 return this._functionName; 170 }, 171 172 /** 173 * @return {Array.<ReplayableResource|*>} 174 */ 175 args: function() 176 { 177 return this._args; 178 }, 179 180 /** 181 * @return {ReplayableResource|*} 182 */ 183 result: function() 184 { 185 return this._result; 186 }, 187 188 /** 189 * @param {Cache} cache 190 * @return {Call} 191 */ 192 replay: function(cache) 193 { 194 // FIXME: Do the replay. 195 } 196 } 197 198 /** 199 * @constructor 142 200 * @param {Object} wrappedObject 143 201 */ … … 222 280 { 223 281 object["__resourceObject"] = this; 282 } 283 } 284 285 /** 286 * @constructor 287 * @param {Resource} originalResource 288 * @param {Object} data 289 */ 290 function ReplayableResource(originalResource, data) 291 { 292 } 293 294 ReplayableResource.prototype = { 295 /** 296 * @param {Cache} cache 297 * @return {Resource} 298 */ 299 replay: function(cache) 300 { 301 // FIXME: Do the replay. 224 302 } 225 303 } … … 354 432 function TraceLog() 355 433 { 356 this._ calls = [];357 this._re sourceCache = new Cache();434 this._replayableCalls = []; 435 this._replayablesCache = new Cache(); 358 436 } 359 437 … … 364 442 size: function() 365 443 { 366 return this._calls.length; 444 return this._replayableCalls.length; 445 }, 446 447 /** 448 * @return {Array.<ReplayableCall>} 449 */ 450 replayableCalls: function() 451 { 452 return this._replayableCalls; 367 453 }, 368 454 … … 380 466 addCall: function(call) 381 467 { 382 // FIXME: Clone call and push the clone. 383 this._calls.push(call); 468 // FIXME: Convert the call to a ReplayableCall and push it. 469 } 470 } 471 472 /** 473 * @constructor 474 * @param {TraceLog} traceLog 475 */ 476 function TraceLogPlayer(traceLog) 477 { 478 this._traceLog = traceLog; 479 this._nextReplayStep = 0; 480 this._replayWorldCache = new Cache(); 481 } 482 483 TraceLogPlayer.prototype = { 484 /** 485 * @return {TraceLog} 486 */ 487 traceLog: function() 488 { 489 return this._traceLog; 490 }, 491 492 /** 493 * @return {number} 494 */ 495 nextReplayStep: function() 496 { 497 return this._nextReplayStep; 498 }, 499 500 reset: function() 501 { 502 // FIXME: Prevent memory leaks: detach and delete all old resources OR reuse them OR create a new replay canvas every time. 503 this._nextReplayStep = 0; 504 this._replayWorldCache.reset(); 505 }, 506 507 step: function() 508 { 509 this.stepTo(this._nextReplayStep); 510 }, 511 512 /** 513 * @param {number} stepNum 514 */ 515 stepTo: function(stepNum) 516 { 517 stepNum = Math.min(stepNum, this._traceLog.size() - 1); 518 console.assert(stepNum >= 0); 519 if (this._nextReplayStep > stepNum) 520 this.reset(); 521 // FIXME: Replay all the cached resources first to warm-up. 522 var replayableCalls = this._traceLog.replayableCalls(); 523 while (this._nextReplayStep <= stepNum) 524 replayableCalls[this._nextReplayStep++].replay(this._replayWorldCache); 525 }, 526 527 replay: function() 528 { 529 this.stepTo(this._traceLog.size() - 1); 384 530 } 385 531 } … … 492 638 { 493 639 this._manager = new ResourceTrackingManager(); 640 this._lastTraceLogId = 0; 641 this._traceLogs = {}; 642 this._traceLogPlayer = null; 643 this._replayContext = null; 494 644 } 495 645 … … 509 659 captureFrame: function() 510 660 { 661 var id = this._makeTraceLogId(); 511 662 this._manager.captureFrame(); 663 this._traceLogs[id] = this._manager.lastTraceLog(); 664 return id; 665 }, 666 667 /** 668 * @param {string} id 669 */ 670 dropTraceLog: function(id) 671 { 672 if (this._traceLogPlayer && this._traceLogPlayer.traceLog() === this._traceLogs[id]) 673 this._traceLogPlayer = null; 674 delete this._traceLogs[id]; 675 }, 676 677 /** 678 * @param {string} id 679 * @return {Object|string} 680 */ 681 traceLog: function(id) 682 { 683 var traceLog = this._traceLogs[id]; 684 if (!traceLog) 685 return "Error: Trace log with this ID not found."; 686 var result = { 687 id: id, 688 calls: [] 689 }; 690 var calls = traceLog.replayableCalls(); 691 for (var i = 0, n = calls.length; i < n; ++i) { 692 var call = calls[i]; 693 result.calls.push({ 694 functionName: call.functionName() + "(" + call.args().join(", ") + ") => " + call.result() 695 }); 696 } 697 return result; 698 }, 699 700 /** 701 * @param {string} id 702 * @param {number} stepNo 703 * @return {string} 704 */ 705 replayTraceLog: function(id, stepNo) 706 { 707 var traceLog = this._traceLogs[id]; 708 if (!traceLog) 709 return ""; 710 if (!this._traceLogPlayer || this._traceLogPlayer.traceLog() !== traceLog) 711 this._traceLogPlayer = new TraceLogPlayer(traceLog); 712 this._traceLogPlayer.stepTo(stepNo); 713 if (!this._replayContext) { 714 console.error("ASSERT_NOT_REACHED: replayTraceLog failed to create a replay canvas?!"); 715 return ""; 716 } 717 // Return current screenshot. 718 return this._replayContext.canvas.toDataURL(); 719 }, 720 721 /** 722 * @return {string} 723 */ 724 _makeTraceLogId: function() 725 { 726 return "{\"injectedScriptId\":" + injectedScriptId + ",\"traceLogId\":" + (++this._lastTraceLogId) + "}"; 512 727 } 513 728 }
Note: See TracChangeset
for help on using the changeset viewer.