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

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

Issue 2769843003: DevTools: split text_utils out of common module (Closed)
Patch Set: rebaseline Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 pushNewState() { 78 pushNewState() {
79 var sourceFrame = this._currentSourceFrameCallback(); 79 var sourceFrame = this._currentSourceFrameCallback();
80 if (!sourceFrame) 80 if (!sourceFrame)
81 return; 81 return;
82 this._pushActiveState(sourceFrame.textEditor.selection()); 82 this._pushActiveState(sourceFrame.textEditor.selection());
83 } 83 }
84 84
85 /** 85 /**
86 * @param {!Common.TextRange} selection 86 * @param {!TextUtils.TextRange} selection
87 */ 87 */
88 _updateActiveState(selection) { 88 _updateActiveState(selection) {
89 var active = this._historyManager.active(); 89 var active = this._historyManager.active();
90 if (!active) 90 if (!active)
91 return; 91 return;
92 var sourceFrame = this._currentSourceFrameCallback(); 92 var sourceFrame = this._currentSourceFrameCallback();
93 if (!sourceFrame) 93 if (!sourceFrame)
94 return; 94 return;
95 var entry = new Sources.EditingLocationHistoryEntry(this._sourcesView, this, sourceFrame, selection); 95 var entry = new Sources.EditingLocationHistoryEntry(this._sourcesView, this, sourceFrame, selection);
96 active.merge(entry); 96 active.merge(entry);
97 } 97 }
98 98
99 /** 99 /**
100 * @param {!Common.TextRange} selection 100 * @param {!TextUtils.TextRange} selection
101 */ 101 */
102 _pushActiveState(selection) { 102 _pushActiveState(selection) {
103 var sourceFrame = this._currentSourceFrameCallback(); 103 var sourceFrame = this._currentSourceFrameCallback();
104 if (!sourceFrame) 104 if (!sourceFrame)
105 return; 105 return;
106 var entry = new Sources.EditingLocationHistoryEntry(this._sourcesView, this, sourceFrame, selection); 106 var entry = new Sources.EditingLocationHistoryEntry(this._sourcesView, this, sourceFrame, selection);
107 this._historyManager.push(entry); 107 this._historyManager.push(entry);
108 } 108 }
109 109
110 /** 110 /**
(...skipping 12 matching lines...) Expand all
123 123
124 /** 124 /**
125 * @implements {Sources.HistoryEntry} 125 * @implements {Sources.HistoryEntry}
126 * @unrestricted 126 * @unrestricted
127 */ 127 */
128 Sources.EditingLocationHistoryEntry = class { 128 Sources.EditingLocationHistoryEntry = class {
129 /** 129 /**
130 * @param {!Sources.SourcesView} sourcesView 130 * @param {!Sources.SourcesView} sourcesView
131 * @param {!Sources.EditingLocationHistoryManager} editingLocationManager 131 * @param {!Sources.EditingLocationHistoryManager} editingLocationManager
132 * @param {!SourceFrame.SourceFrame} sourceFrame 132 * @param {!SourceFrame.SourceFrame} sourceFrame
133 * @param {!Common.TextRange} selection 133 * @param {!TextUtils.TextRange} selection
134 */ 134 */
135 constructor(sourcesView, editingLocationManager, sourceFrame, selection) { 135 constructor(sourcesView, editingLocationManager, sourceFrame, selection) {
136 this._sourcesView = sourcesView; 136 this._sourcesView = sourcesView;
137 this._editingLocationManager = editingLocationManager; 137 this._editingLocationManager = editingLocationManager;
138 var uiSourceCode = sourceFrame.uiSourceCode(); 138 var uiSourceCode = sourceFrame.uiSourceCode();
139 this._projectId = uiSourceCode.project().id(); 139 this._projectId = uiSourceCode.project().id();
140 this._url = uiSourceCode.url(); 140 this._url = uiSourceCode.url();
141 141
142 var position = this._positionFromSelection(selection); 142 var position = this._positionFromSelection(selection);
143 this._positionHandle = sourceFrame.textEditor.textEditorPositionHandle(posit ion.lineNumber, position.columnNumber); 143 this._positionHandle = sourceFrame.textEditor.textEditorPositionHandle(posit ion.lineNumber, position.columnNumber);
144 } 144 }
145 145
146 /** 146 /**
147 * @param {!Sources.HistoryEntry} entry 147 * @param {!Sources.HistoryEntry} entry
148 */ 148 */
149 merge(entry) { 149 merge(entry) {
150 if (this._projectId !== entry._projectId || this._url !== entry._url) 150 if (this._projectId !== entry._projectId || this._url !== entry._url)
151 return; 151 return;
152 this._positionHandle = entry._positionHandle; 152 this._positionHandle = entry._positionHandle;
153 } 153 }
154 154
155 /** 155 /**
156 * @param {!Common.TextRange} selection 156 * @param {!TextUtils.TextRange} selection
157 * @return {!{lineNumber: number, columnNumber: number}} 157 * @return {!{lineNumber: number, columnNumber: number}}
158 */ 158 */
159 _positionFromSelection(selection) { 159 _positionFromSelection(selection) {
160 return {lineNumber: selection.endLine, columnNumber: selection.endColumn}; 160 return {lineNumber: selection.endLine, columnNumber: selection.endColumn};
161 } 161 }
162 162
163 /** 163 /**
164 * @override 164 * @override
165 * @return {boolean} 165 * @return {boolean}
166 */ 166 */
167 valid() { 167 valid() {
168 var position = this._positionHandle.resolve(); 168 var position = this._positionHandle.resolve();
169 var uiSourceCode = Workspace.workspace.uiSourceCode(this._projectId, this._u rl); 169 var uiSourceCode = Workspace.workspace.uiSourceCode(this._projectId, this._u rl);
170 return !!(position && uiSourceCode); 170 return !!(position && uiSourceCode);
171 } 171 }
172 172
173 /** 173 /**
174 * @override 174 * @override
175 */ 175 */
176 reveal() { 176 reveal() {
177 var position = this._positionHandle.resolve(); 177 var position = this._positionHandle.resolve();
178 var uiSourceCode = Workspace.workspace.uiSourceCode(this._projectId, this._u rl); 178 var uiSourceCode = Workspace.workspace.uiSourceCode(this._projectId, this._u rl);
179 if (!position || !uiSourceCode) 179 if (!position || !uiSourceCode)
180 return; 180 return;
181 181
182 this._editingLocationManager.updateCurrentState(); 182 this._editingLocationManager.updateCurrentState();
183 this._sourcesView.showSourceLocation(uiSourceCode, position.lineNumber, posi tion.columnNumber); 183 this._sourcesView.showSourceLocation(uiSourceCode, position.lineNumber, posi tion.columnNumber);
184 } 184 }
185 }; 185 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698