| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * | 10 * |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @constructor | 30 * @constructor |
| 31 * @extends {WebInspector.VBox} | 31 * @extends {WebInspector.VBox} |
| 32 * @implements {WebInspector.TargetManager.Observer} | 32 * @implements {WebInspector.TargetManager.Observer} |
| 33 */ | 33 */ |
| 34 WebInspector.NavigatorView = function() | 34 WebInspector.NavigatorView = function() |
| 35 { | 35 { |
| 36 WebInspector.VBox.call(this); | 36 WebInspector.VBox.call(this); |
| 37 | 37 |
| 38 var scriptsOutlineElement = this.element.createChild("div", "navigator"); | |
| 39 this._scriptsTree = new TreeOutlineInShadow(); | 38 this._scriptsTree = new TreeOutlineInShadow(); |
| 40 this._scriptsTree.registerRequiredCSS("sources/navigatorView.css"); | 39 this._scriptsTree.registerRequiredCSS("sources/navigatorView.css"); |
| 41 this._scriptsTree.setComparator(WebInspector.NavigatorView._treeElementsComp
are); | 40 this._scriptsTree.setComparator(WebInspector.NavigatorView._treeElementsComp
are); |
| 42 this.element.appendChild(this._scriptsTree.element); | 41 this.element.appendChild(this._scriptsTree.element); |
| 43 this.setDefaultFocusedElement(this._scriptsTree.element); | 42 this.setDefaultFocusedElement(this._scriptsTree.element); |
| 44 | 43 |
| 45 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.NavigatorUISource
CodeTreeNode>} */ | 44 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.NavigatorUISource
CodeTreeNode>} */ |
| 46 this._uiSourceCodeNodes = new Map(); | 45 this._uiSourceCodeNodes = new Map(); |
| 47 /** @type {!Map.<string, !WebInspector.NavigatorFolderTreeNode>} */ | 46 /** @type {!Map.<string, !WebInspector.NavigatorFolderTreeNode>} */ |
| 48 this._subfolderNodes = new Map(); | 47 this._subfolderNodes = new Map(); |
| 49 | 48 |
| 50 this._rootNode = new WebInspector.NavigatorRootTreeNode(this); | 49 this._rootNode = new WebInspector.NavigatorRootTreeNode(this); |
| 51 this._rootNode.populate(); | 50 this._rootNode.populate(); |
| 52 | 51 |
| 53 /** @type {!Map.<!WebInspector.ResourceTreeFrame, !WebInspector.NavigatorGro
upTreeNode>} */ | 52 /** @type {!Map.<!WebInspector.ResourceTreeFrame, !WebInspector.NavigatorGro
upTreeNode>} */ |
| 54 this._frameNodes = new Map(); | 53 this._frameNodes = new Map(); |
| 55 | 54 |
| 56 this.element.addEventListener("contextmenu", this.handleContextMenu.bind(thi
s), false); | 55 this.element.addEventListener("contextmenu", this.handleContextMenu.bind(thi
s), false); |
| 57 | 56 |
| 58 this._navigatorGroupingSetting = WebInspector.moduleSetting("navigatorGroupi
ng"); | 57 this._navigatorGroupingByFrameSetting = WebInspector.moduleSetting("navigato
rGroupByFrame"); |
| 59 this._navigatorGroupingSetting.addChangeListener(this._groupingChanged.bind(
this)); | 58 this._navigatorGroupingByFrameSetting.addChangeListener(this._groupingChange
d.bind(this)); |
| 59 this._navigatorGroupingByDomainSetting = WebInspector.moduleSetting("navigat
orGroupByDomain"); |
| 60 this._navigatorGroupingByDomainSetting.addChangeListener(this._groupingChang
ed.bind(this)); |
| 61 this._navigatorGroupingByFolderSetting = WebInspector.moduleSetting("navigat
orGroupByFolder"); |
| 62 this._navigatorGroupingByFolderSetting.addChangeListener(this._groupingChang
ed.bind(this)); |
| 63 |
| 60 this._initGrouping(); | 64 this._initGrouping(); |
| 61 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel,
WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated,
this); | 65 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel,
WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated,
this); |
| 62 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel,
WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, th
is); | 66 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel,
WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, th
is); |
| 63 WebInspector.targetManager.observeTargets(this); | 67 WebInspector.targetManager.observeTargets(this); |
| 64 } | 68 } |
| 65 | 69 |
| 66 WebInspector.NavigatorView.Events = { | 70 WebInspector.NavigatorView.Events = { |
| 67 ItemSelected: "ItemSelected", | 71 ItemSelected: "ItemSelected", |
| 68 ItemRenamed: "ItemRenamed", | 72 ItemRenamed: "ItemRenamed", |
| 69 } | 73 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 function addFolder() | 133 function addFolder() |
| 130 { | 134 { |
| 131 WebInspector.isolatedFileSystemManager.addFileSystem(""); | 135 WebInspector.isolatedFileSystemManager.addFileSystem(""); |
| 132 } | 136 } |
| 133 | 137 |
| 134 var addFolderLabel = WebInspector.UIString.capitalize("Add ^folder to ^works
pace"); | 138 var addFolderLabel = WebInspector.UIString.capitalize("Add ^folder to ^works
pace"); |
| 135 contextMenu.appendItem(addFolderLabel, addFolder); | 139 contextMenu.appendItem(addFolderLabel, addFolder); |
| 136 } | 140 } |
| 137 | 141 |
| 138 WebInspector.NavigatorView.prototype = { | 142 WebInspector.NavigatorView.prototype = { |
| 143 /** |
| 144 * @param {!WebInspector.Workspace} workspace |
| 145 */ |
| 139 setWorkspace: function(workspace) | 146 setWorkspace: function(workspace) |
| 140 { | 147 { |
| 141 this._workspace = workspace; | 148 this._workspace = workspace; |
| 142 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceC
odeAdded, this._uiSourceCodeAdded, this); | 149 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceC
odeAdded, this._uiSourceCodeAdded, this); |
| 143 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceC
odeRemoved, this._uiSourceCodeRemoved, this); | 150 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceC
odeRemoved, this._uiSourceCodeRemoved, this); |
| 144 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRe
moved, this._projectRemoved.bind(this), this); | 151 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRe
moved, this._projectRemoved.bind(this), this); |
| 145 }, | 152 }, |
| 146 | 153 |
| 147 wasShown: function() | 154 wasShown: function() |
| 148 { | 155 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 path = WebInspector.ParsedURL.splitURLIntoPathComponents(uiSourceCod
e.path()).slice(1, -1); | 196 path = WebInspector.ParsedURL.splitURLIntoPathComponents(uiSourceCod
e.path()).slice(1, -1); |
| 190 | 197 |
| 191 var project = uiSourceCode.project(); | 198 var project = uiSourceCode.project(); |
| 192 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceC
ode); | 199 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceC
ode); |
| 193 var frame = this._uiSourceCodeFrame(uiSourceCode); | 200 var frame = this._uiSourceCodeFrame(uiSourceCode); |
| 194 | 201 |
| 195 var folderNode = this._folderNode(uiSourceCode, project, target, frame,
uiSourceCode.host(), path, isFromSourceMap); | 202 var folderNode = this._folderNode(uiSourceCode, project, target, frame,
uiSourceCode.host(), path, isFromSourceMap); |
| 196 var uiSourceCodeNode = new WebInspector.NavigatorUISourceCodeTreeNode(th
is, uiSourceCode); | 203 var uiSourceCodeNode = new WebInspector.NavigatorUISourceCodeTreeNode(th
is, uiSourceCode); |
| 197 this._uiSourceCodeNodes.set(uiSourceCode, uiSourceCodeNode); | 204 this._uiSourceCodeNodes.set(uiSourceCode, uiSourceCodeNode); |
| 198 folderNode.appendChild(uiSourceCodeNode); | 205 folderNode.appendChild(uiSourceCodeNode); |
| 206 this.uiSourceCodeAdded(uiSourceCode); |
| 199 }, | 207 }, |
| 200 | 208 |
| 201 /** | 209 /** |
| 210 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 211 */ |
| 212 uiSourceCodeAdded: function(uiSourceCode) |
| 213 { |
| 214 }, |
| 215 |
| 216 /** |
| 202 * @param {!WebInspector.Event} event | 217 * @param {!WebInspector.Event} event |
| 203 */ | 218 */ |
| 204 _uiSourceCodeAdded: function(event) | 219 _uiSourceCodeAdded: function(event) |
| 205 { | 220 { |
| 206 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | 221 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); |
| 207 this._addUISourceCode(uiSourceCode); | 222 this._addUISourceCode(uiSourceCode); |
| 208 }, | 223 }, |
| 209 | 224 |
| 210 /** | 225 /** |
| 211 * @param {!WebInspector.Event} event | 226 * @param {!WebInspector.Event} event |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 | 667 |
| 653 _groupingChanged: function() | 668 _groupingChanged: function() |
| 654 { | 669 { |
| 655 this.reset(); | 670 this.reset(); |
| 656 this._initGrouping(); | 671 this._initGrouping(); |
| 657 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)
); | 672 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)
); |
| 658 }, | 673 }, |
| 659 | 674 |
| 660 _initGrouping: function() | 675 _initGrouping: function() |
| 661 { | 676 { |
| 662 var value = this._navigatorGroupingSetting.get(); | 677 this._groupByFrame = this._navigatorGroupingByFrameSetting.get(); |
| 663 this._groupByFrame = value.includes("frame"); | 678 this._groupByDomain = this._navigatorGroupingByDomainSetting.get(); |
| 664 this._groupByDomain = value.includes("domain"); | 679 this._groupByFolder = this._groupByDomain && this._navigatorGroupingByFo
lderSetting.get(); |
| 665 this._groupByFolder = value.includes("folder"); | |
| 666 }, | 680 }, |
| 667 | 681 |
| 668 /** | 682 /** |
| 669 * @param {!WebInspector.Event} event | 683 * @param {!WebInspector.Event} event |
| 670 */ | 684 */ |
| 671 _frameNavigated: function(event) | 685 _frameNavigated: function(event) |
| 672 { | 686 { |
| 673 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); | 687 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); |
| 674 var node = this._frameNodes.get(frame); | 688 var node = this._frameNodes.get(frame); |
| 675 if (!node) | 689 if (!node) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 { | 735 { |
| 722 var targetNode = this._rootNode.child("target:" + target.id()); | 736 var targetNode = this._rootNode.child("target:" + target.id()); |
| 723 if (targetNode) | 737 if (targetNode) |
| 724 this._rootNode.removeChild(targetNode); | 738 this._rootNode.removeChild(targetNode); |
| 725 }, | 739 }, |
| 726 | 740 |
| 727 __proto__: WebInspector.VBox.prototype | 741 __proto__: WebInspector.VBox.prototype |
| 728 } | 742 } |
| 729 | 743 |
| 730 /** | 744 /** |
| 731 * @constructor | |
| 732 * @extends {WebInspector.NavigatorView} | |
| 733 */ | |
| 734 WebInspector.SourcesNavigatorView = function() | |
| 735 { | |
| 736 WebInspector.NavigatorView.call(this); | |
| 737 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event
s.InspectedURLChanged, this._inspectedURLChanged, this); | |
| 738 } | |
| 739 | |
| 740 WebInspector.SourcesNavigatorView.prototype = { | |
| 741 /** | |
| 742 * @override | |
| 743 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 744 * @return {boolean} | |
| 745 */ | |
| 746 accept: function(uiSourceCode) | |
| 747 { | |
| 748 if (!WebInspector.NavigatorView.prototype.accept(uiSourceCode)) | |
| 749 return false; | |
| 750 return uiSourceCode.project().type() !== WebInspector.projectTypes.Conte
ntScripts && uiSourceCode.project().type() !== WebInspector.projectTypes.Snippet
s; | |
| 751 | |
| 752 }, | |
| 753 | |
| 754 /** | |
| 755 * @param {!WebInspector.Event} event | |
| 756 */ | |
| 757 _inspectedURLChanged: function(event) | |
| 758 { | |
| 759 var nodes = this._uiSourceCodeNodes.valuesArray(); | |
| 760 for (var i = 0; i < nodes.length; ++i) { | |
| 761 var uiSourceCode = nodes[i].uiSourceCode(); | |
| 762 var inspectedPageURL = WebInspector.targetManager.inspectedPageURL(); | |
| 763 if (inspectedPageURL && WebInspector.networkMapping.networkURL(uiSour
ceCode) === inspectedPageURL) | |
| 764 this.revealUISourceCode(uiSourceCode, true); | |
| 765 } | |
| 766 }, | |
| 767 | |
| 768 /** | |
| 769 * @override | |
| 770 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 771 */ | |
| 772 _addUISourceCode: function(uiSourceCode) | |
| 773 { | |
| 774 WebInspector.NavigatorView.prototype._addUISourceCode.call(this, uiSourc
eCode); | |
| 775 var inspectedPageURL = WebInspector.targetManager.inspectedPageURL(); | |
| 776 if (inspectedPageURL && WebInspector.networkMapping.networkURL(uiSourceC
ode) === inspectedPageURL) | |
| 777 this.revealUISourceCode(uiSourceCode, true); | |
| 778 }, | |
| 779 | |
| 780 __proto__: WebInspector.NavigatorView.prototype | |
| 781 } | |
| 782 | |
| 783 /** | |
| 784 * @constructor | |
| 785 * @extends {WebInspector.NavigatorView} | |
| 786 */ | |
| 787 WebInspector.ContentScriptsNavigatorView = function() | |
| 788 { | |
| 789 WebInspector.NavigatorView.call(this); | |
| 790 } | |
| 791 | |
| 792 WebInspector.ContentScriptsNavigatorView.prototype = { | |
| 793 /** | |
| 794 * @override | |
| 795 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 796 * @return {boolean} | |
| 797 */ | |
| 798 accept: function(uiSourceCode) | |
| 799 { | |
| 800 if (!WebInspector.NavigatorView.prototype.accept(uiSourceCode)) | |
| 801 return false; | |
| 802 return uiSourceCode.project().type() === WebInspector.projectTypes.Conte
ntScripts; | |
| 803 }, | |
| 804 | |
| 805 __proto__: WebInspector.NavigatorView.prototype | |
| 806 } | |
| 807 | |
| 808 /** | |
| 809 * @param {!TreeElement} treeElement1 | 745 * @param {!TreeElement} treeElement1 |
| 810 * @param {!TreeElement} treeElement2 | 746 * @param {!TreeElement} treeElement2 |
| 811 * @return {number} | 747 * @return {number} |
| 812 */ | 748 */ |
| 813 WebInspector.NavigatorView._treeElementsCompare = function compare(treeElement1,
treeElement2) | 749 WebInspector.NavigatorView._treeElementsCompare = function compare(treeElement1,
treeElement2) |
| 814 { | 750 { |
| 815 var typeWeight1 = WebInspector.NavigatorView._treeElementOrder(treeElement1)
; | 751 var typeWeight1 = WebInspector.NavigatorView._treeElementOrder(treeElement1)
; |
| 816 var typeWeight2 = WebInspector.NavigatorView._treeElementOrder(treeElement2)
; | 752 var typeWeight2 = WebInspector.NavigatorView._treeElementOrder(treeElement2)
; |
| 817 | 753 |
| 818 var result; | 754 var result; |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 { | 1483 { |
| 1548 if (this._treeElement) | 1484 if (this._treeElement) |
| 1549 return this._treeElement; | 1485 return this._treeElement; |
| 1550 this._treeElement = new WebInspector.NavigatorFolderTreeElement(this._na
vigatorView, this._type, this._title); | 1486 this._treeElement = new WebInspector.NavigatorFolderTreeElement(this._na
vigatorView, this._type, this._title); |
| 1551 this._treeElement.setNode(this); | 1487 this._treeElement.setNode(this); |
| 1552 return this._treeElement; | 1488 return this._treeElement; |
| 1553 }, | 1489 }, |
| 1554 | 1490 |
| 1555 __proto__: WebInspector.NavigatorTreeNode.prototype | 1491 __proto__: WebInspector.NavigatorTreeNode.prototype |
| 1556 } | 1492 } |
| OLD | NEW |