Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1830)

Unified Diff: Source/devtools/front_end/SourcesPanel.js

Issue 23474010: DevTools: "Jump between editing locations" experiment (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/SourcesPanel.js
diff --git a/Source/devtools/front_end/SourcesPanel.js b/Source/devtools/front_end/SourcesPanel.js
index 3806df3e2885dc91b5aedac35bbf3c91efbb9300..37bbdcd2ac24dad80af6b582880f88af047a1aa0 100644
--- a/Source/devtools/front_end/SourcesPanel.js
+++ b/Source/devtools/front_end/SourcesPanel.js
@@ -26,6 +26,8 @@
importScript("BreakpointsSidebarPane.js");
importScript("CallStackSidebarPane.js");
+importScript("SimpleHistoryManager.js");
+importScript("EditingLocationHistoryManager.js");
importScript("FilePathScoreFunction.js");
importScript("FilteredItemSelectionDialog.js");
importScript("UISourceCodeFrame.js");
@@ -68,7 +70,7 @@ WebInspector.SourcesPanel = function(workspaceForTest)
*/
function viewGetter()
{
- return this.visibleView;
+ return this;
}
WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
@@ -141,6 +143,18 @@ WebInspector.SourcesPanel = function(workspaceForTest)
this.sidebarPanes.workerList = new WebInspector.WorkersSidebarPane(WebInspector.workerManager);
}
+ /**
+ * @this {WebInspector.SourcesPanel}
+ */
+ function currentSourceFrame()
+ {
+ var uiSourceCode = this.currentUISourceCode();
+ if (!uiSourceCode)
+ return null;
+ return this._sourceFramesByUISourceCode.get(uiSourceCode);
+ }
+ this._historyManager = new WebInspector.EditingLocationHistoryManager(this, currentSourceFrame.bind(this));
+
this.sidebarPanes.callstack.registerShortcuts(this.registerShortcuts.bind(this));
this.registerShortcuts(WebInspector.SourcesPanelDescriptor.ShortcutKeys.GoToMember, this._showOutlineDialog.bind(this));
this.registerShortcuts(WebInspector.SourcesPanelDescriptor.ShortcutKeys.ToggleBreakpoint, this._toggleBreakpoint.bind(this));
@@ -297,6 +311,7 @@ WebInspector.SourcesPanel.prototype = {
for (var i = 0; i < uiSourceCodes.length; ++i) {
this._navigator.removeUISourceCode(uiSourceCodes[i]);
this._removeSourceFrame(uiSourceCodes[i]);
+ this._historyManager.removeHistoryForSourceCode(uiSourceCodes[i]);
}
this._editorContainer.removeUISourceCodes(uiSourceCodes);
},
@@ -513,12 +528,16 @@ WebInspector.SourcesPanel.prototype = {
*/
_showSourceLocation: function(uiSourceCode, lineNumber, columnNumber, forceShowInPanel)
{
+ if (uiSourceCode === this._currentUISourceCode && typeof lineNumber === "number") {
vsevik 2014/01/15 16:19:05 This looks redundant. Please remove these lines un
lushnikov 2014/01/16 17:10:29 Done.
+ this.highlightPosition(lineNumber, columnNumber);
+ return;
+ }
this._showEditor(forceShowInPanel);
var sourceFrame = this._showFile(uiSourceCode);
if (typeof lineNumber === "number")
sourceFrame.highlightPosition(lineNumber, columnNumber);
sourceFrame.focus();
-
+ this._historyManager.updateCurrentState();
WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction, {
action: WebInspector.UserMetrics.UserActionNames.OpenSourceLink,
url: uiSourceCode.originURL(),
@@ -535,9 +554,13 @@ WebInspector.SourcesPanel.prototype = {
var sourceFrame = this._getOrCreateSourceFrame(uiSourceCode);
if (this._currentUISourceCode === uiSourceCode)
return sourceFrame;
+
+ this._historyManager.updateCurrentState();
vsevik 2014/01/15 16:19:05 You wrap incorrect line with your calls here and t
lushnikov 2014/01/16 17:10:29 Moved these lines out of the method
this._currentUISourceCode = uiSourceCode;
if (!uiSourceCode.project().isServiceProject())
this._navigator.revealUISourceCode(uiSourceCode, true);
+ this._historyManager.pushNewState();
+
this._editorContainer.showFile(uiSourceCode);
this._updateScriptViewStatusBarItems();
@@ -572,6 +595,7 @@ WebInspector.SourcesPanel.prototype = {
}
sourceFrame.setHighlighterType(uiSourceCode.highlighterType());
this._sourceFramesByUISourceCode.put(uiSourceCode, sourceFrame);
+ this._historyManager.trackSourceFrameCursorJumps(sourceFrame);
return sourceFrame;
},
@@ -688,6 +712,7 @@ WebInspector.SourcesPanel.prototype = {
{
this._navigatorController.hideNavigatorOverlay();
var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
+ this._historyManager.removeHistoryForSourceCode(uiSourceCode);
if (this._currentUISourceCode === uiSourceCode)
delete this._currentUISourceCode;
@@ -699,8 +724,13 @@ WebInspector.SourcesPanel.prototype = {
_editorSelected: function(event)
{
- var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
+ var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data.currentFile);
+ if (!event.data.userGesture)
+ this._historyManager.readOnlyLock();
vsevik 2014/01/16 12:24:26 Can we remove these?
lushnikov 2014/01/16 17:10:29 Not really; test fails.
var sourceFrame = this._showFile(uiSourceCode);
+ if (!event.data.userGesture)
+ this._historyManager.releaseReadOnlyLock();
+
this._navigatorController.hideNavigatorOverlay();
if (!this._navigatorController.isNavigatorPinned())
sourceFrame.focus();
@@ -1160,6 +1190,18 @@ WebInspector.SourcesPanel.prototype = {
view.replaceAllWith(query, text);
},
+ /**
+ * @param {!KeyboardEvent} event
+ */
+ handleShortcut: function(event)
vsevik 2014/01/15 16:19:05 Please register and handle this shortcuts on the p
lushnikov 2014/01/16 17:10:29 Done.
+ {
+ if (this._historyManager.handleShortcut(event)) {
+ event.handled = true;
+ return;
+ }
+ WebInspector.Panel.prototype.handleShortcut.call(this, event);
+ },
+
_onKeyDown: function(event)
{
if (event.keyCode !== WebInspector.KeyboardShortcut.Keys.CtrlOrMeta.code)
@@ -1630,7 +1672,9 @@ WebInspector.SourcesPanel.prototype = {
{
if (!this.canHighlightPosition())
return;
+ this._historyManager.updateCurrentState();
this.visibleView.highlightPosition(line, column);
+ this._historyManager.pushNewState();
},
/**

Powered by Google App Engine
This is Rietveld 408576698