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

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

Issue 22548006: DevTools: Improve performance of the element breadcrumbs. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: revisited Created 7 years, 4 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
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 this.contentElement.classList.add("nowrap"); 64 this.contentElement.classList.add("nowrap");
65 WebInspector.settings.domWordWrap.addChangeListener(this._domWordWrapSetting Changed.bind(this)); 65 WebInspector.settings.domWordWrap.addChangeListener(this._domWordWrapSetting Changed.bind(this));
66 66
67 this.contentElement.addEventListener("contextmenu", this._contextMenuEventFi red.bind(this), true); 67 this.contentElement.addEventListener("contextmenu", this._contextMenuEventFi red.bind(this), true);
68 this.splitView.sidebarElement.addEventListener("contextmenu", this._sidebarC ontextMenuEventFired.bind(this), false); 68 this.splitView.sidebarElement.addEventListener("contextmenu", this._sidebarC ontextMenuEventFired.bind(this), false);
69 69
70 this.treeOutline = new WebInspector.ElementsTreeOutline(true, true, false, t his._populateContextMenu.bind(this), this._setPseudoClassForNodeId.bind(this)); 70 this.treeOutline = new WebInspector.ElementsTreeOutline(true, true, false, t his._populateContextMenu.bind(this), this._setPseudoClassForNodeId.bind(this));
71 this.treeOutline.wireToDomAgent(); 71 this.treeOutline.wireToDomAgent();
72 72
73 this.treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Se lectedNodeChanged, this._selectedNodeChanged, this); 73 this.treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Se lectedNodeChanged, this._selectedNodeChanged, this);
74 this.treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.DO MNodesUpdated, this._updateBreadcrumbIfNeeded, this);
74 75
75 this.crumbsElement = document.createElement("div"); 76 this.crumbsElement = document.createElement("div");
76 this.crumbsElement.className = "crumbs"; 77 this.crumbsElement.className = "crumbs";
77 this.crumbsElement.addEventListener("mousemove", this._mouseMovedInCrumbs.bi nd(this), false); 78 this.crumbsElement.addEventListener("mousemove", this._mouseMovedInCrumbs.bi nd(this), false);
78 this.crumbsElement.addEventListener("mouseout", this._mouseMovedOutOfCrumbs. bind(this), false); 79 this.crumbsElement.addEventListener("mouseout", this._mouseMovedOutOfCrumbs. bind(this), false);
79 80
80 this.sidebarPanes = {}; 81 this.sidebarPanes = {};
81 this.sidebarPanes.computedStyle = new WebInspector.ComputedStyleSidebarPane( ); 82 this.sidebarPanes.computedStyle = new WebInspector.ComputedStyleSidebarPane( );
82 this.sidebarPanes.styles = new WebInspector.StylesSidebarPane(this.sidebarPa nes.computedStyle, this._setPseudoClassForNodeId.bind(this)); 83 this.sidebarPanes.styles = new WebInspector.StylesSidebarPane(this.sidebarPa nes.computedStyle, this._setPseudoClassForNodeId.bind(this));
83 this.sidebarPanes.metrics = new WebInspector.MetricsSidebarPane(); 84 this.sidebarPanes.metrics = new WebInspector.MetricsSidebarPane();
(...skipping 10 matching lines...) Expand all
94 this.sidebarPanes.styles.addEventListener("style property toggled", this._st ylesPaneEdited, this); 95 this.sidebarPanes.styles.addEventListener("style property toggled", this._st ylesPaneEdited, this);
95 this.sidebarPanes.metrics.addEventListener("metrics edited", this._metricsPa neEdited, this); 96 this.sidebarPanes.metrics.addEventListener("metrics edited", this._metricsPa neEdited, this);
96 97
97 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve nts.DockSideChanged, this._dockSideChanged.bind(this)); 98 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve nts.DockSideChanged, this._dockSideChanged.bind(this));
98 WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(thi s._dockSideChanged.bind(this)); 99 WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(thi s._dockSideChanged.bind(this));
99 this._dockSideChanged(); 100 this._dockSideChanged();
100 101
101 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get PopoverAnchor.bind(this), this._showPopover.bind(this)); 102 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get PopoverAnchor.bind(this), this._showPopover.bind(this));
102 this._popoverHelper.setTimeout(0); 103 this._popoverHelper.setTimeout(0);
103 104
104 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrModi fied, this._updateBreadcrumbIfNeeded, this);
105 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrRemo ved, this._updateBreadcrumbIfNeeded, this);
106 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.NodeRemo ved, this._nodeRemoved, this);
107 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.Document Updated, this._documentUpdatedEvent, this); 105 WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.Document Updated, this._documentUpdatedEvent, this);
108 WebInspector.settings.showShadowDOM.addChangeListener(this._showShadowDOMCha nged.bind(this)); 106 WebInspector.settings.showShadowDOM.addChangeListener(this._showShadowDOMCha nged.bind(this));
109 107
110 if (WebInspector.domAgent.existingDocument()) 108 if (WebInspector.domAgent.existingDocument())
111 this._documentUpdated(WebInspector.domAgent.existingDocument()); 109 this._documentUpdated(WebInspector.domAgent.existingDocument());
112 } 110 }
113 111
114 WebInspector.ElementsPanel.prototype = { 112 WebInspector.ElementsPanel.prototype = {
115 _updateTreeOutlineVisibleWidth: function() 113 _updateTreeOutlineVisibleWidth: function()
116 { 114 {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 if (!this._searchResults) 540 if (!this._searchResults)
543 return; 541 return;
544 var searchResult = this._searchResults[this._currentSearchResultIndex]; 542 var searchResult = this._searchResults[this._currentSearchResultIndex];
545 if (!searchResult) 543 if (!searchResult)
546 return; 544 return;
547 var treeElement = this.treeOutline.findTreeElement(searchResult); 545 var treeElement = this.treeOutline.findTreeElement(searchResult);
548 if (treeElement) 546 if (treeElement)
549 treeElement.hideSearchHighlights(); 547 treeElement.hideSearchHighlights();
550 }, 548 },
551 549
550 /**
551 * @return {WebInspector.DOMNode}
552 */
552 selectedDOMNode: function() 553 selectedDOMNode: function()
553 { 554 {
554 return this.treeOutline.selectedDOMNode(); 555 return this.treeOutline.selectedDOMNode();
555 }, 556 },
556 557
557 /** 558 /**
558 * @param {boolean=} focus 559 * @param {boolean=} focus
559 */ 560 */
560 selectDOMNode: function(node, focus) 561 selectDOMNode: function(node, focus)
561 { 562 {
562 this.treeOutline.selectDOMNode(node, focus); 563 this.treeOutline.selectDOMNode(node, focus);
563 }, 564 },
564 565
565 _nodeRemoved: function(event) 566 /**
567 * @param {WebInspector.Event} event
568 */
569 _updateBreadcrumbIfNeeded: function(event)
566 { 570 {
567 if (!this.isShowing()) 571 var nodes = /** @type {!Array.<!WebInspector.DOMNode>} */ (event.data || []);
572 if (!nodes.length)
568 return; 573 return;
569 574
570 var crumbs = this.crumbsElement; 575 var crumbs = this.crumbsElement;
571 for (var crumb = crumbs.firstChild; crumb; crumb = crumb.nextSibling) { 576 for (var crumb = crumbs.firstChild; crumb; crumb = crumb.nextSibling) {
572 if (crumb.representedObject === event.data.node) { 577 if (nodes.indexOf(crumb.representedObject) !== -1) {
573 this.updateBreadcrumb(true); 578 this.updateBreadcrumb(true);
574 return; 579 return;
575 } 580 }
576 } 581 }
577 }, 582 },
578 583
579 _stylesPaneEdited: function() 584 _stylesPaneEdited: function()
580 { 585 {
581 // Once styles are edited, the Metrics pane should be updated. 586 // Once styles are edited, the Metrics pane should be updated.
582 this.sidebarPanes.metrics.needsUpdate = true; 587 this.sidebarPanes.metrics.needsUpdate = true;
(...skipping 24 matching lines...) Expand all
607 { 612 {
608 var nodeUnderMouse = document.elementFromPoint(event.pageX, event.pageY) ; 613 var nodeUnderMouse = document.elementFromPoint(event.pageX, event.pageY) ;
609 if (nodeUnderMouse && nodeUnderMouse.isDescendant(this.crumbsElement)) 614 if (nodeUnderMouse && nodeUnderMouse.isDescendant(this.crumbsElement))
610 return; 615 return;
611 616
612 WebInspector.domAgent.hideDOMNodeHighlight(); 617 WebInspector.domAgent.hideDOMNodeHighlight();
613 618
614 this._mouseOutOfCrumbsTimeout = setTimeout(this.updateBreadcrumbSizes.bi nd(this), 1000); 619 this._mouseOutOfCrumbsTimeout = setTimeout(this.updateBreadcrumbSizes.bi nd(this), 1000);
615 }, 620 },
616 621
617 _updateBreadcrumbIfNeeded: function(event)
618 {
619 var name = event.data.name;
620 if (name !== "class" && name !== "id")
621 return;
622
623 var node = /** @type {WebInspector.DOMNode} */ (event.data.node);
624 var crumbs = this.crumbsElement;
625 var crumb = crumbs.firstChild;
626 while (crumb) {
627 if (crumb.representedObject === node) {
628 this.updateBreadcrumb(true);
629 break;
630 }
631 crumb = crumb.nextSibling;
632 }
633 },
634
635 /** 622 /**
636 * @param {boolean=} forceUpdate 623 * @param {boolean=} forceUpdate
637 */ 624 */
638 updateBreadcrumb: function(forceUpdate) 625 updateBreadcrumb: function(forceUpdate)
639 { 626 {
640 if (!this.isShowing()) 627 if (!this.isShowing())
641 return; 628 return;
642 629
643 var crumbs = this.crumbsElement; 630 var crumbs = this.crumbsElement;
644 631
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 681
695 for (var current = this.selectedDOMNode(); current; current = current.pa rentNode) { 682 for (var current = this.selectedDOMNode(); current; current = current.pa rentNode) {
696 if (current.nodeType() === Node.DOCUMENT_NODE) 683 if (current.nodeType() === Node.DOCUMENT_NODE)
697 continue; 684 continue;
698 685
699 crumb = document.createElement("span"); 686 crumb = document.createElement("span");
700 crumb.className = "crumb"; 687 crumb.className = "crumb";
701 crumb.representedObject = current; 688 crumb.representedObject = current;
702 crumb.addEventListener("mousedown", selectCrumbFunction, false); 689 crumb.addEventListener("mousedown", selectCrumbFunction, false);
703 690
704 var crumbTitle; 691 var crumbTitle = "";
705 switch (current.nodeType()) { 692 switch (current.nodeType()) {
706 case Node.ELEMENT_NODE: 693 case Node.ELEMENT_NODE:
707 WebInspector.DOMPresentationUtils.decorateNodeLabel(current, crumb); 694 WebInspector.DOMPresentationUtils.decorateNodeLabel(current, crumb);
708 break; 695 break;
709 696
710 case Node.TEXT_NODE: 697 case Node.TEXT_NODE:
711 crumbTitle = WebInspector.UIString("(text)"); 698 crumbTitle = WebInspector.UIString("(text)");
712 break 699 break;
713 700
714 case Node.COMMENT_NODE: 701 case Node.COMMENT_NODE:
715 crumbTitle = "<!-->"; 702 crumbTitle = "<!-->";
716 break; 703 break;
717 704
718 case Node.DOCUMENT_TYPE_NODE: 705 case Node.DOCUMENT_TYPE_NODE:
719 crumbTitle = "<!DOCTYPE>"; 706 crumbTitle = "<!DOCTYPE>";
720 break; 707 break;
721 708
722 default: 709 default:
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 * @param {WebInspector.SidebarPane} pane 1189 * @param {WebInspector.SidebarPane} pane
1203 */ 1190 */
1204 addExtensionSidebarPane: function(id, pane) 1191 addExtensionSidebarPane: function(id, pane)
1205 { 1192 {
1206 this.sidebarPanes[id] = pane; 1193 this.sidebarPanes[id] = pane;
1207 this.sidebarPaneView.addPane(pane); 1194 this.sidebarPaneView.addPane(pane);
1208 }, 1195 },
1209 1196
1210 __proto__: WebInspector.Panel.prototype 1197 __proto__: WebInspector.Panel.prototype
1211 } 1198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698