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

Unified Diff: third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js

Issue 2142653003: DevTools: move functionality away from ElementsPanel for better DOM tree control reuse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/elements/ElementsTreeOutline.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js b/third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js
index 5b489f664e9b4e3cefecf821a4b707bce15a7a5d..a89c4c1d98ae09dafc34e4394fc5452a67373bba 100644
--- a/third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js
+++ b/third_party/WebKit/Source/devtools/front_end/elements/ElementsPanel.js
@@ -89,8 +89,6 @@ WebInspector.ElementsPanel = function()
/** @type {!Array.<!WebInspector.ElementsTreeOutline>} */
this._treeOutlines = [];
- /** @type {!Map.<!WebInspector.DOMModel, !WebInspector.ElementsTreeOutline>} */
- this._modelToTreeOutline = new Map();
WebInspector.targetManager.observeTargets(this);
WebInspector.moduleSetting("showUAShadowDOM").addChangeListener(this._showUAShadowDOMChanged.bind(this));
WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspector.DOMModel.Events.DocumentUpdated, this._documentUpdatedEvent, this);
@@ -123,7 +121,6 @@ WebInspector.ElementsPanel.prototype = {
var filterInput = WebInspector.StylesSidebarPane.createPropertyFilterElement(WebInspector.UIString("Filter"), hbox, ssp.onFilterChanged.bind(ssp));
filterContainerElement.appendChild(filterInput);
var toolbar = new WebInspector.ExtensibleToolbar("styles-sidebarpane-toolbar", hbox);
- toolbar.onLoad().then(() => toolbar.appendToolbarItem(WebInspector.StylesSidebarPane.createAddNewRuleButton(ssp)));
toolbar.element.classList.add("styles-pane-toolbar");
toolbar.makeToggledGray();
var toolbarPaneContainer = container.createChild("div", "styles-sidebar-toolbar-pane-container");
@@ -203,24 +200,6 @@ WebInspector.ElementsPanel.prototype = {
}
},
- _toggleHideElement: function()
- {
- var node = this.selectedDOMNode();
- var treeOutline = this._treeOutlineForNode(node);
- if (!node || !treeOutline)
- return;
- treeOutline.toggleHideElement(node);
- },
-
- _toggleEditAsHTML: function()
- {
- var node = this.selectedDOMNode();
- var treeOutline = this._treeOutlineForNode(node);
- if (!node || !treeOutline)
- return;
- treeOutline.toggleEditAsHTML(node);
- },
-
_loadSidebarViews: function()
{
var extensions = self.runtime.extensions("@WebInspector.Widget");
@@ -266,7 +245,6 @@ WebInspector.ElementsPanel.prototype = {
treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.ElementsTreeUpdated, this._updateBreadcrumbIfNeeded, this);
new WebInspector.ElementsTreeElementHighlighter(treeOutline);
this._treeOutlines.push(treeOutline);
- this._modelToTreeOutline.set(domModel, treeOutline);
// Perform attach if necessary.
if (this.isShowing())
@@ -283,7 +261,7 @@ WebInspector.ElementsPanel.prototype = {
var domModel = WebInspector.DOMModel.fromTarget(target);
if (!domModel)
return;
- var treeOutline = this._modelToTreeOutline.remove(domModel);
+ var treeOutline = WebInspector.ElementsTreeOutline.forDOMModel(domModel);
treeOutline.unwireFromDOMModel();
this._treeOutlines.remove(treeOutline);
treeOutline.element.remove();
@@ -431,7 +409,7 @@ WebInspector.ElementsPanel.prototype = {
this._reset();
this.searchCanceled();
- var treeOutline = this._modelToTreeOutline.get(domModel);
+ var treeOutline = WebInspector.ElementsTreeOutline.forDOMModel(domModel);
treeOutline.rootDOMNode = inspectedRootDocument;
if (!inspectedRootDocument) {
@@ -704,7 +682,7 @@ WebInspector.ElementsPanel.prototype = {
var searchResult = this._searchResults[this._currentSearchResultIndex];
if (!searchResult.node)
return;
- var treeOutline = this._modelToTreeOutline.get(searchResult.node.domModel());
+ var treeOutline = WebInspector.ElementsTreeOutline.forDOMModel(searchResult.node.domModel());
var treeElement = treeOutline.findTreeElement(searchResult.node);
if (treeElement)
treeElement.hideSearchHighlights();
@@ -815,7 +793,7 @@ WebInspector.ElementsPanel.prototype = {
{
if (!node)
return null;
- return this._modelToTreeOutline.get(node.domModel()) || null;
+ return WebInspector.ElementsTreeOutline.forDOMModel(node.domModel());
},
/**
@@ -906,33 +884,6 @@ WebInspector.ElementsPanel.prototype = {
this._notFirstInspectElement = true;
},
- /**
- * @param {!Event} event
- * @param {!WebInspector.ContextMenu} contextMenu
- * @param {!Object} object
- */
- appendApplicableItems: function(event, contextMenu, object)
- {
- if (!(object instanceof WebInspector.RemoteObject && (/** @type {!WebInspector.RemoteObject} */ (object)).isNode())
- && !(object instanceof WebInspector.DOMNode)
- && !(object instanceof WebInspector.DeferredDOMNode)) {
- return;
- }
-
- // Add debbuging-related actions
- if (object instanceof WebInspector.DOMNode) {
- contextMenu.appendSeparator();
- WebInspector.domBreakpointsSidebarPane.populateNodeContextMenu(object, contextMenu, true);
- }
-
- // Skip adding "Reveal..." menu item for our own tree outline.
- if (this.element.isAncestor(/** @type {!Node} */ (event.target)))
- return;
- var commandCallback = WebInspector.Revealer.reveal.bind(WebInspector.Revealer, object);
-
- contextMenu.appendItem(WebInspector.UIString.capitalize("Reveal in Elements ^panel"), commandCallback);
- },
-
_sidebarContextMenuEventFired: function(event)
{
var contextMenu = new WebInspector.ContextMenu(event);
@@ -1104,11 +1055,27 @@ WebInspector.ElementsPanel.ContextMenuProvider.prototype = {
* @override
* @param {!Event} event
* @param {!WebInspector.ContextMenu} contextMenu
- * @param {!Object} target
+ * @param {!Object} object
*/
- appendApplicableItems: function(event, contextMenu, target)
+ appendApplicableItems: function(event, contextMenu, object)
{
- WebInspector.ElementsPanel.instance().appendApplicableItems(event, contextMenu, target);
+ if (!(object instanceof WebInspector.RemoteObject && (/** @type {!WebInspector.RemoteObject} */ (object)).isNode())
+ && !(object instanceof WebInspector.DOMNode)
+ && !(object instanceof WebInspector.DeferredDOMNode)) {
+ return;
+ }
+
+ // Add debbuging-related actions
+ if (object instanceof WebInspector.DOMNode) {
+ contextMenu.appendSeparator();
+ WebInspector.domBreakpointsSidebarPane.populateNodeContextMenu(object, contextMenu, true);
+ }
+
+ // Skip adding "Reveal..." menu item for our own tree outline.
+ if (WebInspector.ElementsPanel.instance().element.isAncestor(/** @type {!Node} */ (event.target)))
+ return;
+ var commandCallback = WebInspector.Revealer.reveal.bind(WebInspector.Revealer, object);
+ contextMenu.appendItem(WebInspector.UIString.capitalize("Reveal in Elements ^panel"), commandCallback);
}
}
@@ -1221,12 +1188,19 @@ WebInspector.ElementsActionDelegate.prototype = {
*/
handleAction: function(context, actionId)
{
+ var node = WebInspector.context.flavor(WebInspector.DOMNode);
+ if (!node)
+ return true;
+ var treeOutline = WebInspector.ElementsTreeOutline.forDOMModel(node.domModel());
+ if (!treeOutline)
+ return true;
+
switch (actionId) {
case "elements.hide-element":
- WebInspector.ElementsPanel.instance()._toggleHideElement();
+ treeOutline.toggleHideElement(node);
return true;
case "elements.edit-as-html":
- WebInspector.ElementsPanel.instance()._toggleEditAsHTML();
+ treeOutline.toggleEditAsHTML(node);
return true;
}
return false;
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/elements/ElementsTreeOutline.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698