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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 this._frameNodes = new Map(); | 53 this._frameNodes = new Map(); |
54 | 54 |
55 this.element.addEventListener("contextmenu", this.handleContextMenu.bind(thi
s), false); | 55 this.element.addEventListener("contextmenu", this.handleContextMenu.bind(thi
s), false); |
56 | 56 |
57 this._navigatorGroupByFolderSetting = WebInspector.moduleSetting("navigatorG
roupByFolder"); | 57 this._navigatorGroupByFolderSetting = WebInspector.moduleSetting("navigatorG
roupByFolder"); |
58 this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged.
bind(this)); | 58 this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged.
bind(this)); |
59 | 59 |
60 this._initGrouping(); | 60 this._initGrouping(); |
61 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel,
WebInspector.ResourceTreeModel.Events.FrameNavigated, this._frameNavigated, this
); | 61 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel,
WebInspector.ResourceTreeModel.Events.FrameNavigated, this._frameNavigated, this
); |
62 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel,
WebInspector.ResourceTreeModel.Events.FrameDetached, this._frameDetached, this); | 62 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel,
WebInspector.ResourceTreeModel.Events.FrameDetached, this._frameDetached, this); |
63 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi
ndingCreated, this._onBindingChanged, this); | 63 |
64 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi
ndingRemoved, this._onBindingChanged, this); | 64 if (Runtime.experiments.isEnabled("persistence2")) { |
| 65 WebInspector.persistence.addEventListener(WebInspector.Persistence.Event
s.BindingCreated, this._onBindingChanged, this); |
| 66 WebInspector.persistence.addEventListener(WebInspector.Persistence.Event
s.BindingRemoved, this._onBindingChanged, this); |
| 67 } else { |
| 68 WebInspector.persistence.addEventListener(WebInspector.Persistence.Event
s.BindingCreated, this._onBindingCreated, this); |
| 69 WebInspector.persistence.addEventListener(WebInspector.Persistence.Event
s.BindingRemoved, this._onBindingRemoved, this); |
| 70 } |
65 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event
s.NameChanged, this._targetNameChanged, this); | 71 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event
s.NameChanged, this._targetNameChanged, this); |
66 | 72 |
67 WebInspector.targetManager.observeTargets(this); | 73 WebInspector.targetManager.observeTargets(this); |
68 this._resetWorkspace(WebInspector.workspace); | 74 this._resetWorkspace(WebInspector.workspace); |
69 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); | 75 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); |
70 } | 76 } |
71 | 77 |
72 WebInspector.NavigatorView.Types = { | 78 WebInspector.NavigatorView.Types = { |
73 Category: "category", | 79 Category: "category", |
74 Domain: "domain", | 80 Domain: "domain", |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 path = "*"; | 158 path = "*"; |
153 searchLabel = WebInspector.UIString("Search in all files"); | 159 searchLabel = WebInspector.UIString("Search in all files"); |
154 } | 160 } |
155 contextMenu.appendItem(searchLabel, searchPath); | 161 contextMenu.appendItem(searchLabel, searchPath); |
156 } | 162 } |
157 | 163 |
158 WebInspector.NavigatorView.prototype = { | 164 WebInspector.NavigatorView.prototype = { |
159 /** | 165 /** |
160 * @param {!WebInspector.Event} event | 166 * @param {!WebInspector.Event} event |
161 */ | 167 */ |
| 168 _onBindingCreated: function(event) |
| 169 { |
| 170 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data
); |
| 171 this._removeUISourceCode(binding.network); |
| 172 }, |
| 173 |
| 174 /** |
| 175 * @param {!WebInspector.Event} event |
| 176 */ |
| 177 _onBindingRemoved: function(event) |
| 178 { |
| 179 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data
); |
| 180 this._addUISourceCode(binding.network); |
| 181 }, |
| 182 |
| 183 /** |
| 184 * @param {!WebInspector.Event} event |
| 185 */ |
162 _onBindingChanged: function(event) | 186 _onBindingChanged: function(event) |
163 { | 187 { |
164 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data
); | 188 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data
); |
165 | 189 |
166 // Update UISourceCode titles. | 190 // Update UISourceCode titles. |
167 var networkNode = this._uiSourceCodeNodes.get(binding.network); | 191 var networkNode = this._uiSourceCodeNodes.get(binding.network); |
168 if (networkNode) | 192 if (networkNode) |
169 networkNode.updateTitle(); | 193 networkNode.updateTitle(); |
170 var fileSystemNode = this._uiSourceCodeNodes.get(binding.fileSystem); | 194 var fileSystemNode = this._uiSourceCodeNodes.get(binding.fileSystem); |
171 if (fileSystemNode) | 195 if (fileSystemNode) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 }, | 257 }, |
234 | 258 |
235 /** | 259 /** |
236 * @param {!WebInspector.UISourceCode} uiSourceCode | 260 * @param {!WebInspector.UISourceCode} uiSourceCode |
237 */ | 261 */ |
238 _addUISourceCode: function(uiSourceCode) | 262 _addUISourceCode: function(uiSourceCode) |
239 { | 263 { |
240 if (!this.accept(uiSourceCode)) | 264 if (!this.accept(uiSourceCode)) |
241 return; | 265 return; |
242 | 266 |
| 267 var binding = WebInspector.persistence.binding(uiSourceCode); |
| 268 if (!Runtime.experiments.isEnabled("persistence2") && binding && binding
.network === uiSourceCode) |
| 269 return; |
| 270 |
243 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); | 271 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); |
244 var path; | 272 var path; |
245 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst
em) | 273 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst
em) |
246 path = WebInspector.FileSystemWorkspaceBinding.relativePath(uiSource
Code).slice(0, -1); | 274 path = WebInspector.FileSystemWorkspaceBinding.relativePath(uiSource
Code).slice(0, -1); |
247 else | 275 else |
248 path = WebInspector.ParsedURL.splitURLIntoPathComponents(uiSourceCod
e.url()).slice(1, -1); | 276 path = WebInspector.ParsedURL.splitURLIntoPathComponents(uiSourceCod
e.url()).slice(1, -1); |
249 | 277 |
250 var project = uiSourceCode.project(); | 278 var project = uiSourceCode.project(); |
251 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceC
ode); | 279 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceC
ode); |
252 var frame = this._uiSourceCodeFrame(uiSourceCode); | 280 var frame = this._uiSourceCodeFrame(uiSourceCode); |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 updateTitle: function(ignoreIsDirty) | 1322 updateTitle: function(ignoreIsDirty) |
1295 { | 1323 { |
1296 if (!this._treeElement) | 1324 if (!this._treeElement) |
1297 return; | 1325 return; |
1298 | 1326 |
1299 var titleText = this._uiSourceCode.displayName(); | 1327 var titleText = this._uiSourceCode.displayName(); |
1300 if (!ignoreIsDirty && (this._uiSourceCode.isDirty() || WebInspector.pers
istence.hasUnsavedCommittedChanges(this._uiSourceCode))) | 1328 if (!ignoreIsDirty && (this._uiSourceCode.isDirty() || WebInspector.pers
istence.hasUnsavedCommittedChanges(this._uiSourceCode))) |
1301 titleText = "*" + titleText; | 1329 titleText = "*" + titleText; |
1302 | 1330 |
1303 var binding = WebInspector.persistence.binding(this._uiSourceCode); | 1331 var binding = WebInspector.persistence.binding(this._uiSourceCode); |
1304 if (binding) { | 1332 if (binding && Runtime.experiments.isEnabled("persistence2")) { |
1305 var titleElement = createElement("span"); | 1333 var titleElement = createElement("span"); |
1306 titleElement.textContent = titleText; | 1334 titleElement.textContent = titleText; |
1307 var status = titleElement.createChild("span"); | 1335 var status = titleElement.createChild("span"); |
1308 status.classList.add("mapped-file-bubble"); | 1336 status.classList.add("mapped-file-bubble"); |
1309 status.textContent = "\u25C9"; | 1337 status.textContent = "\u25C9"; |
1310 if (this._uiSourceCode === binding.network) | 1338 if (this._uiSourceCode === binding.network) |
1311 status.title = WebInspector.UIString("Persisted to file system:
%s", binding.fileSystem.url().trimMiddle(150)); | 1339 status.title = WebInspector.UIString("Persisted to file system:
%s", binding.fileSystem.url().trimMiddle(150)); |
1312 else if (binding.network.contentType().isFromSourceMap()) | 1340 else if (binding.network.contentType().isFromSourceMap()) |
1313 status.title = WebInspector.UIString("Linked to source map: %s",
binding.network.url().trimMiddle(150)); | 1341 status.title = WebInspector.UIString("Linked to source map: %s",
binding.network.url().trimMiddle(150)); |
1314 else | 1342 else |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 this._treeElement = this._createTreeElement(this._title, this); | 1475 this._treeElement = this._createTreeElement(this._title, this); |
1448 this.updateTitle(); | 1476 this.updateTitle(); |
1449 return this._treeElement; | 1477 return this._treeElement; |
1450 }, | 1478 }, |
1451 | 1479 |
1452 updateTitle: function() | 1480 updateTitle: function() |
1453 { | 1481 { |
1454 if (!this._treeElement || this._project.type() !== WebInspector.projectT
ypes.FileSystem) | 1482 if (!this._treeElement || this._project.type() !== WebInspector.projectT
ypes.FileSystem) |
1455 return; | 1483 return; |
1456 var absoluteFileSystemPath = WebInspector.FileSystemWorkspaceBinding.fil
eSystemPath(this._project.id()) + "/" + this._folderPath; | 1484 var absoluteFileSystemPath = WebInspector.FileSystemWorkspaceBinding.fil
eSystemPath(this._project.id()) + "/" + this._folderPath; |
1457 this._treeElement.listItemElement.classList.toggle("has-mapped-files", W
ebInspector.persistence.filePathHasBindings(absoluteFileSystemPath)); | 1485 var hasMappedFiles = Runtime.experiments.isEnabled("persistence2") ? Web
Inspector.persistence.filePathHasBindings(absoluteFileSystemPath) : true; |
| 1486 this._treeElement.listItemElement.classList.toggle("has-mapped-files", h
asMappedFiles); |
1458 }, | 1487 }, |
1459 | 1488 |
1460 /** | 1489 /** |
1461 * @return {!TreeElement} | 1490 * @return {!TreeElement} |
1462 */ | 1491 */ |
1463 _createTreeElement: function(title, node) | 1492 _createTreeElement: function(title, node) |
1464 { | 1493 { |
1465 if (this._project.type() !== WebInspector.projectTypes.FileSystem) { | 1494 if (this._project.type() !== WebInspector.projectTypes.FileSystem) { |
1466 try { | 1495 try { |
1467 title = decodeURI(title); | 1496 title = decodeURI(title); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 */ | 1653 */ |
1625 onattach: function() | 1654 onattach: function() |
1626 { | 1655 { |
1627 this.updateTitle(); | 1656 this.updateTitle(); |
1628 }, | 1657 }, |
1629 | 1658 |
1630 updateTitle: function() | 1659 updateTitle: function() |
1631 { | 1660 { |
1632 if (!this._treeElement || this._project.type() !== WebInspector.projectT
ypes.FileSystem) | 1661 if (!this._treeElement || this._project.type() !== WebInspector.projectT
ypes.FileSystem) |
1633 return; | 1662 return; |
| 1663 if (!Runtime.experiments.isEnabled("persistence2")) { |
| 1664 this._treeElement.listItemElement.classList.add("has-mapped-files"); |
| 1665 return; |
| 1666 } |
1634 var fileSystemPath = WebInspector.FileSystemWorkspaceBinding.fileSystemP
ath(this._project.id()); | 1667 var fileSystemPath = WebInspector.FileSystemWorkspaceBinding.fileSystemP
ath(this._project.id()); |
1635 var wasActive = this._treeElement.listItemElement.classList.contains("ha
s-mapped-files"); | 1668 var wasActive = this._treeElement.listItemElement.classList.contains("ha
s-mapped-files"); |
1636 var isActive = WebInspector.persistence.filePathHasBindings(fileSystemPa
th); | 1669 var isActive = WebInspector.persistence.filePathHasBindings(fileSystemPa
th); |
1637 if (wasActive === isActive) | 1670 if (wasActive === isActive) |
1638 return; | 1671 return; |
1639 this._treeElement.listItemElement.classList.toggle("has-mapped-files", i
sActive); | 1672 this._treeElement.listItemElement.classList.toggle("has-mapped-files", i
sActive); |
1640 if (isActive) | 1673 if (isActive) |
1641 this._treeElement.expand(); | 1674 this._treeElement.expand(); |
1642 else | 1675 else |
1643 this._treeElement.collapse(); | 1676 this._treeElement.collapse(); |
1644 }, | 1677 }, |
1645 | 1678 |
1646 /** | 1679 /** |
1647 * @param {string} title | 1680 * @param {string} title |
1648 * @override | 1681 * @override |
1649 */ | 1682 */ |
1650 setTitle: function(title) | 1683 setTitle: function(title) |
1651 { | 1684 { |
1652 this._title = title; | 1685 this._title = title; |
1653 if (this._treeElement) | 1686 if (this._treeElement) |
1654 this._treeElement.title = this._title; | 1687 this._treeElement.title = this._title; |
1655 }, | 1688 }, |
1656 | 1689 |
1657 __proto__: WebInspector.NavigatorTreeNode.prototype | 1690 __proto__: WebInspector.NavigatorTreeNode.prototype |
1658 } | 1691 } |
OLD | NEW |