Changeset 140160 in webkit
- Timestamp:
- Jan 18, 2013 9:05:12 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r140157 r140160 1 2013-01-18 Andrey Adaikin <aandrey@chromium.org> 2 3 Web Inspector: [Canvas] UI: add a context selector to show screenshot of any canvas in the log 4 https://bugs.webkit.org/show_bug.cgi?id=107274 5 6 Reviewed by Pavel Feldman. 7 8 Adding a canvas context selector to display in the replay image screenshot. 9 Drive-by: Reuse common CSS class "status-bar-item" to remove a lot of CSS duplication. 10 11 * English.lproj/localizedStrings.js: 12 * inspector/front-end/CanvasProfileView.js: 13 (WebInspector.CanvasProfileView): 14 (WebInspector.CanvasProfileView.prototype._createControlButton): 15 (WebInspector.CanvasProfileView.prototype._onReplayContextChanged): 16 (WebInspector.CanvasProfileView.prototype._onReplayFirstStepClick): 17 (WebInspector.CanvasProfileView.prototype._onReplayLastStepClick): 18 (WebInspector.CanvasProfileView.prototype._enableWaitIcon): 19 (WebInspector.CanvasProfileView.prototype._replayTraceLog.didReplayTraceLog): 20 (WebInspector.CanvasProfileView.prototype._replayTraceLog): 21 (WebInspector.CanvasProfileView.prototype._didReceiveTraceLog): 22 (WebInspector.CanvasProfileView.prototype._requestReplayContextInfo.didReceiveResourceInfo): 23 (WebInspector.CanvasProfileView.prototype._requestReplayContextInfo): 24 * inspector/front-end/canvasProfiler.css: 25 * inspector/front-end/inspector.css: 26 (.status-bar button.status-bar-item img): 27 1 28 2013-01-18 Andrey Adaikin <aandrey@chromium.org> 2 29 -
trunk/Source/WebCore/English.lproj/localizedStrings.js
r140124 r140160 783 783 localizedStrings["Next call."] = "Next call."; 784 784 localizedStrings["Last call."] = "Last call."; 785 localizedStrings["Show screenshot of the last replayed resource."] = "Show screenshot of the last replayed resource."; 786 localizedStrings["Show screenshot of this context's canvas."] = "Show screenshot of this context's canvas."; 785 787 localizedStrings["Reload"] = "Reload"; 786 788 localizedStrings["Binary File"] = "Binary File"; -
trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js
r140157 r140160 50 50 51 51 var replayInfoContainer = this._splitView.secondElement(); 52 var controlsContainer = replayInfoContainer.createChild("div", " canvas-replay-controls");52 var controlsContainer = replayInfoContainer.createChild("div", "status-bar"); 53 53 var logGridContainer = replayInfoContainer.createChild("div", "canvas-replay-log"); 54 54 … … 57 57 this._createControlButton(controlsContainer, "canvas-replay-next-step", WebInspector.UIString("Next call."), this._onReplayStepClick.bind(this, true)); 58 58 this._createControlButton(controlsContainer, "canvas-replay-last-step", WebInspector.UIString("Last call."), this._onReplayLastStepClick.bind(this)); 59 60 this._replayContextSelector = new WebInspector.StatusBarComboBox(this._onReplayContextChanged.bind(this)); 61 this._replayContextSelector.createOption("<screenshot auto>", WebInspector.UIString("Show screenshot of the last replayed resource."), ""); 62 controlsContainer.appendChild(this._replayContextSelector.element); 63 64 /** @type {!Object.<string, boolean>} */ 65 this._replayContexts = {}; 66 /** @type {!Object.<string, CanvasAgent.ResourceState>} */ 67 this._currentResourceStates = {}; 59 68 60 69 var columns = { 0: {}, 1: {}, 2: {} }; … … 114 123 _createControlButton: function(parent, className, title, clickCallback) 115 124 { 116 var button = parent.createChild("button", " canvas-control-button");125 var button = parent.createChild("button", "status-bar-item"); 117 126 button.addStyleClass(className); 118 127 button.title = title; 119 128 button.createChild("img"); 120 129 button.addEventListener("click", clickCallback, false); 130 }, 131 132 _onReplayContextChanged: function() 133 { 134 /** 135 * @param {string?} error 136 * @param {CanvasAgent.ResourceState} resourceState 137 */ 138 function didReceiveResourceState(error, resourceState) 139 { 140 this._enableWaitIcon(false); 141 if (error) 142 return; 143 144 this._currentResourceStates[resourceState.id] = resourceState; 145 146 var selectedContextId = this._replayContextSelector.selectedOption().value; 147 if (selectedContextId === resourceState.id) 148 this._replayImageElement.src = resourceState.imageURL; 149 } 150 151 var selectedContextId = this._replayContextSelector.selectedOption().value || "auto"; 152 var resourceState = this._currentResourceStates[selectedContextId]; 153 if (resourceState) 154 this._replayImageElement.src = resourceState.imageURL; 155 else { 156 this._enableWaitIcon(true); 157 this._replayImageElement.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; // Empty transparent image. 158 CanvasAgent.getResourceState(this._traceLogId, selectedContextId, didReceiveResourceState.bind(this)); 159 } 121 160 }, 122 161 … … 138 177 _onReplayFirstStepClick: function() 139 178 { 140 var rootNode = this._logGrid.rootNode(); 141 var children = rootNode && rootNode.children; 142 var firstNode = children && children[0]; 179 var firstNode = this._logGrid.rootNode().children[0]; 143 180 if (firstNode) 144 181 firstNode.revealAndSelect(); … … 147 184 _onReplayLastStepClick: function() 148 185 { 149 var rootNode = this._logGrid.rootNode(); 150 var children = rootNode && rootNode.children; 151 var lastNode = children && children[children.length - 1]; 186 var children = this._logGrid.rootNode().children; 187 var lastNode = children[children.length - 1]; 152 188 if (lastNode) 153 189 lastNode.revealAndSelect(); … … 162 198 { 163 199 this._replayImageElement.addStyleClass("wait"); 164 this._debugInfoElement. textContent = "";200 this._debugInfoElement.addStyleClass("hidden"); 165 201 delete this._showWaitIconTimer; 166 202 } … … 174 210 } 175 211 this._replayImageElement.enableStyleClass("wait", enable); 176 this._debugInfoElement. textContent = "";212 this._debugInfoElement.enableStyleClass("hidden", enable); 177 213 } 178 214 }, … … 184 220 return; 185 221 var time = Date.now(); 222 /** 223 * @param {string?} error 224 * @param {CanvasAgent.ResourceState} resourceState 225 */ 186 226 function didReplayTraceLog(error, resourceState) 187 227 { 188 228 if (callNode !== this._logGrid.selectedNode) 189 229 return; 230 190 231 this._enableWaitIcon(false); 191 232 if (error) 192 233 return; 234 235 this._currentResourceStates = {}; 236 this._currentResourceStates["auto"] = resourceState; 237 this._currentResourceStates[resourceState.id] = resourceState; 238 193 239 this._debugInfoElement.textContent = "Replay time: " + (Date.now() - time) + "ms"; 194 this._ replayImageElement.src = resourceState.imageURL;240 this._onReplayContextChanged(); 195 241 } 196 242 this._enableWaitIcon(true); … … 201 247 { 202 248 this._enableWaitIcon(false); 203 this._logGrid.rootNode().removeChildren();204 249 if (error || !traceLog) 205 250 return; 251 var lastNode = null; 206 252 var calls = traceLog.calls; 207 for (var i = 0, n = calls.length; i < n; ++i) 208 this._logGrid.rootNode().appendChild(this._createCallNode(i, calls[i])); 209 var lastNode = this._logGrid.rootNode().children[calls.length - 1]; 253 for (var i = 0, n = calls.length; i < n; ++i) { 254 var call = calls[i]; 255 this._requestReplayContextInfo(call.contextId); 256 var gridNode = this._createCallNode(i, call); 257 this._logGrid.rootNode().appendChild(gridNode); 258 lastNode = gridNode; 259 } 210 260 if (lastNode) 211 261 lastNode.revealAndSelect(); … … 213 263 214 264 /** 265 * @param {string} contextId 266 */ 267 _requestReplayContextInfo: function(contextId) 268 { 269 if (this._replayContexts[contextId]) 270 return; 271 this._replayContexts[contextId] = true; 272 /** 273 * @param {string?} error 274 * @param {CanvasAgent.ResourceInfo} resourceInfo 275 */ 276 function didReceiveResourceInfo(error, resourceInfo) 277 { 278 if (error) { 279 delete this._replayContexts[contextId]; 280 return; 281 } 282 this._replayContextSelector.createOption(resourceInfo.description, WebInspector.UIString("Show screenshot of this context's canvas."), contextId); 283 } 284 CanvasAgent.getResourceInfo(contextId, didReceiveResourceInfo.bind(this)); 285 }, 286 287 /** 215 288 * @param {number} index 216 289 * @param {Object} call 290 * @return {!WebInspector.DataGridNode} 217 291 */ 218 292 _createCallNode: function(index, call) -
trunk/Source/WebCore/inspector/front-end/canvasProfiler.css
r139614 r140160 65 65 } 66 66 67 .canvas-replay-controls {68 position: absolute;69 top: 0;70 left: 0;71 right: 0;72 height: 26px;73 border: 1px solid #aaa;74 background-image: -webkit-linear-gradient(rgb(243,243,243), rgb(235,235,235));75 }76 77 67 .canvas-replay-log { 78 68 position: absolute; … … 81 71 right: 0; 82 72 bottom: 0; 83 }84 85 .canvas-control-button {86 display: inline-block;87 position: relative;88 width: 32px;89 height: 24px;90 padding: 0;91 margin-left: -1px;92 vertical-align: top;93 background-color: transparent;94 border: 0 transparent none;95 border-left: 1px solid rgb(202, 202, 202);96 border-right: 1px solid rgb(202, 202, 202);97 }98 99 .canvas-control-button:active {100 background-color: rgb(163,163,163);101 border-left: 1px solid rgb(120, 120, 120);102 border-right: 1px solid rgb(120, 120, 120);103 }104 105 .canvas-control-button:disabled {106 opacity: 0.5;107 }108 109 .canvas-control-button img {110 margin-top: 1px;111 73 } 112 74 -
trunk/Source/WebCore/inspector/front-end/inspector.css
r138166 r140160 695 695 } 696 696 697 .status-bar button.status-bar-item img { 698 margin-top: 1px; 699 } 700 697 701 .status-bar select.status-bar-item:active, 698 702 .status-bar button.status-bar-item:active {
Note: See TracChangeset
for help on using the changeset viewer.