Changeset 140157 in webkit
- Timestamp:
- Jan 18, 2013 8:49:41 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r140154 r140157 1 2013-01-18 Andrey Adaikin <aandrey@chromium.org> 2 3 Web Inspector: [Canvas] add getResourceInfo and getResourceState methods to the protocol 4 https://bugs.webkit.org/show_bug.cgi?id=107280 5 6 Reviewed by Pavel Feldman. 7 8 We need to expose replayable resource info and replay state via the protocol. 9 The ResourceInfo describes a replayable resource, i.e. the info about a resource that was stored to replay it later. 10 The ResourceState describes a current state of a resource being replayed on the back-end. 11 12 * inspector/CodeGeneratorInspector.py: 13 * inspector/InjectedScriptCanvasModule.cpp: 14 (WebCore::InjectedScriptCanvasModule::replayTraceLog): 15 (WebCore): 16 (WebCore::InjectedScriptCanvasModule::resourceInfo): 17 (WebCore::InjectedScriptCanvasModule::resourceState): 18 * inspector/InjectedScriptCanvasModule.h: 19 (InjectedScriptCanvasModule): 20 * inspector/InjectedScriptCanvasModuleSource.js: 21 (.): 22 * inspector/Inspector.json: 23 * inspector/InspectorCanvasAgent.cpp: 24 (WebCore::InspectorCanvasAgent::replayTraceLog): 25 (WebCore): 26 (WebCore::InspectorCanvasAgent::getResourceInfo): 27 (WebCore::InspectorCanvasAgent::getResourceState): 28 * inspector/InspectorCanvasAgent.h: 29 (InspectorCanvasAgent): 30 * inspector/front-end/CanvasProfileView.js: 31 (WebInspector.CanvasProfileView.prototype._replayTraceLog.didReplayTraceLog): 32 (WebInspector.CanvasProfileView.prototype._replayTraceLog): 33 1 34 2013-01-18 Sergio Villar Senin <svillar@igalia.com> 2 35 -
trunk/Source/WebCore/inspector/CodeGeneratorInspector.py
r136431 r140157 58 58 59 59 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.PropertyDescriptor", "Runtime.InternalPropertyDescriptor", 60 "Debugger.FunctionDetails", "Debugger.CallFrame", "Canvas.TraceLog", 60 "Debugger.FunctionDetails", "Debugger.CallFrame", 61 "Canvas.TraceLog", "Canvas.ResourceInfo", "Canvas.ResourceState", 61 62 # This should be a temporary hack. TimelineEvent should be created via generated C++ API. 62 63 "Timeline.TimelineEvent"]) -
trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.cpp
r135591 r140157 141 141 } 142 142 143 void InjectedScriptCanvasModule::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, String* result)143 void InjectedScriptCanvasModule::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, RefPtr<TypeBuilder::Canvas::ResourceState>* result) 144 144 { 145 145 ScriptFunctionCall function(injectedScriptObject(), "replayTraceLog"); … … 148 148 RefPtr<InspectorValue> resultValue; 149 149 makeCall(function, &resultValue); 150 if (!resultValue || resultValue->type() != InspectorValue::TypeString || !resultValue->asString(result)) 151 *errorString = "Internal error: replayTraceLog"; 150 if (!resultValue || resultValue->type() != InspectorValue::TypeObject) { 151 if (!resultValue->asString(errorString)) 152 *errorString = "Internal error: replayTraceLog"; 153 return; 154 } 155 *result = TypeBuilder::Canvas::ResourceState::runtimeCast(resultValue); 156 } 157 158 void InjectedScriptCanvasModule::resourceInfo(ErrorString* errorString, const String& resourceId, RefPtr<TypeBuilder::Canvas::ResourceInfo>* result) 159 { 160 ScriptFunctionCall function(injectedScriptObject(), "resourceInfo"); 161 function.appendArgument(resourceId); 162 RefPtr<InspectorValue> resultValue; 163 makeCall(function, &resultValue); 164 if (!resultValue || resultValue->type() != InspectorValue::TypeObject) { 165 if (!resultValue->asString(errorString)) 166 *errorString = "Internal error: resourceInfo"; 167 return; 168 } 169 *result = TypeBuilder::Canvas::ResourceInfo::runtimeCast(resultValue); 170 } 171 172 void InjectedScriptCanvasModule::resourceState(ErrorString* errorString, const String& traceLogId, const String& resourceId, RefPtr<TypeBuilder::Canvas::ResourceState>* result) 173 { 174 ScriptFunctionCall function(injectedScriptObject(), "resourceState"); 175 function.appendArgument(traceLogId); 176 function.appendArgument(resourceId); 177 RefPtr<InspectorValue> resultValue; 178 makeCall(function, &resultValue); 179 if (!resultValue || resultValue->type() != InspectorValue::TypeObject) { 180 if (!resultValue->asString(errorString)) 181 *errorString = "Internal error: resourceState"; 182 return; 183 } 184 *result = TypeBuilder::Canvas::ResourceState::runtimeCast(resultValue); 152 185 } 153 186 -
trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.h
r135591 r140157 61 61 void dropTraceLog(ErrorString*, const String&); 62 62 void traceLog(ErrorString*, const String&, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>*); 63 void replayTraceLog(ErrorString*, const String&, int, String*); 63 void replayTraceLog(ErrorString*, const String&, int, RefPtr<TypeBuilder::Canvas::ResourceState>*); 64 void resourceInfo(ErrorString*, const String&, RefPtr<TypeBuilder::Canvas::ResourceInfo>*); 65 void resourceState(ErrorString*, const String&, const String&, RefPtr<TypeBuilder::Canvas::ResourceState>*); 64 66 65 67 private: -
trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js
r140142 r140157 742 742 toDataURL: function() 743 743 { 744 var contextResource = this.contextResource(); 745 return contextResource === this ? "" : contextResource.toDataURL(); 744 return ""; 746 745 }, 747 746 … … 2608 2607 2609 2608 /** 2609 * @param {number} id 2610 * @return {ReplayableResource} 2611 */ 2612 replayableResource: function(id) 2613 { 2614 return /** @type {ReplayableResource} */ (this._replayablesCache.get(id)); 2615 }, 2616 2617 /** 2610 2618 * @param {!Resource} resource 2611 2619 */ … … 2645 2653 { 2646 2654 return this._traceLog; 2655 }, 2656 2657 /** 2658 * @param {number} id 2659 * @return {Resource} 2660 */ 2661 replayWorldResource: function(id) 2662 { 2663 return /** @type {Resource} */ (this._replayWorldCache.get(id)); 2647 2664 }, 2648 2665 … … 2898 2915 * @param {string} id 2899 2916 * @param {number=} startOffset 2900 * @return { Object|string}2917 * @return {!Object|string} 2901 2918 */ 2902 2919 traceLog: function(id, startOffset) … … 2904 2921 var traceLog = this._traceLogs[id]; 2905 2922 if (!traceLog) 2906 return "Error: Trace log with th isID not found.";2923 return "Error: Trace log with the given ID not found."; 2907 2924 startOffset = Math.max(0, startOffset || 0); 2908 2925 var alive = this._manager.capturing() && this._manager.lastTraceLog() === traceLog; … … 2920 2937 var callFrame = stackTrace ? stackTrace.callFrame(0) || {} : {}; 2921 2938 var traceLogItem = { 2922 contextId: this._make ContextId(contextResource.id()),2939 contextId: this._makeStringResourceId(contextResource.id()), 2923 2940 sourceURL: callFrame.sourceURL, 2924 2941 lineNumber: callFrame.lineNumber, … … 2953 2970 2954 2971 /** 2955 * @param {string} id2972 * @param {string} traceLogId 2956 2973 * @param {number} stepNo 2957 * @return { string}2958 */ 2959 replayTraceLog: function( id, stepNo)2960 { 2961 var traceLog = this._traceLogs[ id];2974 * @return {!Object|string} 2975 */ 2976 replayTraceLog: function(traceLogId, stepNo) 2977 { 2978 var traceLog = this._traceLogs[traceLogId]; 2962 2979 if (!traceLog) 2963 return ""; 2964 this._traceLogPlayers[id] = this._traceLogPlayers[id] || new TraceLogPlayer(traceLog); 2965 var lastCall = this._traceLogPlayers[id].stepTo(stepNo); 2966 return lastCall.resource().toDataURL(); 2980 return "Error: Trace log with the given ID not found."; 2981 this._traceLogPlayers[traceLogId] = this._traceLogPlayers[traceLogId] || new TraceLogPlayer(traceLog); 2982 var lastCall = this._traceLogPlayers[traceLogId].stepTo(stepNo); 2983 var resource = lastCall.resource(); 2984 var dataURL = resource.toDataURL(); 2985 if (!dataURL) { 2986 resource = resource.contextResource(); 2987 dataURL = resource.toDataURL(); 2988 } 2989 return this._makeResourceState(this._makeStringResourceId(resource.id()), traceLogId, dataURL); 2990 }, 2991 2992 /** 2993 * @param {string} stringResourceId 2994 * @return {!Object|string} 2995 */ 2996 resourceInfo: function(stringResourceId) 2997 { 2998 var resourceId = this._parseStringId(stringResourceId).resourceId; 2999 if (!resourceId) 3000 return "Error: Wrong resource ID: " + stringResourceId; 3001 3002 var replayableResource = null; 3003 for (var id in this._traceLogs) { 3004 replayableResource = this._traceLogs[id].replayableResource(resourceId); 3005 if (replayableResource) 3006 break; 3007 } 3008 if (!replayableResource) 3009 return "Error: Resource with the given ID not found."; 3010 3011 return this._makeResourceInfo(stringResourceId, replayableResource.description()); 3012 }, 3013 3014 /** 3015 * @param {string} traceLogId 3016 * @param {string} stringResourceId 3017 * @return {!Object|string} 3018 */ 3019 resourceState: function(traceLogId, stringResourceId) 3020 { 3021 var traceLog = this._traceLogs[traceLogId]; 3022 if (!traceLog) 3023 return "Error: Trace log with the given ID not found."; 3024 3025 var traceLogPlayer = this._traceLogPlayers[traceLogId]; 3026 if (!traceLogPlayer) 3027 return "Error: Trace log replay has not started yet."; 3028 3029 var parsedStringId1 = this._parseStringId(traceLogId); 3030 var parsedStringId2 = this._parseStringId(stringResourceId); 3031 if (parsedStringId1.injectedScriptId !== parsedStringId2.injectedScriptId) 3032 return "Error: Both IDs must point to the same injected script."; 3033 3034 var resourceId = parsedStringId2.resourceId; 3035 if (!resourceId) 3036 return "Error: Wrong resource ID: " + stringResourceId; 3037 3038 var resource = traceLogPlayer.replayWorldResource(resourceId); 3039 if (!resource) 3040 return "Error: Resource with the given ID has not been replayed yet."; 3041 3042 return this._makeResourceState(stringResourceId, traceLogId, resource.toDataURL()); 2967 3043 }, 2968 3044 … … 2979 3055 * @return {string} 2980 3056 */ 2981 _makeContextId: function(resourceId) 2982 { 2983 return "{\"injectedScriptId\":" + injectedScriptId + ",\"canvasContextId\":" + resourceId + "}"; 3057 _makeStringResourceId: function(resourceId) 3058 { 3059 return "{\"injectedScriptId\":" + injectedScriptId + ",\"resourceId\":" + resourceId + "}"; 3060 }, 3061 3062 /** 3063 * @param {string} stringResourceId 3064 * @param {string} description 3065 * @return {!Object} 3066 */ 3067 _makeResourceInfo: function(stringResourceId, description) 3068 { 3069 return { 3070 id: stringResourceId, 3071 description: description 3072 }; 3073 }, 3074 3075 /** 3076 * @param {string} stringResourceId 3077 * @param {string} traceLogId 3078 * @param {string} imageURL 3079 * @return {!Object} 3080 */ 3081 _makeResourceState: function(stringResourceId, traceLogId, imageURL) 3082 { 3083 return { 3084 id: stringResourceId, 3085 traceLogId: traceLogId, 3086 imageURL: imageURL 3087 }; 3088 }, 3089 3090 /** 3091 * @param {string} stringId 3092 * @return {{injectedScriptId: number, traceLogId: ?number, resourceId: ?number}} 3093 */ 3094 _parseStringId: function(stringId) 3095 { 3096 return InjectedScriptHost.evaluate("(" + stringId + ")"); 2984 3097 } 2985 3098 } -
trunk/Source/WebCore/inspector/Inspector.json
r139998 r140157 3195 3195 "types": [ 3196 3196 { 3197 "id": " ContextId",3197 "id": "ResourceId", 3198 3198 "type": "string", 3199 "description": "Unique context identifier." 3199 "description": "Unique resource identifier." 3200 }, 3201 { 3202 "id": "ResourceInfo", 3203 "type": "object", 3204 "properties": [ 3205 { "name": "id", "$ref": "ResourceId" }, 3206 { "name": "description", "type": "string" } 3207 ] 3208 }, 3209 { 3210 "id": "ResourceState", 3211 "type": "object", 3212 "properties": [ 3213 { "name": "id", "$ref": "ResourceId" }, 3214 { "name": "traceLogId", "$ref": "TraceLogId" }, 3215 { "name": "imageURL", "type": "string", "optional": true, "description": "Screenshot image data URL." } 3216 ] 3200 3217 }, 3201 3218 { … … 3210 3227 "type": "object", 3211 3228 "properties": [ 3212 { "name": "contextId", "$ref": " ContextId" },3229 { "name": "contextId", "$ref": "ResourceId" }, 3213 3230 { "name": "functionName", "type": "string", "optional": true }, 3214 3231 { "name": "arguments", "type": "array", "items": { "$ref": "CallArgument" }, "optional": true }, … … 3294 3311 ], 3295 3312 "returns": [ 3296 { "name": "screenshotDataUrl", "type": "string" } 3313 { "name": "resourceState", "$ref": "ResourceState" } 3314 ] 3315 }, 3316 { 3317 "name": "getResourceInfo", 3318 "parameters": [ 3319 { "name": "resourceId", "$ref": "ResourceId" } 3320 ], 3321 "returns": [ 3322 { "name": "resourceInfo", "$ref": "ResourceInfo" } 3323 ] 3324 }, 3325 { 3326 "name": "getResourceState", 3327 "parameters": [ 3328 { "name": "traceLogId", "$ref": "TraceLogId" }, 3329 { "name": "resourceId", "$ref": "ResourceId" } 3330 ], 3331 "returns": [ 3332 { "name": "resourceState", "$ref": "ResourceState" } 3297 3333 ] 3298 3334 } -
trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp
r138497 r140157 165 165 } 166 166 167 void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, String* result) 168 { 169 if (!checkIsEnabled(errorString)) 170 return; 171 InjectedScriptCanvasModule module = injectedScriptCanvasModuleForTraceLogId(errorString, traceLogId); 172 if (!module.hasNoValue()) 173 module.replayTraceLog(errorString, traceLogId, stepNo, result); 167 void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, RefPtr<TypeBuilder::Canvas::ResourceState>& result) 168 { 169 if (!checkIsEnabled(errorString)) 170 return; 171 InjectedScriptCanvasModule module = injectedScriptCanvasModuleForTraceLogId(errorString, traceLogId); 172 if (!module.hasNoValue()) 173 module.replayTraceLog(errorString, traceLogId, stepNo, &result); 174 } 175 176 void InspectorCanvasAgent::getResourceInfo(ErrorString* errorString, const String& resourceId, RefPtr<TypeBuilder::Canvas::ResourceInfo>& result) 177 { 178 if (!checkIsEnabled(errorString)) 179 return; 180 InjectedScriptCanvasModule module = injectedScriptCanvasModuleForTraceLogId(errorString, resourceId); 181 if (!module.hasNoValue()) 182 module.resourceInfo(errorString, resourceId, &result); 183 } 184 185 void InspectorCanvasAgent::getResourceState(ErrorString* errorString, const String& traceLogId, const String& resourceId, RefPtr<TypeBuilder::Canvas::ResourceState>& result) 186 { 187 if (!checkIsEnabled(errorString)) 188 return; 189 InjectedScriptCanvasModule module = injectedScriptCanvasModuleForTraceLogId(errorString, traceLogId); 190 if (!module.hasNoValue()) 191 module.resourceState(errorString, traceLogId, resourceId, &result); 174 192 } 175 193 -
trunk/Source/WebCore/inspector/InspectorCanvasAgent.h
r138497 r140157 85 85 virtual void stopCapturing(ErrorString*, const String&); 86 86 virtual void getTraceLog(ErrorString*, const String&, const int*, RefPtr<TypeBuilder::Canvas::TraceLog>&); 87 virtual void replayTraceLog(ErrorString*, const String&, int, String*); 87 virtual void replayTraceLog(ErrorString*, const String&, int, RefPtr<TypeBuilder::Canvas::ResourceState>&); 88 virtual void getResourceInfo(ErrorString*, const String&, RefPtr<TypeBuilder::Canvas::ResourceInfo>&); 89 virtual void getResourceState(ErrorString*, const String&, const String&, RefPtr<TypeBuilder::Canvas::ResourceState>&); 88 90 89 91 private: -
trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js
r139729 r140157 184 184 return; 185 185 var time = Date.now(); 186 function didReplayTraceLog(error, dataURL)186 function didReplayTraceLog(error, resourceState) 187 187 { 188 188 if (callNode !== this._logGrid.selectedNode) … … 192 192 return; 193 193 this._debugInfoElement.textContent = "Replay time: " + (Date.now() - time) + "ms"; 194 this._replayImageElement.src = dataURL;194 this._replayImageElement.src = resourceState.imageURL; 195 195 } 196 196 this._enableWaitIcon(true);
Note: See TracChangeset
for help on using the changeset viewer.