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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sources/EditingLocationHistoryManager.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month 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: third_party/WebKit/Source/devtools/front_end/sources/EditingLocationHistoryManager.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/EditingLocationHistoryManager.js b/third_party/WebKit/Source/devtools/front_end/sources/EditingLocationHistoryManager.js
index 13ab9503a3cfd7bae5a582ca576d1f87b4e55ecc..b939a47b5d556b406aa148ac8dadcf80778cf988 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/EditingLocationHistoryManager.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/EditingLocationHistoryManager.js
@@ -27,119 +27,112 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
/**
- * @constructor
- * @param {!WebInspector.SourcesView} sourcesView
- * @param {function():?WebInspector.SourceFrame} currentSourceFrameCallback
+ * @unrestricted
*/
-WebInspector.EditingLocationHistoryManager = function(sourcesView, currentSourceFrameCallback)
-{
+WebInspector.EditingLocationHistoryManager = class {
+ /**
+ * @param {!WebInspector.SourcesView} sourcesView
+ * @param {function():?WebInspector.SourceFrame} currentSourceFrameCallback
+ */
+ constructor(sourcesView, currentSourceFrameCallback) {
this._sourcesView = sourcesView;
- this._historyManager = new WebInspector.SimpleHistoryManager(WebInspector.EditingLocationHistoryManager.HistoryDepth);
+ this._historyManager =
+ new WebInspector.SimpleHistoryManager(WebInspector.EditingLocationHistoryManager.HistoryDepth);
this._currentSourceFrameCallback = currentSourceFrameCallback;
-};
-
-WebInspector.EditingLocationHistoryManager.HistoryDepth = 20;
+ }
+
+ /**
+ * @param {!WebInspector.UISourceCodeFrame} sourceFrame
+ */
+ trackSourceFrameCursorJumps(sourceFrame) {
+ sourceFrame.textEditor.addEventListener(
+ WebInspector.SourcesTextEditor.Events.JumpHappened, this._onJumpHappened.bind(this));
+ }
+
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _onJumpHappened(event) {
+ if (event.data.from)
+ this._updateActiveState(event.data.from);
+ if (event.data.to)
+ this._pushActiveState(event.data.to);
+ }
+
+ rollback() {
+ this._historyManager.rollback();
+ }
+
+ rollover() {
+ this._historyManager.rollover();
+ }
+
+ updateCurrentState() {
+ var sourceFrame = this._currentSourceFrameCallback();
+ if (!sourceFrame)
+ return;
+ this._updateActiveState(sourceFrame.textEditor.selection());
+ }
+
+ pushNewState() {
+ var sourceFrame = this._currentSourceFrameCallback();
+ if (!sourceFrame)
+ return;
+ this._pushActiveState(sourceFrame.textEditor.selection());
+ }
+
+ /**
+ * @param {!WebInspector.TextRange} selection
+ */
+ _updateActiveState(selection) {
+ var active = this._historyManager.active();
+ if (!active)
+ return;
+ var sourceFrame = this._currentSourceFrameCallback();
+ if (!sourceFrame)
+ return;
+ var entry = new WebInspector.EditingLocationHistoryEntry(this._sourcesView, this, sourceFrame, selection);
+ active.merge(entry);
+ }
+
+ /**
+ * @param {!WebInspector.TextRange} selection
+ */
+ _pushActiveState(selection) {
+ var sourceFrame = this._currentSourceFrameCallback();
+ if (!sourceFrame)
+ return;
+ var entry = new WebInspector.EditingLocationHistoryEntry(this._sourcesView, this, sourceFrame, selection);
+ this._historyManager.push(entry);
+ }
+
+ /**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ */
+ removeHistoryForSourceCode(uiSourceCode) {
+ function filterOut(entry) {
+ return entry._projectId === uiSourceCode.project().id() && entry._url === uiSourceCode.url();
+ }
-WebInspector.EditingLocationHistoryManager.prototype = {
- /**
- * @param {!WebInspector.UISourceCodeFrame} sourceFrame
- */
- trackSourceFrameCursorJumps: function(sourceFrame)
- {
- sourceFrame.textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.JumpHappened, this._onJumpHappened.bind(this));
- },
-
- /**
- * @param {!WebInspector.Event} event
- */
- _onJumpHappened: function(event)
- {
- if (event.data.from)
- this._updateActiveState(event.data.from);
- if (event.data.to)
- this._pushActiveState(event.data.to);
- },
-
- rollback: function()
- {
- this._historyManager.rollback();
- },
-
- rollover: function()
- {
- this._historyManager.rollover();
- },
-
- updateCurrentState: function()
- {
- var sourceFrame = this._currentSourceFrameCallback();
- if (!sourceFrame)
- return;
- this._updateActiveState(sourceFrame.textEditor.selection());
- },
-
- pushNewState: function()
- {
- var sourceFrame = this._currentSourceFrameCallback();
- if (!sourceFrame)
- return;
- this._pushActiveState(sourceFrame.textEditor.selection());
- },
-
- /**
- * @param {!WebInspector.TextRange} selection
- */
- _updateActiveState: function(selection)
- {
- var active = this._historyManager.active();
- if (!active)
- return;
- var sourceFrame = this._currentSourceFrameCallback();
- if (!sourceFrame)
- return;
- var entry = new WebInspector.EditingLocationHistoryEntry(this._sourcesView, this, sourceFrame, selection);
- active.merge(entry);
- },
-
- /**
- * @param {!WebInspector.TextRange} selection
- */
- _pushActiveState: function(selection)
- {
- var sourceFrame = this._currentSourceFrameCallback();
- if (!sourceFrame)
- return;
- var entry = new WebInspector.EditingLocationHistoryEntry(this._sourcesView, this, sourceFrame, selection);
- this._historyManager.push(entry);
- },
-
- /**
- * @param {!WebInspector.UISourceCode} uiSourceCode
- */
- removeHistoryForSourceCode: function(uiSourceCode)
- {
- function filterOut(entry)
- {
- return entry._projectId === uiSourceCode.project().id() && entry._url === uiSourceCode.url();
- }
-
- this._historyManager.filterOut(filterOut);
- },
+ this._historyManager.filterOut(filterOut);
+ }
};
+WebInspector.EditingLocationHistoryManager.HistoryDepth = 20;
/**
- * @constructor
* @implements {WebInspector.HistoryEntry}
- * @param {!WebInspector.SourcesView} sourcesView
- * @param {!WebInspector.EditingLocationHistoryManager} editingLocationManager
- * @param {!WebInspector.SourceFrame} sourceFrame
- * @param {!WebInspector.TextRange} selection
+ * @unrestricted
*/
-WebInspector.EditingLocationHistoryEntry = function(sourcesView, editingLocationManager, sourceFrame, selection)
-{
+WebInspector.EditingLocationHistoryEntry = class {
+ /**
+ * @param {!WebInspector.SourcesView} sourcesView
+ * @param {!WebInspector.EditingLocationHistoryManager} editingLocationManager
+ * @param {!WebInspector.SourceFrame} sourceFrame
+ * @param {!WebInspector.TextRange} selection
+ */
+ constructor(sourcesView, editingLocationManager, sourceFrame, selection) {
this._sourcesView = sourcesView;
this._editingLocationManager = editingLocationManager;
var uiSourceCode = sourceFrame.uiSourceCode();
@@ -148,53 +141,45 @@ WebInspector.EditingLocationHistoryEntry = function(sourcesView, editingLocation
var position = this._positionFromSelection(selection);
this._positionHandle = sourceFrame.textEditor.textEditorPositionHandle(position.lineNumber, position.columnNumber);
-};
-
-WebInspector.EditingLocationHistoryEntry.prototype = {
- /**
- * @param {!WebInspector.HistoryEntry} entry
- */
- merge: function(entry)
- {
- if (this._projectId !== entry._projectId || this._url !== entry._url)
- return;
- this._positionHandle = entry._positionHandle;
- },
-
- /**
- * @param {!WebInspector.TextRange} selection
- * @return {!{lineNumber: number, columnNumber: number}}
- */
- _positionFromSelection: function(selection)
- {
- return {
- lineNumber: selection.endLine,
- columnNumber: selection.endColumn
- };
- },
-
- /**
- * @override
- * @return {boolean}
- */
- valid: function()
- {
- var position = this._positionHandle.resolve();
- var uiSourceCode = WebInspector.workspace.uiSourceCode(this._projectId, this._url);
- return !!(position && uiSourceCode);
- },
-
- /**
- * @override
- */
- reveal: function()
- {
- var position = this._positionHandle.resolve();
- var uiSourceCode = WebInspector.workspace.uiSourceCode(this._projectId, this._url);
- if (!position || !uiSourceCode)
- return;
-
- this._editingLocationManager.updateCurrentState();
- this._sourcesView.showSourceLocation(uiSourceCode, position.lineNumber, position.columnNumber);
- }
+ }
+
+ /**
+ * @param {!WebInspector.HistoryEntry} entry
+ */
+ merge(entry) {
+ if (this._projectId !== entry._projectId || this._url !== entry._url)
+ return;
+ this._positionHandle = entry._positionHandle;
+ }
+
+ /**
+ * @param {!WebInspector.TextRange} selection
+ * @return {!{lineNumber: number, columnNumber: number}}
+ */
+ _positionFromSelection(selection) {
+ return {lineNumber: selection.endLine, columnNumber: selection.endColumn};
+ }
+
+ /**
+ * @override
+ * @return {boolean}
+ */
+ valid() {
+ var position = this._positionHandle.resolve();
+ var uiSourceCode = WebInspector.workspace.uiSourceCode(this._projectId, this._url);
+ return !!(position && uiSourceCode);
+ }
+
+ /**
+ * @override
+ */
+ reveal() {
+ var position = this._positionHandle.resolve();
+ var uiSourceCode = WebInspector.workspace.uiSourceCode(this._projectId, this._url);
+ if (!position || !uiSourceCode)
+ return;
+
+ this._editingLocationManager.updateCurrentState();
+ this._sourcesView.showSourceLocation(uiSourceCode, position.lineNumber, position.columnNumber);
+ }
};

Powered by Google App Engine
This is Rietveld 408576698