Web Inspector: add keyboard shortcuts to load/save operations in Timeline panel.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Jul 2011 15:43:57 +0000 (15:43 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Jul 2011 15:43:57 +0000 (15:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=64864

Source/WebCore:

Export/import were renamed to save/load.
Ctrl|Meta-S/Ctrl|Meta-O shortcuts were added for Save and Load operations.
Ctrl|Meta-E shortcut toggles Record button;
Ctrl|Meta-Shift-F shortcut toggles short records filter button;
All the shortcuts were added to the shortcuts help screen.
There was a problem with saving empty data.

Reviewed by Yury Semikhatsky.

* English.lproj/localizedStrings.js:
* inspector/front-end/TimelinePanel.js:
(WebInspector.TimelinePanel.prototype._registerShortcuts):
(WebInspector.TimelinePanel.prototype._createFileSelector):
(WebInspector.TimelinePanel.prototype._contextMenu):
(WebInspector.TimelinePanel.prototype._saveToFile):
(WebInspector.TimelinePanel.prototype._loadFromFile):
(WebInspector.TimelineModel.prototype._loadNextChunk):
(WebInspector.TimelineModel.prototype._loadFromFile):
(WebInspector.TimelineModel.prototype._loadFromFile.onError):
(WebInspector.TimelineModel.prototype._saveToFile):

LayoutTests:

Export/import were renamed to save/load.

Reviewed by Yury Semikhatsky.

* inspector/timeline/timeline-load.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@91367 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/timeline/timeline-load.html
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/localizedStrings.js
Source/WebCore/inspector/front-end/TimelinePanel.js

index b8a4e1a493c7faa201a958f954f6f01138258a73..3f25fb444e25c1a96215164da355439ab2dc6298 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-20  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: add keyboard shortcuts to load/save operations in Timeline panel.
+        https://bugs.webkit.org/show_bug.cgi?id=64864
+
+        Export/import were renamed to save/load.
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/timeline/timeline-load.html:
+
 2011-07-20  Ryosuke Niwa  <rniwa@webkit.org>
 
         Chromium test expectation update.
index 577551275851488f21215ebe84466a25f9f53f45..6dd04eb7ea96330ed1b581cd0949398f7c955ab1 100644 (file)
@@ -7,7 +7,7 @@
 function test()
 {
     WebInspector.showPanel("timeline");
-    InspectorTest.addSniffer(WebInspector.TimelineModel.prototype, "_importNextChunk", importNextChunk);
+    InspectorTest.addSniffer(WebInspector.TimelineModel.prototype, "_loadNextChunk", loadNextChunk);
     InspectorFrontendHost.saveAs = saveAs;
     var data = [
         {"startTime":1310749854316.8408,"data":{"identifier":43,"url":"http://www.webkit.org/","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":1819936,"totalHeapSize":7629120},
@@ -20,11 +20,11 @@ function test()
         {"startTime":1310749855137.989,"data":{"identifier":49,"url":"http://www.webkit.org/css/purple.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
         {"startTime":1310749855138.308,"data":{"identifier":50,"url":"http://www.webkit.org/css/gray.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120}];
 
-    WebInspector.panels.timeline._model._importNextChunk(data, 0);
+    WebInspector.panels.timeline._model._loadNextChunk(data, 0);
 
-    function importNextChunk()
+    function loadNextChunk()
     {
-        WebInspector.panels.timeline._model._exportToFile();
+        WebInspector.panels.timeline._model._saveToFile();
     }
 
     function saveAs(name, saveData)
index e6dfdbeab09f20ff88439d1101cbcb691c0628e2..aaa97bd02f08447bc1a1307067872a5780843b35 100644 (file)
@@ -1,3 +1,29 @@
+2011-07-20  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: add keyboard shortcuts to load/save operations in Timeline panel.
+        https://bugs.webkit.org/show_bug.cgi?id=64864
+
+        Export/import were renamed to save/load.
+        Ctrl|Meta-S/Ctrl|Meta-O shortcuts were added for Save and Load operations.
+        Ctrl|Meta-E shortcut toggles Record button;
+        Ctrl|Meta-Shift-F shortcut toggles short records filter button;
+        All the shortcuts were added to the shortcuts help screen.
+        There was a problem with saving empty data.
+
+        Reviewed by Yury Semikhatsky.
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/TimelinePanel.js:
+        (WebInspector.TimelinePanel.prototype._registerShortcuts):
+        (WebInspector.TimelinePanel.prototype._createFileSelector):
+        (WebInspector.TimelinePanel.prototype._contextMenu):
+        (WebInspector.TimelinePanel.prototype._saveToFile):
+        (WebInspector.TimelinePanel.prototype._loadFromFile):
+        (WebInspector.TimelineModel.prototype._loadNextChunk):
+        (WebInspector.TimelineModel.prototype._loadFromFile):
+        (WebInspector.TimelineModel.prototype._loadFromFile.onError):
+        (WebInspector.TimelineModel.prototype._saveToFile):
+
 2011-07-20  Ryosuke Niwa  <rniwa@webkit.org>
 
         Speculative build fix after r91355.
index 79d8e6fc9da59284c3eb92884bb33f0edbadfd00..a44fcb2c2ca145b1425a380ecc451e2a100f1ba0 100644 (file)
Binary files a/Source/WebCore/English.lproj/localizedStrings.js and b/Source/WebCore/English.lproj/localizedStrings.js differ
index a27fe9f794e122b3def23a21ecd8263c2b6a7b10..c07f15a6cc23933cd3c099ade5fbd660892d7b99 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -104,6 +104,7 @@ WebInspector.TimelinePanel = function()
     this._createFileSelector();
     this._model = new WebInspector.TimelineModel(this);
 
+    this._registerShortcuts();
     WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onTimelineEventRecorded, this);
 }
 
@@ -221,6 +222,26 @@ WebInspector.TimelinePanel.prototype = {
         this.recordsCounter.className = "timeline-records-counter";
     },
 
+    _registerShortcuts: function()
+    {
+        var shortcut = WebInspector.KeyboardShortcut;
+        var modifiers = shortcut.Modifiers;
+        var section = WebInspector.shortcutsScreen.section(WebInspector.UIString("Timeline Panel"));
+
+        this._shortcuts[shortcut.makeKey("e", modifiers.CtrlOrMeta)] = this._toggleTimelineButtonClicked.bind(this);
+        section.addKey(shortcut.shortcutToString("e", modifiers.CtrlOrMeta), WebInspector.UIString("Start/stop recording"));
+
+        var shortRecordThresholdTitle = Number.secondsToString(WebInspector.TimelinePanel.shortRecordThreshold);
+        this._shortcuts[shortcut.makeKey("f", modifiers.Shift | modifiers.CtrlOrMeta)] = this._toggleFilterButtonClicked.bind(this);
+        section.addKey(shortcut.shortcutToString("f", modifiers.Shift | modifiers.CtrlOrMeta), WebInspector.UIString("Toggle filter for the records that are shorter than %s", shortRecordThresholdTitle));
+
+        this._shortcuts[shortcut.makeKey("s", modifiers.CtrlOrMeta)] = this._saveToFile.bind(this);
+        section.addKey(shortcut.shortcutToString("s", modifiers.CtrlOrMeta), WebInspector.UIString("Save Timeline data\u2026"));
+
+        this._shortcuts[shortcut.makeKey("o", modifiers.CtrlOrMeta)] = this._fileSelectorElement.click.bind(this._fileSelectorElement);
+        section.addKey(shortcut.shortcutToString("o", modifiers.CtrlOrMeta), WebInspector.UIString("Load Timeline data\u2026"));
+    },
+
     _createFileSelector: function()
     {
         if (this._fileSelectorElement)
@@ -229,7 +250,7 @@ WebInspector.TimelinePanel.prototype = {
         var fileSelectorElement = document.createElement("input");
         fileSelectorElement.type = "file";
         fileSelectorElement.style.opacity = 0;
-        fileSelectorElement.onchange = this._importFromFile.bind(this);
+        fileSelectorElement.onchange = this._loadFromFile.bind(this);
         this.element.appendChild(fileSelectorElement);
         this._fileSelectorElement = fileSelectorElement;
     },
@@ -237,24 +258,24 @@ WebInspector.TimelinePanel.prototype = {
     _contextMenu: function(event)
     {
         var contextMenu = new WebInspector.ContextMenu();
-        contextMenu.appendItem(WebInspector.UIString("&Export Timeline data\u2026"), this._exportToFile.bind(this));
-        contextMenu.appendItem(WebInspector.UIString("&Import Timeline data\u2026"), this._fileSelectorElement.click.bind(this._fileSelectorElement));
+        contextMenu.appendItem(WebInspector.UIString("&Save Timeline data\u2026"), this._saveToFile.bind(this));
+        contextMenu.appendItem(WebInspector.UIString("L&oad Timeline data\u2026"), this._fileSelectorElement.click.bind(this._fileSelectorElement));
         contextMenu.show(event);
     },
 
-    _exportToFile: function()
+    _saveToFile: function()
     {
-        this._model._exportToFile();
+        this._model._saveToFile();
     },
 
-    _importFromFile: function()
+    _loadFromFile: function()
     {
         if (this.toggleTimelineButton.toggled)
             WebInspector.timelineManager.stop();
 
         this._clearPanel();
 
-        this._model._importFromFile(this._fileSelectorElement.files[0]);
+        this._model._loadFromFile(this._fileSelectorElement.files[0]);
         this._createFileSelector();
     },
 
@@ -304,11 +325,13 @@ WebInspector.TimelinePanel.prototype = {
         return eventDividerPadding;
     },
 
-    _timelinesOverviewItemSelected: function(event) {
+    _timelinesOverviewItemSelected: function(event)
+    {
         this._overviewPane.showTimelines();
     },
 
-    _memoryOverviewItemSelected: function(event) {
+    _memoryOverviewItemSelected: function(event)
+    {
         this._overviewPane.showMemoryGraph(this._rootRecord.children);
     },
 
@@ -1228,37 +1251,37 @@ WebInspector.TimelineModel.prototype = {
         this._records.push(record);
     },
 
-    _importNextChunk: function(data, index)
+    _loadNextChunk: function(data, index)
     {
         for (var i = 0; i < 20 && index < data.length; ++i, ++index)
             this._panel._addRecordToTimeline(data[index]);
 
         if (index !== data.length)
-            setTimeout(this._importNextChunk.bind(this, data, index), 0);
+            setTimeout(this._loadNextChunk.bind(this, data, index), 0);
     },
 
-    _importFromFile: function(file)
+    _loadFromFile: function(file)
     {
         function onLoad(e)
         {
             var data = JSON.parse(e.target.result);
             var version = data[0];
-            this._importNextChunk(data, 1);
+            this._loadNextChunk(data, 1);
         }
 
         function onError(e)
         {
             switch(e.target.error.code) {
             case e.target.error.NOT_FOUND_ERR:
-                WebInspector.log(WebInspector.UIString('Timeline.importFromFile: File "%s" not found.', file.name));
+                WebInspector.log(WebInspector.UIString('Timeline.loadFromFile: File "%s" not found.', file.name));
             break;
             case e.target.error.NOT_READABLE_ERR:
-                WebInspector.log(WebInspector.UIString('Timeline.importFromFile: File "%s" is not readable', file.name));
+                WebInspector.log(WebInspector.UIString('Timeline.loadFromFile: File "%s" is not readable', file.name));
             break;
             case e.target.error.ABORT_ERR:
                 break;
             default:
-                WebInspector.log(WebInspector.UIString('Timeline.importFromFile: An error occurred while reading the file "%s"', file.name));
+                WebInspector.log(WebInspector.UIString('Timeline.loadFromFile: An error occurred while reading the file "%s"', file.name));
             }
         }
 
@@ -1268,12 +1291,12 @@ WebInspector.TimelineModel.prototype = {
         reader.readAsText(file);
     },
 
-    _exportToFile: function()
+    _saveToFile: function()
     {
         var records = ['[' + JSON.stringify(window.navigator.appVersion)];
-        for (var i = 0; i < this._records.length - 1; ++i)
+        for (var i = 0; i < this._records.length; ++i)
             records.push(JSON.stringify(this._records[i]));
-        records.push(JSON.stringify(this._records[this._records.length - 1]) + "]");
+            records[records.length - 1] = records[records.length - 1] + "]";
 
         var now= new Date();
         InspectorFrontendHost.saveAs("TimelineRawData-" + now.toRFC3339() + ".json", records.join(",\n"));