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

Side by Side Diff: Source/devtools/front_end/SourcesEditor.js

Issue 206063003: DevTools: Extract SourcesEditor from SourcesPanel. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @constructor
7 * @implements {WebInspector.TabbedEditorContainerDelegate}
8 * @implements {WebInspector.Searchable}
9 * @implements {WebInspector.Replaceable}
10 * @extends {WebInspector.Object}
11 * @param {!WebInspector.Workspace} workspace
12 * @param {!WebInspector.SourcesPanel} sourcesPanel
13 */
14 WebInspector.SourcesEditor = function(workspace, sourcesPanel)
lushnikov 2014/03/20 13:13:43 it would be great to remove this sourcesPanel depe
15 {
16 this._workspace = workspace;
17 this._sourcesPanel = sourcesPanel;
18
19 this._sourcesView = new WebInspector.SourcesView();
20
21 this._searchableView = new WebInspector.SearchableView(this);
22 this._searchableView.setMinimalSearchQuerySize(0);
23 this._searchableView.show(this._sourcesView.element);
24
25 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.SourceFrame>} */
26 this._sourceFramesByUISourceCode = new Map();
27
28 var tabbedEditorPlaceholderText = WebInspector.isMac() ? WebInspector.UIStri ng("Hit Cmd+O to open a file") : WebInspector.UIString("Hit Ctrl+O to open a fil e");
29 this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previo uslyViewedFiles", tabbedEditorPlaceholderText);
30 this._editorContainer.show(this._searchableView.element);
31 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev ents.EditorSelected, this._editorSelected, this);
32 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev ents.EditorClosed, this._editorClosed, this);
33
34 this._historyManager = new WebInspector.EditingLocationHistoryManager(this, this.currentSourceFrame.bind(this));
35
36 this._scriptViewStatusBarItemsContainer = document.createElement("div");
37 this._scriptViewStatusBarItemsContainer.className = "inline-block";
38
39 this._scriptViewStatusBarTextContainer = document.createElement("div");
40 this._scriptViewStatusBarTextContainer.className = "hbox";
41
42 this._statusBarContainerElement = this._sourcesView.element.createChild("div ", "sources-status-bar");
43
44 /**
45 * @this {WebInspector.SourcesEditor}
46 * @param {!WebInspector.SourcesEditor.EditorAction} EditorAction
47 */
48 function appendButtonForExtension(EditorAction)
49 {
50 this._statusBarContainerElement.appendChild(EditorAction.button(this));
51 }
52 var editorActions = /** @type {!Array.<!WebInspector.SourcesEditor.EditorAct ion>} */ (WebInspector.moduleManager.instances(WebInspector.SourcesEditor.Editor Action));
53 editorActions.forEach(appendButtonForExtension.bind(this));
54
55 this._statusBarContainerElement.appendChild(this._scriptViewStatusBarItemsCo ntainer);
56 this._statusBarContainerElement.appendChild(this._scriptViewStatusBarTextCon tainer);
57
58 WebInspector.startBatchUpdate();
59 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));
60 WebInspector.endBatchUpdate();
61
62 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAdded, this);
63 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR emoved, this._uiSourceCodeRemoved, this);
64 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillRe set, this._projectWillReset.bind(this), this);
65
66 function handleBeforeUnload(event)
67 {
68 if (event.returnValue)
69 return;
70 var unsavedSourceCodes = WebInspector.workspace.unsavedSourceCodes();
71 if (!unsavedSourceCodes.length)
72 return;
73
74 event.returnValue = WebInspector.UIString("DevTools have unsaved changes that will be permanently lost.");
75 WebInspector.inspectorView.showPanel("sources");
76 for (var i = 0; i < unsavedSourceCodes.length; ++i)
77 WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]);
78 }
79 window.addEventListener("beforeunload", handleBeforeUnload, true);
80 }
81
82 WebInspector.SourcesEditor.Events = {
83 EditorClosed: "EditorClosed",
84 EditorSelected: "EditorSelected",
85 }
86
87 WebInspector.SourcesEditor.prototype = {
88 /**
89 * @param {function(!Array.<!WebInspector.KeyboardShortcut.Descriptor>, func tion(?Event=):boolean)} registerShortcutDelegate
90 */
91 registerShortcuts: function(registerShortcutDelegate)
92 {
93 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.JumpToPreviousLocation, this._onJumpToPreviousLocation.bind(this));
94 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.JumpToNextLocation, this._onJumpToNextLocation.bind(this));
95 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.CloseEditorTab, this._onCloseEditorTab.bind(this));
96 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.GoToLine, this._showGoToLineDialog.bind(this));
97 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.GoToMember, this._showOutlineDialog.bind(this));
98 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.ToggleBreakpoint, this._toggleBreakpoint.bind(this));
99 },
100
101 /**
102 * @return {!Element}
103 */
104 statusBarContainerElement: function()
105 {
106 return this._statusBarContainerElement;
107 },
108
109 /**
110 * @return {!Element}
111 */
112 defaultFocusedElement: function()
113 {
114 return this._editorContainer.view.defaultFocusedElement();
115 },
116
117 /**
118 * @return {!WebInspector.SearchableView}
119 */
120 searchableView: function()
121 {
122 return this._searchableView;
123 },
124
125 /**
126 * @return {!WebInspector.SourcesView}
127 */
128 sourcesView: function()
129 {
130 return this._sourcesView;
131 },
132
133 /**
134 * @return {!WebInspector.View}
135 */
136 visibleView: function()
137 {
138 return this._editorContainer.visibleView;
139 },
140
141 /**
142 * @return {?WebInspector.SourceFrame}
143 */
144 currentSourceFrame: function()
145 {
146 var view = this.visibleView();
147 if (!(view instanceof WebInspector.SourceFrame))
148 return null;
149 return /** @type {!WebInspector.SourceFrame} */ (view);
150 },
151
152 /**
153 * @return {?WebInspector.UISourceCode}
154 */
155 currentUISourceCode: function()
156 {
157 return this._currentUISourceCode;
158 },
159
160 /**
161 * @param {?Event=} event
162 */
163 _onCloseEditorTab: function(event)
164 {
165 var uiSourceCode = this.currentUISourceCode();
166 if (!uiSourceCode)
167 return false;
168 this._editorContainer.closeFile(uiSourceCode);
169 return true;
170 },
171
172 /**
173 * @param {?Event=} event
174 */
175 _onJumpToPreviousLocation: function(event)
176 {
177 this._historyManager.rollback();
178 return true;
179 },
180
181 /**
182 * @param {?Event=} event
183 */
184 _onJumpToNextLocation: function(event)
185 {
186 this._historyManager.rollover();
187 return true;
188 },
189
190 /**
191 * @param {!WebInspector.Event} event
192 */
193 _uiSourceCodeAdded: function(event)
194 {
195 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data );
196 this._addUISourceCode(uiSourceCode);
197 },
198
199 /**
200 * @param {!WebInspector.UISourceCode} uiSourceCode
201 */
202 _addUISourceCode: function(uiSourceCode)
203 {
204 if (uiSourceCode.project().isServiceProject())
205 return;
206 this._editorContainer.addUISourceCode(uiSourceCode);
207 // Replace debugger script-based uiSourceCode with a network-based one.
208 var currentUISourceCode = this._currentUISourceCode;
209 if (currentUISourceCode && currentUISourceCode.project().isServiceProjec t() && currentUISourceCode !== uiSourceCode && currentUISourceCode.url === uiSou rceCode.url) {
210 this._showFile(uiSourceCode);
211 this._editorContainer.removeUISourceCode(currentUISourceCode);
212 }
213 },
214
215 _uiSourceCodeRemoved: function(event)
216 {
217 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data );
218 this._removeUISourceCodes([uiSourceCode]);
219 },
220
221 /**
222 * @param {!Array.<!WebInspector.UISourceCode>} uiSourceCodes
223 */
224 _removeUISourceCodes: function(uiSourceCodes)
225 {
226 for (var i = 0; i < uiSourceCodes.length; ++i) {
227 this._removeSourceFrame(uiSourceCodes[i]);
228 this._historyManager.removeHistoryForSourceCode(uiSourceCodes[i]);
229 }
230 this._editorContainer.removeUISourceCodes(uiSourceCodes);
231 },
232
233 _projectWillReset: function(event)
234 {
235 var project = event.data;
236 var uiSourceCodes = project.uiSourceCodes();
237 this._removeUISourceCodes(uiSourceCodes);
238 if (project.type() === WebInspector.projectTypes.Network)
239 this._editorContainer.reset();
240 },
241
242 _updateScriptViewStatusBarItems: function()
243 {
244 this._scriptViewStatusBarItemsContainer.removeChildren();
245 this._scriptViewStatusBarTextContainer.removeChildren();
246 var sourceFrame = this.currentSourceFrame();
247 if (!sourceFrame)
248 return;
249
250 var statusBarItems = sourceFrame.statusBarItems() || [];
251 for (var i = 0; i < statusBarItems.length; ++i)
252 this._scriptViewStatusBarItemsContainer.appendChild(statusBarItems[i ]);
253 var statusBarText = sourceFrame.statusBarText();
254 if (statusBarText)
255 this._scriptViewStatusBarTextContainer.appendChild(statusBarText);
256 },
257
258 /**
259 * @param {!WebInspector.UISourceCode} uiSourceCode
260 * @param {number=} lineNumber
261 * @param {number=} columnNumber
262 * @param {boolean=} omitFocus
263 * @param {boolean=} omitHighlight
264 */
265 showSourceLocation: function(uiSourceCode, lineNumber, columnNumber, omitFoc us, omitHighlight)
266 {
267 this._historyManager.updateCurrentState();
268 var sourceFrame = this._showFile(uiSourceCode);
269 if (typeof lineNumber === "number")
270 sourceFrame.revealPosition(lineNumber, columnNumber, !omitHighlight) ;
271 this._historyManager.pushNewState();
272 if (!omitFocus)
273 sourceFrame.focus();
274 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMet rics.UserAction, {
275 action: WebInspector.UserMetrics.UserActionNames.OpenSourceLink,
276 url: uiSourceCode.originURL(),
277 lineNumber: lineNumber
278 });
279 },
280
281 /**
282 * @param {!WebInspector.UISourceCode} uiSourceCode
283 * @return {!WebInspector.SourceFrame}
284 */
285 _showFile: function(uiSourceCode)
286 {
287 var sourceFrame = this._getOrCreateSourceFrame(uiSourceCode);
288 if (this._currentUISourceCode === uiSourceCode)
289 return sourceFrame;
290
291 this._currentUISourceCode = uiSourceCode;
292 this._editorContainer.showFile(uiSourceCode);
293 this._updateScriptViewStatusBarItems();
294 return sourceFrame;
295 },
296
297 /**
298 * @param {!WebInspector.UISourceCode} uiSourceCode
299 * @return {!WebInspector.SourceFrame}
300 */
301 _createSourceFrame: function(uiSourceCode)
302 {
303 var sourceFrame;
304 switch (uiSourceCode.contentType()) {
305 case WebInspector.resourceTypes.Script:
306 sourceFrame = new WebInspector.JavaScriptSourceFrame(this._sourcesPa nel, uiSourceCode);
307 break;
308 case WebInspector.resourceTypes.Document:
309 sourceFrame = new WebInspector.JavaScriptSourceFrame(this._sourcesPa nel, uiSourceCode);
310 break;
311 case WebInspector.resourceTypes.Stylesheet:
312 sourceFrame = new WebInspector.CSSSourceFrame(uiSourceCode);
313 break;
314 default:
315 sourceFrame = new WebInspector.UISourceCodeFrame(uiSourceCode);
316 break;
317 }
318 sourceFrame.setHighlighterType(uiSourceCode.highlighterType());
319 this._sourceFramesByUISourceCode.put(uiSourceCode, sourceFrame);
320 this._historyManager.trackSourceFrameCursorJumps(sourceFrame);
321 return sourceFrame;
322 },
323
324 /**
325 * @param {!WebInspector.UISourceCode} uiSourceCode
326 * @return {!WebInspector.SourceFrame}
327 */
328 _getOrCreateSourceFrame: function(uiSourceCode)
329 {
330 return this._sourceFramesByUISourceCode.get(uiSourceCode) || this._creat eSourceFrame(uiSourceCode);
331 },
332
333 /**
334 * @param {!WebInspector.SourceFrame} sourceFrame
335 * @param {!WebInspector.UISourceCode} uiSourceCode
336 * @return {boolean}
337 */
338 _sourceFrameMatchesUISourceCode: function(sourceFrame, uiSourceCode)
339 {
340 switch (uiSourceCode.contentType()) {
341 case WebInspector.resourceTypes.Script:
342 case WebInspector.resourceTypes.Document:
343 return sourceFrame instanceof WebInspector.JavaScriptSourceFrame;
344 case WebInspector.resourceTypes.Stylesheet:
345 return sourceFrame instanceof WebInspector.CSSSourceFrame;
346 default:
347 return !(sourceFrame instanceof WebInspector.JavaScriptSourceFrame);
348 }
349 },
350
351 /**
352 * @param {!WebInspector.UISourceCode} uiSourceCode
353 */
354 _recreateSourceFrameIfNeeded: function(uiSourceCode)
355 {
356 var oldSourceFrame = this._sourceFramesByUISourceCode.get(uiSourceCode);
357 if (!oldSourceFrame)
358 return;
359 if (this._sourceFrameMatchesUISourceCode(oldSourceFrame, uiSourceCode)) {
360 oldSourceFrame.setHighlighterType(uiSourceCode.highlighterType());
361 } else {
362 this._editorContainer.removeUISourceCode(uiSourceCode);
363 this._removeSourceFrame(uiSourceCode);
364 }
365 },
366
367 /**
368 * @param {!WebInspector.UISourceCode} uiSourceCode
369 * @return {!WebInspector.SourceFrame}
370 */
371 viewForFile: function(uiSourceCode)
372 {
373 return this._getOrCreateSourceFrame(uiSourceCode);
374 },
375
376 /**
377 * @param {!WebInspector.UISourceCode} uiSourceCode
378 */
379 _removeSourceFrame: function(uiSourceCode)
380 {
381 var sourceFrame = this._sourceFramesByUISourceCode.get(uiSourceCode);
382 if (!sourceFrame)
383 return;
384 this._sourceFramesByUISourceCode.remove(uiSourceCode);
385 sourceFrame.dispose();
386 },
387
388 clearCurrentExecutionLine: function()
389 {
390 if (this._executionSourceFrame)
391 this._executionSourceFrame.clearExecutionLine();
392 delete this._executionSourceFrame;
393 },
394
395 setExecutionLine: function(uiLocation)
396 {
397 var sourceFrame = this._getOrCreateSourceFrame(uiLocation.uiSourceCode);
398 sourceFrame.setExecutionLine(uiLocation.lineNumber);
399 this._executionSourceFrame = sourceFrame;
400 },
401
402 _editorClosed: function(event)
403 {
404 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data );
405 this._historyManager.removeHistoryForSourceCode(uiSourceCode);
406
407 var wasSelected = false;
408 if (this._currentUISourceCode === uiSourceCode) {
409 delete this._currentUISourceCode;
410 wasSelected = true;
411 }
412
413 // SourcesNavigator does not need to update on EditorClosed.
414 this._updateScriptViewStatusBarItems();
415 this._searchableView.resetSearch();
416
417 var data = {};
418 data.uiSourceCode = uiSourceCode;
419 data.wasSelected = wasSelected;
420 this.dispatchEventToListeners(WebInspector.SourcesEditor.Events.EditorCl osed, data);
421 },
422
423 _editorSelected: function(event)
424 {
425 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data .currentFile);
426 var shouldUseHistoryManager = uiSourceCode !== this._currentUISourceCode && event.data.userGesture;
427 if (shouldUseHistoryManager)
428 this._historyManager.updateCurrentState();
429 var sourceFrame = this._showFile(uiSourceCode);
430 if (shouldUseHistoryManager)
431 this._historyManager.pushNewState();
432
433 this._searchableView.setReplaceable(!!sourceFrame && sourceFrame.canEdit Source());
434 this._searchableView.resetSearch();
435
436 this.dispatchEventToListeners(WebInspector.SourcesEditor.Events.EditorSe lected, uiSourceCode);
437 },
438
439 /**
440 * @param {!WebInspector.UISourceCode} uiSourceCode
441 */
442 sourceRenamed: function(uiSourceCode)
443 {
444 this._recreateSourceFrameIfNeeded(uiSourceCode);
445 },
446
447 searchCanceled: function()
448 {
449 if (this._searchView)
450 this._searchView.searchCanceled();
451
452 delete this._searchView;
453 delete this._searchQuery;
454 },
455
456 /**
457 * @param {string} query
458 * @param {boolean} shouldJump
459 */
460 performSearch: function(query, shouldJump)
461 {
462 this._searchableView.updateSearchMatchesCount(0);
463
464 var sourceFrame = this.currentSourceFrame();
465 if (!sourceFrame)
466 return;
467
468 this._searchView = sourceFrame;
469 this._searchQuery = query;
470
471 /**
472 * @param {!WebInspector.View} view
473 * @param {number} searchMatches
474 * @this {WebInspector.SourcesEditor}
475 */
476 function finishedCallback(view, searchMatches)
477 {
478 if (!searchMatches)
479 return;
480
481 this._searchableView.updateSearchMatchesCount(searchMatches);
482 }
483
484 /**
485 * @param {number} currentMatchIndex
486 * @this {WebInspector.SourcesEditor}
487 */
488 function currentMatchChanged(currentMatchIndex)
489 {
490 this._searchableView.updateCurrentMatchIndex(currentMatchIndex);
491 }
492
493 /**
494 * @this {WebInspector.SourcesEditor}
495 */
496 function searchResultsChanged()
497 {
498 this._searchableView.cancelSearch();
499 }
500
501 this._searchView.performSearch(query, shouldJump, finishedCallback.bind( this), currentMatchChanged.bind(this), searchResultsChanged.bind(this));
502 },
503
504 jumpToNextSearchResult: function()
505 {
506 if (!this._searchView)
507 return;
508
509 if (this._searchView !== this.currentSourceFrame()) {
510 this.performSearch(this._searchQuery, true);
511 return;
512 }
513
514 this._searchView.jumpToNextSearchResult();
515 },
516
517 jumpToPreviousSearchResult: function()
518 {
519 if (!this._searchView)
520 return;
521
522 if (this._searchView !== this.currentSourceFrame()) {
523 this.performSearch(this._searchQuery, true);
524 if (this._searchView)
525 this._searchView.jumpToLastSearchResult();
526 return;
527 }
528
529 this._searchView.jumpToPreviousSearchResult();
530 },
531
532 /**
533 * @param {string} text
534 */
535 replaceSelectionWith: function(text)
536 {
537 var sourceFrame = this.currentSourceFrame();
538 if (!sourceFrame) {
539 console.assert(sourceFrame);
540 return;
541 }
542 sourceFrame.replaceSelectionWith(text);
543 },
544
545 /**
546 * @param {string} query
547 * @param {string} text
548 */
549 replaceAllWith: function(query, text)
550 {
551 var sourceFrame = this.currentSourceFrame();
552 if (!sourceFrame) {
553 console.assert(sourceFrame);
554 return;
555 }
556 sourceFrame.replaceAllWith(query, text);
557 },
558
559 /**
560 * @param {?Event=} event
561 * @return {boolean}
562 */
563 _showOutlineDialog: function(event)
564 {
565 var uiSourceCode = this._editorContainer.currentFile();
566 if (!uiSourceCode)
567 return false;
568
569 switch (uiSourceCode.contentType()) {
570 case WebInspector.resourceTypes.Document:
571 case WebInspector.resourceTypes.Script:
572 WebInspector.JavaScriptOutlineDialog.show(this._sourcesView, uiSourc eCode, this.showSourceLocation.bind(this, uiSourceCode));
573 return true;
574 case WebInspector.resourceTypes.Stylesheet:
575 WebInspector.StyleSheetOutlineDialog.show(this._sourcesView, uiSourc eCode, this.showSourceLocation.bind(this, uiSourceCode));
576 return true;
577 }
578 return false;
579 },
580
581 /**
582 * @param {string=} query
583 */
584 showOpenResourceDialog: function(query)
585 {
586 var uiSourceCodes = this._editorContainer.historyUISourceCodes();
587 /** @type {!Map.<!WebInspector.UISourceCode, number>} */
588 var defaultScores = new Map();
589 for (var i = 1; i < uiSourceCodes.length; ++i) // Skip current element
590 defaultScores.put(uiSourceCodes[i], uiSourceCodes.length - i);
591 WebInspector.OpenResourceDialog.show(this, this._sourcesView.element, qu ery, defaultScores);
592 },
593
594 /**
595 * @param {?Event=} event
596 * @return {boolean}
597 */
598 _showGoToLineDialog: function(event)
599 {
600 this.showOpenResourceDialog(":");
601 return true;
602 },
603
604 /**
605 * @return {boolean}
606 */
607 _toggleBreakpoint: function()
608 {
609 var sourceFrame = this.currentSourceFrame();
610 if (!sourceFrame)
611 return false;
612
613 if (sourceFrame instanceof WebInspector.JavaScriptSourceFrame) {
614 var javaScriptSourceFrame = /** @type {!WebInspector.JavaScriptSourc eFrame} */ (sourceFrame);
615 javaScriptSourceFrame.toggleBreakpointOnCurrentLine();
616 return true;
617 }
618 return false;
619 },
620
621 /**
622 * @param {boolean} active
623 */
624 toggleBreakpointsActiveState: function(active)
625 {
626 this._editorContainer.view.element.classList.toggle("breakpoints-deactiv ated", !active);
627 },
628
629 __proto__: WebInspector.Object.prototype
630 }
631
632 /**
633 * @constructor
634 * @extends {WebInspector.VBox}
635 */
636 WebInspector.SourcesView = function()
637 {
638 WebInspector.VBox.call(this);
639 this.registerRequiredCSS("sourcesView.css");
640 this.element.id = "sources-panel-sources-view";
641 this.element.addEventListener("dragenter", this._onDragEnter.bind(this), tru e);
642 this.element.addEventListener("dragover", this._onDragOver.bind(this), true) ;
643 }
644
645 WebInspector.SourcesView.dragAndDropFilesType = "Files";
646
647 WebInspector.SourcesView.prototype = {
648 _onDragEnter: function (event)
649 {
650 if (event.dataTransfer.types.indexOf(WebInspector.SourcesView.dragAndDro pFilesType) === -1)
651 return;
652 event.consume(true);
653 },
654
655 _onDragOver: function (event)
656 {
657 if (event.dataTransfer.types.indexOf(WebInspector.SourcesView.dragAndDro pFilesType) === -1)
658 return;
659 event.consume(true);
660 if (this._dragMaskElement)
661 return;
662 this._dragMaskElement = this.element.createChild("div", "fill drag-mask" );
663 this._dragMaskElement.addEventListener("drop", this._onDrop.bind(this), true);
664 this._dragMaskElement.addEventListener("dragleave", this._onDragLeave.bi nd(this), true);
665 },
666
667 _onDrop: function (event)
668 {
669 event.consume(true);
670 this._removeMask();
671 var items = /** @type {!Array.<!DataTransferItem>} */ (event.dataTransfe r.items);
672 if (!items.length)
673 return;
674 var entry = items[0].webkitGetAsEntry();
675 if (!entry.isDirectory)
676 return;
677 InspectorFrontendHost.upgradeDraggedFileSystemPermissions(entry.filesyst em);
678 },
679
680 _onDragLeave: function (event)
681 {
682 event.consume(true);
683 this._removeMask();
684 },
685
686 _removeMask: function ()
687 {
688 this._dragMaskElement.remove();
689 delete this._dragMaskElement;
690 },
691
692 __proto__: WebInspector.VBox.prototype
693 }
694
695 /**
696 * @interface
697 */
698 WebInspector.SourcesEditor.EditorAction = function()
699 {
700 }
701
702 WebInspector.SourcesEditor.EditorAction.prototype = {
703 /**
704 * @param {!WebInspector.SourcesEditor} sourcesEditor
705 * @return {!Element}
706 */
707 button: function(sourcesEditor) { }
708 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698