Changeset 91252 in webkit
- Timestamp:
- Jul 19, 2011 6:45:04 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r91251 r91252 1 2011-07-19 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: implement import/export for timeline data. 4 https://bugs.webkit.org/show_bug.cgi?id=64601 5 6 Reviewed by Yury Semikhatsky. 7 8 * inspector/timeline/timeline-load-expected.txt: Added. 9 * inspector/timeline/timeline-load.html: Added. 10 1 11 2011-07-19 Gabor Loki <loki@webkit.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r91250 r91252 1 2011-07-19 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: implement import/export for timeline data. 4 https://bugs.webkit.org/show_bug.cgi?id=64601 5 6 Reviewed by Yury Semikhatsky. 7 8 Test: inspector/timeline/timeline-load.html 9 10 * English.lproj/localizedStrings.js: 11 * inspector/InspectorFrontendHost.cpp: 12 (WebCore::FrontendMenuProvider::contextMenuItemSelected): 13 * inspector/front-end/TimelinePanel.js: 14 (WebInspector.TimelinePanel): 15 (WebInspector.TimelinePanel.prototype._createFileSelector): 16 (WebInspector.TimelinePanel.prototype._contextMenu): 17 (WebInspector.TimelinePanel.prototype._exportToFile): 18 (WebInspector.TimelinePanel.prototype._importFromFile): 19 (WebInspector.TimelinePanel.prototype._addRecordToTimeline): 20 (WebInspector.TimelinePanel.prototype._clearPanel): 21 (WebInspector.TimelineModel): 22 (WebInspector.TimelineModel.prototype._addRecord): 23 (WebInspector.TimelineModel.prototype._importNextChunk): 24 (WebInspector.TimelineModel.prototype._importFromFile): 25 (WebInspector.TimelineModel.prototype._importFromFile.onError): 26 (WebInspector.TimelineModel.prototype._exportToFile): 27 (WebInspector.TimelineModel.prototype._reset): 28 * inspector/front-end/utilities.js: 29 (): 30 1 31 2011-07-19 Vsevolod Vlasov <vsevik@chromium.org> 2 32 -
trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp
r86551 r91252 48 48 #include "Pasteboard.h" 49 49 #include "ScriptFunctionCall.h" 50 #include "UserGestureIndicator.h" 50 51 51 52 #include <wtf/RefPtr.h> … … 92 93 { 93 94 if (m_frontendHost) { 95 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); 94 96 int itemNumber = item->action() - ContextMenuItemBaseCustomTag; 95 97 -
trunk/Source/WebCore/inspector/front-end/TimelinePanel.js
r91061 r91252 34 34 35 35 this.element.appendChild(this._createTopPane()); 36 this.element.addEventListener("contextmenu", this._contextMenu.bind(this), true); 36 37 this.element.tabIndex = 0; 37 38 … … 100 101 this._timeStampRecords = []; 101 102 this._expandOffset = 15; 103 104 this._createFileSelector(); 105 this._model = new WebInspector.TimelineModel(this); 102 106 103 107 WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onTimelineEventRecorded, this); … … 218 222 }, 219 223 224 _createFileSelector: function() 225 { 226 if (this._fileSelectorElement) 227 this.element.removeChild(this._fileSelectorElement); 228 229 var fileSelectorElement = document.createElement("input"); 230 fileSelectorElement.type = "file"; 231 fileSelectorElement.style.opacity = 0; 232 fileSelectorElement.onchange = this._importFromFile.bind(this); 233 this.element.appendChild(fileSelectorElement); 234 this._fileSelectorElement = fileSelectorElement; 235 }, 236 237 _contextMenu: function(event) 238 { 239 var contextMenu = new WebInspector.ContextMenu(); 240 contextMenu.appendItem(WebInspector.UIString("&Export Timeline data\u2026"), this._exportToFile.bind(this)); 241 contextMenu.appendItem(WebInspector.UIString("&Import Timeline data\u2026"), this._fileSelectorElement.click.bind(this._fileSelectorElement)); 242 contextMenu.show(event); 243 }, 244 245 _exportToFile: function() 246 { 247 this._model._exportToFile(); 248 }, 249 250 _importFromFile: function() 251 { 252 if (this.toggleTimelineButton.toggled) 253 WebInspector.timelineManager.stop(); 254 255 this._clearPanel(); 256 257 this._model._importFromFile(this._fileSelectorElement.files[0]); 258 this._createFileSelector(); 259 }, 260 220 261 _updateRecordsCounter: function() 221 262 { … … 315 356 } 316 357 } 358 this._model._addRecord(record); 317 359 this._innerAddRecordToTimeline(record, this._rootRecord); 318 360 this._scheduleRefresh(); … … 445 487 this._refresh(); 446 488 this._closeRecordDetails(); 489 this._model._reset(); 447 490 }, 448 491 … … 1173 1216 } 1174 1217 } 1218 1219 WebInspector.TimelineModel = function(timelinePanel) 1220 { 1221 this._panel = timelinePanel; 1222 this._records = []; 1223 } 1224 1225 WebInspector.TimelineModel.prototype = { 1226 _addRecord: function(record) 1227 { 1228 this._records.push(record); 1229 }, 1230 1231 _importNextChunk: function(data, index) 1232 { 1233 for (var i = 0; i < 20 && index < data.length; ++i, ++index) 1234 this._panel._addRecordToTimeline(data[index]); 1235 1236 if (index !== data.length) 1237 setTimeout(this._importNextChunk.bind(this, data, index), 0); 1238 }, 1239 1240 _importFromFile: function(file) 1241 { 1242 function onLoad(e) 1243 { 1244 var data = JSON.parse(e.target.result); 1245 var version = data[0]; 1246 this._importNextChunk(data, 1); 1247 } 1248 1249 function onError(e) 1250 { 1251 switch(e.target.error.code) { 1252 case e.target.error.NOT_FOUND_ERR: 1253 WebInspector.log(WebInspector.UIString('Timeline.importFromFile: File "%s" not found.', file.name)); 1254 break; 1255 case e.target.error.NOT_READABLE_ERR: 1256 WebInspector.log(WebInspector.UIString('Timeline.importFromFile: File "%s" is not readable', file.name)); 1257 break; 1258 case e.target.error.ABORT_ERR: 1259 break; 1260 default: 1261 WebInspector.log(WebInspector.UIString('Timeline.importFromFile: An error occurred while reading the file "%s"', file.name)); 1262 } 1263 } 1264 1265 var reader = new FileReader(); 1266 reader.onload = onLoad.bind(this); 1267 reader.onerror = onError; 1268 reader.readAsText(file); 1269 }, 1270 1271 _exportToFile: function() 1272 { 1273 var records = ['[' + JSON.stringify(window.navigator.appVersion)]; 1274 for (var i = 0; i < this._records.length - 1; ++i) 1275 records.push(JSON.stringify(this._records[i])); 1276 records.push(JSON.stringify(this._records[this._records.length - 1]) + "]"); 1277 1278 var now= new Date(); 1279 InspectorFrontendHost.saveAs("TimelineRawData-" + now.toRFC3339() + ".json", records.join(",\n")); 1280 }, 1281 1282 _reset: function() 1283 { 1284 this._records = []; 1285 } 1286 } -
trunk/Source/WebCore/inspector/front-end/utilities.js
r90556 r91252 689 689 } 690 690 691 Date.prototype.toRFC3339 = function() 692 { 693 function leadZero(x) 694 { 695 return x > 9 ? x : '0' + x 696 } 697 var offset = Math.abs(this.getTimezoneOffset()); 698 var offsetString = Math.floor(offset / 60) + ':' + leadZero(offset % 60); 699 return this.getFullYear() + '-' + 700 leadZero(this.getMonth() + 1) + '-' + 701 leadZero(this.getDate()) + 'T' + 702 leadZero(this.getHours()) + ':' + 703 leadZero(this.getMinutes()) + ':' + 704 leadZero(this.getSeconds()) + 705 (!offset ? "Z" : (this.getTimezoneOffset() > 0 ? '-' : '+') + offsetString); 706 } 707 691 708 HTMLTextAreaElement.prototype.moveCursorToEnd = function() 692 709 {
Note: See TracChangeset
for help on using the changeset viewer.