| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @implements {WebInspector.TabbedEditorContainerDelegate} | 7 * @implements {WebInspector.TabbedEditorContainerDelegate} |
| 8 * @implements {WebInspector.Searchable} | 8 * @implements {WebInspector.Searchable} |
| 9 * @implements {WebInspector.Replaceable} | 9 * @implements {WebInspector.Replaceable} |
| 10 * @extends {WebInspector.Object} | 10 * @extends {WebInspector.VBox} |
| 11 * @param {!WebInspector.Workspace} workspace | 11 * @param {!WebInspector.Workspace} workspace |
| 12 * @param {!WebInspector.SourcesPanel} sourcesPanel | 12 * @param {!WebInspector.SourcesPanel} sourcesPanel |
| 13 */ | 13 */ |
| 14 WebInspector.SourcesEditor = function(workspace, sourcesPanel) | 14 WebInspector.SourcesView = function(workspace, sourcesPanel) |
| 15 { | 15 { |
| 16 WebInspector.VBox.call(this); |
| 17 this.registerRequiredCSS("sourcesView.css"); |
| 18 this.element.id = "sources-panel-sources-view"; |
| 19 |
| 16 this._workspace = workspace; | 20 this._workspace = workspace; |
| 17 this._sourcesPanel = sourcesPanel; | 21 this._sourcesPanel = sourcesPanel; |
| 18 | 22 |
| 19 this._sourcesView = new WebInspector.SourcesView(); | |
| 20 | |
| 21 this._searchableView = new WebInspector.SearchableView(this); | 23 this._searchableView = new WebInspector.SearchableView(this); |
| 22 this._searchableView.setMinimalSearchQuerySize(0); | 24 this._searchableView.setMinimalSearchQuerySize(0); |
| 23 this._searchableView.show(this._sourcesView.element); | 25 this._searchableView.show(this.element); |
| 24 | 26 |
| 25 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.SourceFrame>} */ | 27 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.SourceFrame>} */ |
| 26 this._sourceFramesByUISourceCode = new Map(); | 28 this._sourceFramesByUISourceCode = new Map(); |
| 27 | 29 |
| 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"); | 30 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); | 31 this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previo
uslyViewedFiles", tabbedEditorPlaceholderText); |
| 30 this._editorContainer.show(this._searchableView.element); | 32 this._editorContainer.show(this._searchableView.element); |
| 31 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorSelected, this._editorSelected, this); | 33 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorSelected, this._editorSelected, this); |
| 32 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorClosed, this._editorClosed, this); | 34 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorClosed, this._editorClosed, this); |
| 33 | 35 |
| 34 this._historyManager = new WebInspector.EditingLocationHistoryManager(this,
this.currentSourceFrame.bind(this)); | 36 this._historyManager = new WebInspector.EditingLocationHistoryManager(this,
this.currentSourceFrame.bind(this)); |
| 35 | 37 |
| 36 this._scriptViewStatusBarItemsContainer = document.createElement("div"); | 38 this._scriptViewStatusBarItemsContainer = document.createElement("div"); |
| 37 this._scriptViewStatusBarItemsContainer.className = "inline-block"; | 39 this._scriptViewStatusBarItemsContainer.className = "inline-block"; |
| 38 | 40 |
| 39 this._scriptViewStatusBarTextContainer = document.createElement("div"); | 41 this._scriptViewStatusBarTextContainer = document.createElement("div"); |
| 40 this._scriptViewStatusBarTextContainer.className = "hbox"; | 42 this._scriptViewStatusBarTextContainer.className = "hbox"; |
| 41 | 43 |
| 42 this._statusBarContainerElement = this._sourcesView.element.createChild("div
", "sources-status-bar"); | 44 this._statusBarContainerElement = this.element.createChild("div", "sources-s
tatus-bar"); |
| 43 | 45 |
| 44 /** | 46 /** |
| 45 * @this {WebInspector.SourcesEditor} | 47 * @this {WebInspector.SourcesView} |
| 46 * @param {!WebInspector.SourcesEditor.EditorAction} EditorAction | 48 * @param {!WebInspector.SourcesView.EditorAction} EditorAction |
| 47 */ | 49 */ |
| 48 function appendButtonForExtension(EditorAction) | 50 function appendButtonForExtension(EditorAction) |
| 49 { | 51 { |
| 50 this._statusBarContainerElement.appendChild(EditorAction.button(this)); | 52 this._statusBarContainerElement.appendChild(EditorAction.button(this)); |
| 51 } | 53 } |
| 52 var editorActions = /** @type {!Array.<!WebInspector.SourcesEditor.EditorAct
ion>} */ (WebInspector.moduleManager.instances(WebInspector.SourcesEditor.Editor
Action)); | 54 var editorActions = /** @type {!Array.<!WebInspector.SourcesView.EditorActio
n>} */ (WebInspector.moduleManager.instances(WebInspector.SourcesView.EditorActi
on)); |
| 53 editorActions.forEach(appendButtonForExtension.bind(this)); | 55 editorActions.forEach(appendButtonForExtension.bind(this)); |
| 54 | 56 |
| 55 this._statusBarContainerElement.appendChild(this._scriptViewStatusBarItemsCo
ntainer); | 57 this._statusBarContainerElement.appendChild(this._scriptViewStatusBarItemsCo
ntainer); |
| 56 this._statusBarContainerElement.appendChild(this._scriptViewStatusBarTextCon
tainer); | 58 this._statusBarContainerElement.appendChild(this._scriptViewStatusBarTextCon
tainer); |
| 57 | 59 |
| 58 WebInspector.startBatchUpdate(); | 60 WebInspector.startBatchUpdate(); |
| 59 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); | 61 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); |
| 60 WebInspector.endBatchUpdate(); | 62 WebInspector.endBatchUpdate(); |
| 61 | 63 |
| 62 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAdded, this); | 64 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAdded, this); |
| 63 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR
emoved, this._uiSourceCodeRemoved, this); | 65 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); | 66 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillRe
set, this._projectWillReset.bind(this), this); |
| 65 | 67 |
| 66 function handleBeforeUnload(event) | 68 function handleBeforeUnload(event) |
| 67 { | 69 { |
| 68 if (event.returnValue) | 70 if (event.returnValue) |
| 69 return; | 71 return; |
| 70 var unsavedSourceCodes = WebInspector.workspace.unsavedSourceCodes(); | 72 var unsavedSourceCodes = WebInspector.workspace.unsavedSourceCodes(); |
| 71 if (!unsavedSourceCodes.length) | 73 if (!unsavedSourceCodes.length) |
| 72 return; | 74 return; |
| 73 | 75 |
| 74 event.returnValue = WebInspector.UIString("DevTools have unsaved changes
that will be permanently lost."); | 76 event.returnValue = WebInspector.UIString("DevTools have unsaved changes
that will be permanently lost."); |
| 75 WebInspector.inspectorView.showPanel("sources"); | 77 WebInspector.inspectorView.showPanel("sources"); |
| 76 for (var i = 0; i < unsavedSourceCodes.length; ++i) | 78 for (var i = 0; i < unsavedSourceCodes.length; ++i) |
| 77 WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]); | 79 WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]); |
| 78 } | 80 } |
| 79 window.addEventListener("beforeunload", handleBeforeUnload, true); | 81 window.addEventListener("beforeunload", handleBeforeUnload, true); |
| 80 } | 82 } |
| 81 | 83 |
| 82 WebInspector.SourcesEditor.Events = { | 84 WebInspector.SourcesView.Events = { |
| 83 EditorClosed: "EditorClosed", | 85 EditorClosed: "EditorClosed", |
| 84 EditorSelected: "EditorSelected", | 86 EditorSelected: "EditorSelected", |
| 85 } | 87 } |
| 86 | 88 |
| 87 WebInspector.SourcesEditor.prototype = { | 89 WebInspector.SourcesView.prototype = { |
| 88 /** | 90 /** |
| 89 * @param {function(!Array.<!WebInspector.KeyboardShortcut.Descriptor>, func
tion(?Event=):boolean)} registerShortcutDelegate | 91 * @param {function(!Array.<!WebInspector.KeyboardShortcut.Descriptor>, func
tion(?Event=):boolean)} registerShortcutDelegate |
| 90 */ | 92 */ |
| 91 registerShortcuts: function(registerShortcutDelegate) | 93 registerShortcuts: function(registerShortcutDelegate) |
| 92 { | 94 { |
| 93 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc
uts.JumpToPreviousLocation, this._onJumpToPreviousLocation.bind(this)); | 95 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc
uts.JumpToPreviousLocation, this._onJumpToPreviousLocation.bind(this)); |
| 94 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc
uts.JumpToNextLocation, this._onJumpToNextLocation.bind(this)); | 96 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc
uts.JumpToNextLocation, this._onJumpToNextLocation.bind(this)); |
| 95 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc
uts.CloseEditorTab, this._onCloseEditorTab.bind(this)); | 97 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc
uts.CloseEditorTab, this._onCloseEditorTab.bind(this)); |
| 96 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc
uts.GoToLine, this._showGoToLineDialog.bind(this)); | 98 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc
uts.GoToLine, this._showGoToLineDialog.bind(this)); |
| 97 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc
uts.GoToMember, this._showOutlineDialog.bind(this)); | 99 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc
uts.GoToMember, this._showOutlineDialog.bind(this)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 116 | 118 |
| 117 /** | 119 /** |
| 118 * @return {!WebInspector.SearchableView} | 120 * @return {!WebInspector.SearchableView} |
| 119 */ | 121 */ |
| 120 searchableView: function() | 122 searchableView: function() |
| 121 { | 123 { |
| 122 return this._searchableView; | 124 return this._searchableView; |
| 123 }, | 125 }, |
| 124 | 126 |
| 125 /** | 127 /** |
| 126 * @return {!WebInspector.SourcesView} | |
| 127 */ | |
| 128 sourcesView: function() | |
| 129 { | |
| 130 return this._sourcesView; | |
| 131 }, | |
| 132 | |
| 133 /** | |
| 134 * @return {!WebInspector.View} | 128 * @return {!WebInspector.View} |
| 135 */ | 129 */ |
| 136 visibleView: function() | 130 visibleView: function() |
| 137 { | 131 { |
| 138 return this._editorContainer.visibleView; | 132 return this._editorContainer.visibleView; |
| 139 }, | 133 }, |
| 140 | 134 |
| 141 /** | 135 /** |
| 142 * @return {?WebInspector.SourceFrame} | 136 * @return {?WebInspector.SourceFrame} |
| 143 */ | 137 */ |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 wasSelected = true; | 404 wasSelected = true; |
| 411 } | 405 } |
| 412 | 406 |
| 413 // SourcesNavigator does not need to update on EditorClosed. | 407 // SourcesNavigator does not need to update on EditorClosed. |
| 414 this._updateScriptViewStatusBarItems(); | 408 this._updateScriptViewStatusBarItems(); |
| 415 this._searchableView.resetSearch(); | 409 this._searchableView.resetSearch(); |
| 416 | 410 |
| 417 var data = {}; | 411 var data = {}; |
| 418 data.uiSourceCode = uiSourceCode; | 412 data.uiSourceCode = uiSourceCode; |
| 419 data.wasSelected = wasSelected; | 413 data.wasSelected = wasSelected; |
| 420 this.dispatchEventToListeners(WebInspector.SourcesEditor.Events.EditorCl
osed, data); | 414 this.dispatchEventToListeners(WebInspector.SourcesView.Events.EditorClos
ed, data); |
| 421 }, | 415 }, |
| 422 | 416 |
| 423 _editorSelected: function(event) | 417 _editorSelected: function(event) |
| 424 { | 418 { |
| 425 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
.currentFile); | 419 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
.currentFile); |
| 426 var shouldUseHistoryManager = uiSourceCode !== this._currentUISourceCode
&& event.data.userGesture; | 420 var shouldUseHistoryManager = uiSourceCode !== this._currentUISourceCode
&& event.data.userGesture; |
| 427 if (shouldUseHistoryManager) | 421 if (shouldUseHistoryManager) |
| 428 this._historyManager.updateCurrentState(); | 422 this._historyManager.updateCurrentState(); |
| 429 var sourceFrame = this._showFile(uiSourceCode); | 423 var sourceFrame = this._showFile(uiSourceCode); |
| 430 if (shouldUseHistoryManager) | 424 if (shouldUseHistoryManager) |
| 431 this._historyManager.pushNewState(); | 425 this._historyManager.pushNewState(); |
| 432 | 426 |
| 433 this._searchableView.setReplaceable(!!sourceFrame && sourceFrame.canEdit
Source()); | 427 this._searchableView.setReplaceable(!!sourceFrame && sourceFrame.canEdit
Source()); |
| 434 this._searchableView.resetSearch(); | 428 this._searchableView.resetSearch(); |
| 435 | 429 |
| 436 this.dispatchEventToListeners(WebInspector.SourcesEditor.Events.EditorSe
lected, uiSourceCode); | 430 this.dispatchEventToListeners(WebInspector.SourcesView.Events.EditorSele
cted, uiSourceCode); |
| 437 }, | 431 }, |
| 438 | 432 |
| 439 /** | 433 /** |
| 440 * @param {!WebInspector.UISourceCode} uiSourceCode | 434 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 441 */ | 435 */ |
| 442 sourceRenamed: function(uiSourceCode) | 436 sourceRenamed: function(uiSourceCode) |
| 443 { | 437 { |
| 444 this._recreateSourceFrameIfNeeded(uiSourceCode); | 438 this._recreateSourceFrameIfNeeded(uiSourceCode); |
| 445 }, | 439 }, |
| 446 | 440 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 464 var sourceFrame = this.currentSourceFrame(); | 458 var sourceFrame = this.currentSourceFrame(); |
| 465 if (!sourceFrame) | 459 if (!sourceFrame) |
| 466 return; | 460 return; |
| 467 | 461 |
| 468 this._searchView = sourceFrame; | 462 this._searchView = sourceFrame; |
| 469 this._searchQuery = query; | 463 this._searchQuery = query; |
| 470 | 464 |
| 471 /** | 465 /** |
| 472 * @param {!WebInspector.View} view | 466 * @param {!WebInspector.View} view |
| 473 * @param {number} searchMatches | 467 * @param {number} searchMatches |
| 474 * @this {WebInspector.SourcesEditor} | 468 * @this {WebInspector.SourcesView} |
| 475 */ | 469 */ |
| 476 function finishedCallback(view, searchMatches) | 470 function finishedCallback(view, searchMatches) |
| 477 { | 471 { |
| 478 if (!searchMatches) | 472 if (!searchMatches) |
| 479 return; | 473 return; |
| 480 | 474 |
| 481 this._searchableView.updateSearchMatchesCount(searchMatches); | 475 this._searchableView.updateSearchMatchesCount(searchMatches); |
| 482 } | 476 } |
| 483 | 477 |
| 484 /** | 478 /** |
| 485 * @param {number} currentMatchIndex | 479 * @param {number} currentMatchIndex |
| 486 * @this {WebInspector.SourcesEditor} | 480 * @this {WebInspector.SourcesView} |
| 487 */ | 481 */ |
| 488 function currentMatchChanged(currentMatchIndex) | 482 function currentMatchChanged(currentMatchIndex) |
| 489 { | 483 { |
| 490 this._searchableView.updateCurrentMatchIndex(currentMatchIndex); | 484 this._searchableView.updateCurrentMatchIndex(currentMatchIndex); |
| 491 } | 485 } |
| 492 | 486 |
| 493 /** | 487 /** |
| 494 * @this {WebInspector.SourcesEditor} | 488 * @this {WebInspector.SourcesView} |
| 495 */ | 489 */ |
| 496 function searchResultsChanged() | 490 function searchResultsChanged() |
| 497 { | 491 { |
| 498 this._searchableView.cancelSearch(); | 492 this._searchableView.cancelSearch(); |
| 499 } | 493 } |
| 500 | 494 |
| 501 this._searchView.performSearch(query, shouldJump, finishedCallback.bind(
this), currentMatchChanged.bind(this), searchResultsChanged.bind(this)); | 495 this._searchView.performSearch(query, shouldJump, finishedCallback.bind(
this), currentMatchChanged.bind(this), searchResultsChanged.bind(this)); |
| 502 }, | 496 }, |
| 503 | 497 |
| 504 jumpToNextSearchResult: function() | 498 jumpToNextSearchResult: function() |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 */ | 556 */ |
| 563 _showOutlineDialog: function(event) | 557 _showOutlineDialog: function(event) |
| 564 { | 558 { |
| 565 var uiSourceCode = this._editorContainer.currentFile(); | 559 var uiSourceCode = this._editorContainer.currentFile(); |
| 566 if (!uiSourceCode) | 560 if (!uiSourceCode) |
| 567 return false; | 561 return false; |
| 568 | 562 |
| 569 switch (uiSourceCode.contentType()) { | 563 switch (uiSourceCode.contentType()) { |
| 570 case WebInspector.resourceTypes.Document: | 564 case WebInspector.resourceTypes.Document: |
| 571 case WebInspector.resourceTypes.Script: | 565 case WebInspector.resourceTypes.Script: |
| 572 WebInspector.JavaScriptOutlineDialog.show(this._sourcesView, uiSourc
eCode, this.showSourceLocation.bind(this, uiSourceCode)); | 566 WebInspector.JavaScriptOutlineDialog.show(this, uiSourceCode, this.s
howSourceLocation.bind(this, uiSourceCode)); |
| 573 return true; | 567 return true; |
| 574 case WebInspector.resourceTypes.Stylesheet: | 568 case WebInspector.resourceTypes.Stylesheet: |
| 575 WebInspector.StyleSheetOutlineDialog.show(this._sourcesView, uiSourc
eCode, this.showSourceLocation.bind(this, uiSourceCode)); | 569 WebInspector.StyleSheetOutlineDialog.show(this, uiSourceCode, this.s
howSourceLocation.bind(this, uiSourceCode)); |
| 576 return true; | 570 return true; |
| 577 } | 571 } |
| 578 return false; | 572 return false; |
| 579 }, | 573 }, |
| 580 | 574 |
| 581 /** | 575 /** |
| 582 * @param {string=} query | 576 * @param {string=} query |
| 583 */ | 577 */ |
| 584 showOpenResourceDialog: function(query) | 578 showOpenResourceDialog: function(query) |
| 585 { | 579 { |
| 586 var uiSourceCodes = this._editorContainer.historyUISourceCodes(); | 580 var uiSourceCodes = this._editorContainer.historyUISourceCodes(); |
| 587 /** @type {!Map.<!WebInspector.UISourceCode, number>} */ | 581 /** @type {!Map.<!WebInspector.UISourceCode, number>} */ |
| 588 var defaultScores = new Map(); | 582 var defaultScores = new Map(); |
| 589 for (var i = 1; i < uiSourceCodes.length; ++i) // Skip current element | 583 for (var i = 1; i < uiSourceCodes.length; ++i) // Skip current element |
| 590 defaultScores.put(uiSourceCodes[i], uiSourceCodes.length - i); | 584 defaultScores.put(uiSourceCodes[i], uiSourceCodes.length - i); |
| 591 WebInspector.OpenResourceDialog.show(this, this._sourcesView.element, qu
ery, defaultScores); | 585 WebInspector.OpenResourceDialog.show(this, this.element, query, defaultS
cores); |
| 592 }, | 586 }, |
| 593 | 587 |
| 594 /** | 588 /** |
| 595 * @param {?Event=} event | 589 * @param {?Event=} event |
| 596 * @return {boolean} | 590 * @return {boolean} |
| 597 */ | 591 */ |
| 598 _showGoToLineDialog: function(event) | 592 _showGoToLineDialog: function(event) |
| 599 { | 593 { |
| 600 this.showOpenResourceDialog(":"); | 594 this.showOpenResourceDialog(":"); |
| 601 return true; | 595 return true; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 619 }, | 613 }, |
| 620 | 614 |
| 621 /** | 615 /** |
| 622 * @param {boolean} active | 616 * @param {boolean} active |
| 623 */ | 617 */ |
| 624 toggleBreakpointsActiveState: function(active) | 618 toggleBreakpointsActiveState: function(active) |
| 625 { | 619 { |
| 626 this._editorContainer.view.element.classList.toggle("breakpoints-deactiv
ated", !active); | 620 this._editorContainer.view.element.classList.toggle("breakpoints-deactiv
ated", !active); |
| 627 }, | 621 }, |
| 628 | 622 |
| 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 | 623 __proto__: WebInspector.VBox.prototype |
| 693 } | 624 } |
| 694 | 625 |
| 695 /** | 626 /** |
| 696 * @interface | 627 * @interface |
| 697 */ | 628 */ |
| 698 WebInspector.SourcesEditor.EditorAction = function() | 629 WebInspector.SourcesView.EditorAction = function() |
| 699 { | 630 { |
| 700 } | 631 } |
| 701 | 632 |
| 702 WebInspector.SourcesEditor.EditorAction.prototype = { | 633 WebInspector.SourcesView.EditorAction.prototype = { |
| 703 /** | 634 /** |
| 704 * @param {!WebInspector.SourcesEditor} sourcesEditor | 635 * @param {!WebInspector.SourcesView} sourcesView |
| 705 * @return {!Element} | 636 * @return {!Element} |
| 706 */ | 637 */ |
| 707 button: function(sourcesEditor) { } | 638 button: function(sourcesView) { } |
| 708 } | 639 } |
| OLD | NEW |