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

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

Issue 23474010: DevTools: "Jump between editing locations" experiment (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: making reveal() to return boolean value Created 7 years, 4 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/ScriptsPanel.js
diff --git a/Source/devtools/front_end/ScriptsPanel.js b/Source/devtools/front_end/ScriptsPanel.js
index ed44ed32cf1f1784b3284d48eacd1417ad41a472..d4c42ebeac59568f02575d5b9e9e4fc19ab2aeea 100644
--- a/Source/devtools/front_end/ScriptsPanel.js
+++ b/Source/devtools/front_end/ScriptsPanel.js
@@ -461,6 +461,19 @@ WebInspector.ScriptsPanel.prototype = {
},
/**
+ * @param {WebInspector.TextEditorPositionHandle} from
+ * @param {WebInspector.TextEditorPositionHandle} to
+ */
+ _onJumpToPosition: function(uiSourceCode, from, to)
+ {
+ if (this._searchQuery)
vsevik 2013/09/04 09:46:22 Please extract all jump specific logic to a separa
lushnikov 2014/01/02 14:06:09 Done.
+ return;
+ var fromEntry = from ? new WebInspector.ScriptsPanelJumpHistoryEntry(this, uiSourceCode, from) : null;
+ var toEntry = to ? new WebInspector.ScriptsPanelJumpHistoryEntry(this, uiSourceCode, to) : null;
+ WebInspector.jumpHistoryManager.jumpToPosition(fromEntry, toEntry);
+ },
+
+ /**
* @param {WebInspector.UISourceCode} uiSourceCode
* @return {WebInspector.SourceFrame}
*/
@@ -480,6 +493,7 @@ WebInspector.ScriptsPanel.prototype = {
break;
}
this._sourceFramesByUISourceCode.put(uiSourceCode, sourceFrame);
+ sourceFrame.setJumpToPositionDelegate(this._onJumpToPosition.bind(this, uiSourceCode));
return sourceFrame;
},
@@ -566,6 +580,13 @@ WebInspector.ScriptsPanel.prototype = {
if (this._currentUISourceCode === uiSourceCode)
delete this._currentUISourceCode;
+ function historyFilter(projectId, path, entry)
+ {
+ if (!(entry instanceof WebInspector.ScriptsPanelJumpHistoryEntry))
+ return false;
+ return entry._path === path && entry._projectId === projectId;
+ }
+ WebInspector.jumpHistoryManager.filterHistoryEntries(historyFilter.bind(this, uiSourceCode.project().id(), uiSourceCode.path()));
// ScriptsNavigator does not need to update on EditorClosed.
this._updateScriptViewStatusBarItems();
WebInspector.searchController.resetSearch();
@@ -1447,3 +1468,62 @@ WebInspector.ScriptsPanel.prototype = {
__proto__: WebInspector.Panel.prototype
}
+
+/**
+ * @constructor
+ * @implements {WebInspector.JumpHistoryEntry}
+ * @param {WebInspector.ScriptsPanel} scriptsPanel
+ * @param {WebInspector.UISourceCode} uiSourceCode
+ * @param {WebInspector.TextEditorPositionHandle} position
+ */
+WebInspector.ScriptsPanelJumpHistoryEntry = function(scriptsPanel, uiSourceCode, position)
+{
+ this._scriptsPanel = scriptsPanel;
+ this._projectId = uiSourceCode.project().id();
+ this._path = uiSourceCode.path();
+ this._position = position;
+}
+
+WebInspector.ScriptsPanelJumpHistoryEntry.prototype = {
+ /**
+ * @return {boolean}
+ */
+ valid: function()
+ {
+ return !!this._position.resolve();
+ },
+
+ /**
+ * @param {WebInspector.JumpHistoryEntry} entry
+ */
+ merge: function(entry)
+ {
+ if (!(entry instanceof WebInspector.ScriptsPanelJumpHistoryEntry))
+ return;
+ if (entry._projectId === this._projectId && entry._path === this._path)
+ this._position = entry._position;
+ },
+
+ /**
+ * @return {boolean}
+ */
+ reveal: function()
+ {
+ if (!this._scriptsPanel.isShowing())
+ WebInspector.inspectorView.setCurrentPanel(this._scriptsPanel);
+ var position = this._position.resolve();
+ var uiSourceCode = WebInspector.workspace.project(this._projectId).uiSourceCode(this._path);
+ this._scriptsPanel._showSourceLocation(uiSourceCode, position.lineNumber, position.columnNumber);
+ return true;
+ },
+
+ /**
+ * @param {WebInspector.JumpHistoryEntry} entry
+ */
+ equal: function(entry)
+ {
+ if (!(entry instanceof WebInspector.ScriptsPanelJumpHistoryEntry))
+ return false;
+ return entry._projectId === this._projectId && entry._path === this._path && entry._position.equal(this._position);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698