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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js

Issue 2327983002: [DevTools] Migrate StylesSidebarPane to TreeOutlineInShadow. (Closed)
Patch Set: filtering, tests Created 4 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 this._style = style; 616 this._style = style;
617 this._matchedStyles = matchedStyles; 617 this._matchedStyles = matchedStyles;
618 this.editable = !!(style.styleSheetId && style.range); 618 this.editable = !!(style.styleSheetId && style.range);
619 619
620 var rule = style.parentRule; 620 var rule = style.parentRule;
621 this.element = createElementWithClass("div", "styles-section matched-styles monospace"); 621 this.element = createElementWithClass("div", "styles-section matched-styles monospace");
622 this.element._section = this; 622 this.element._section = this;
623 623
624 this._titleElement = this.element.createChild("div", "styles-section-title " + (rule ? "styles-selector" : "")); 624 this._titleElement = this.element.createChild("div", "styles-section-title " + (rule ? "styles-selector" : ""));
625 625
626 this.propertiesTreeOutline = new TreeOutline(); 626 this.propertiesTreeOutline = new TreeOutlineInShadow();
627 this.propertiesTreeOutline.element.classList.add("style-properties", "monosp ace"); 627 this.propertiesTreeOutline.registerRequiredCSS("elements/stylesSectionTree.c ss");
628 this.propertiesTreeOutline.element.classList.add("style-properties", "matche d-styles", "monospace");
628 this.propertiesTreeOutline.section = this; 629 this.propertiesTreeOutline.section = this;
629 this.element.appendChild(this.propertiesTreeOutline.element); 630 this.element.appendChild(this.propertiesTreeOutline.element);
630 631
631 var selectorContainer = createElement("div"); 632 var selectorContainer = createElement("div");
632 this._selectorElement = createElementWithClass("span", "selector"); 633 this._selectorElement = createElementWithClass("span", "selector");
633 this._selectorElement.textContent = this._headerText(); 634 this._selectorElement.textContent = this._headerText();
634 selectorContainer.appendChild(this._selectorElement); 635 selectorContainer.appendChild(this._selectorElement);
635 this._selectorElement.addEventListener("mouseenter", this._onMouseEnterSelec tor.bind(this), false); 636 this._selectorElement.addEventListener("mouseenter", this._onMouseEnterSelec tor.bind(this), false);
636 this._selectorElement.addEventListener("mouseleave", this._onMouseOutSelecto r.bind(this), false); 637 this._selectorElement.addEventListener("mouseleave", this._onMouseOutSelecto r.bind(this), false);
637 638
(...skipping 28 matching lines...) Expand all
666 this._mediaListElement = this._titleElement.createChild("div", "media-list m edia-matches"); 667 this._mediaListElement = this._titleElement.createChild("div", "media-list m edia-matches");
667 this._selectorRefElement = this._titleElement.createChild("div", "styles-sec tion-subtitle"); 668 this._selectorRefElement = this._titleElement.createChild("div", "styles-sec tion-subtitle");
668 this._updateMediaList(); 669 this._updateMediaList();
669 this._updateRuleOrigin(); 670 this._updateRuleOrigin();
670 this._titleElement.appendChild(selectorContainer); 671 this._titleElement.appendChild(selectorContainer);
671 this._selectorContainer = selectorContainer; 672 this._selectorContainer = selectorContainer;
672 673
673 if (this.navigable) 674 if (this.navigable)
674 this.element.classList.add("navigable"); 675 this.element.classList.add("navigable");
675 676
676 if (!this.editable) 677 if (!this.editable) {
677 this.element.classList.add("read-only"); 678 this.element.classList.add("read-only");
679 this.propertiesTreeOutline.element.classList.add("read-only");
680 }
678 681
679 this._markSelectorMatches(); 682 this._markSelectorMatches();
680 this.onpopulate(); 683 this.onpopulate();
681 } 684 }
682 685
683 WebInspector.StylePropertiesSection.prototype = { 686 WebInspector.StylePropertiesSection.prototype = {
684 /** 687 /**
685 * @param {boolean} isHovered 688 * @param {boolean} isHovered
686 */ 689 */
687 _setSectionHovered: function(isHovered) 690 _setSectionHovered: function(isHovered)
688 { 691 {
689 this.element.classList.toggle("styles-panel-hovered", isHovered); 692 this.element.classList.toggle("styles-panel-hovered", isHovered);
693 this.propertiesTreeOutline.element.classList.toggle("styles-panel-hovere d", isHovered);
690 if (this._hoverableSelectorsMode !== isHovered) { 694 if (this._hoverableSelectorsMode !== isHovered) {
691 this._hoverableSelectorsMode = isHovered; 695 this._hoverableSelectorsMode = isHovered;
692 this._markSelectorMatches(); 696 this._markSelectorMatches();
693 } 697 }
694 }, 698 },
695 699
696 /** 700 /**
697 * @param {!Event} event 701 * @param {!Event} event
698 */ 702 */
699 _onMouseMove: function(event) 703 _onMouseMove: function(event)
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 /** 1106 /**
1103 * @return {boolean} 1107 * @return {boolean}
1104 */ 1108 */
1105 _updateFilter: function() 1109 _updateFilter: function()
1106 { 1110 {
1107 var hasMatchingChild = false; 1111 var hasMatchingChild = false;
1108 for (var child of this.propertiesTreeOutline.rootElement().children()) 1112 for (var child of this.propertiesTreeOutline.rootElement().children())
1109 hasMatchingChild |= child._updateFilter(); 1113 hasMatchingChild |= child._updateFilter();
1110 1114
1111 var regex = this._parentPane.filterRegex(); 1115 var regex = this._parentPane.filterRegex();
1112 var hideRule = !hasMatchingChild && !!regex && !regex.test(this.element. textContent); 1116 var hideRule = !hasMatchingChild && !!regex && !regex.test(this.element. deepTextContent());
1113 this.element.classList.toggle("hidden", hideRule); 1117 this.element.classList.toggle("hidden", hideRule);
1114 if (!hideRule && this._style.parentRule) 1118 if (!hideRule && this._style.parentRule)
1115 this._markSelectorHighlights(); 1119 this._markSelectorHighlights();
1116 return !hideRule; 1120 return !hideRule;
1117 }, 1121 },
1118 1122
1119 _markSelectorMatches: function() 1123 _markSelectorMatches: function()
1120 { 1124 {
1121 var rule = this._style.parentRule; 1125 var rule = this._style.parentRule;
1122 if (!rule) 1126 if (!rule)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 }, 1250 },
1247 1251
1248 /** 1252 /**
1249 * @param {!Event} event 1253 * @param {!Event} event
1250 */ 1254 */
1251 _handleEmptySpaceClick: function(event) 1255 _handleEmptySpaceClick: function(event)
1252 { 1256 {
1253 if (!this.editable) 1257 if (!this.editable)
1254 return; 1258 return;
1255 1259
1260 var targetElement = event.deepElementFromPoint();
1261 if (targetElement && !targetElement.isComponentSelectionCollapsed())
1262 return;
1263
1256 if (!event.target.isComponentSelectionCollapsed()) 1264 if (!event.target.isComponentSelectionCollapsed())
1257 return; 1265 return;
1258 1266
1259 if (this._checkWillCancelEditing()) 1267 if (this._checkWillCancelEditing())
1260 return; 1268 return;
1261 1269
1262 if (event.target.enclosingNodeOrSelfWithNodeName("a")) 1270 if (event.target.enclosingNodeOrSelfWithNodeName("a"))
1263 return; 1271 return;
1264 1272
1265 if (event.target.classList.contains("header") || this.element.classList. contains("read-only") || event.target.enclosingNodeOrSelfWithClass("media")) { 1273 if (event.target.classList.contains("header") || this.element.classList. contains("read-only") || event.target.enclosingNodeOrSelfWithClass("media")) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 .then(updateSourceRanges.bind(this, rule)); 1536 .then(updateSourceRanges.bind(this, rule));
1529 } 1537 }
1530 1538
1531 /** 1539 /**
1532 * @param {!WebInspector.CSSStyleRule} rule 1540 * @param {!WebInspector.CSSStyleRule} rule
1533 * @this {WebInspector.StylePropertiesSection} 1541 * @this {WebInspector.StylePropertiesSection}
1534 */ 1542 */
1535 function updateSourceRanges(rule) 1543 function updateSourceRanges(rule)
1536 { 1544 {
1537 var doesAffectSelectedNode = this._matchedStyles.matchingSelectors(r ule).length > 0; 1545 var doesAffectSelectedNode = this._matchedStyles.matchingSelectors(r ule).length > 0;
1538 this.element.classList.toggle("no-affect", !doesAffectSelectedNode); 1546 this.propertiesTreeOutline.element.classList.toggle("no-affect", !do esAffectSelectedNode);
1539 this._matchedStyles.resetActiveProperties(); 1547 this._matchedStyles.resetActiveProperties();
1540 this._parentPane._refreshUpdate(this); 1548 this._parentPane._refreshUpdate(this);
1541 } 1549 }
1542 1550
1543 console.assert(rule instanceof WebInspector.CSSStyleRule); 1551 console.assert(rule instanceof WebInspector.CSSStyleRule);
1544 var oldSelectorRange = rule.selectorRange(); 1552 var oldSelectorRange = rule.selectorRange();
1545 if (!oldSelectorRange) 1553 if (!oldSelectorRange)
1546 return Promise.resolve(); 1554 return Promise.resolve();
1547 var selectedNode = this._parentPane.node(); 1555 var selectedNode = this._parentPane.node();
1548 return rule.setSelectorText(newContent) 1556 return rule.setSelectorText(newContent)
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 /** 1722 /**
1715 * @param {!WebInspector.CSSStyleRule} newRule 1723 * @param {!WebInspector.CSSStyleRule} newRule
1716 * @this {WebInspector.StylePropertiesSection} 1724 * @this {WebInspector.StylePropertiesSection}
1717 */ 1725 */
1718 function onAddedToCascade(newRule) 1726 function onAddedToCascade(newRule)
1719 { 1727 {
1720 var doesSelectorAffectSelectedNode = this._matchedStyles.matchingSel ectors(newRule).length > 0; 1728 var doesSelectorAffectSelectedNode = this._matchedStyles.matchingSel ectors(newRule).length > 0;
1721 this._makeNormal(newRule); 1729 this._makeNormal(newRule);
1722 1730
1723 if (!doesSelectorAffectSelectedNode) 1731 if (!doesSelectorAffectSelectedNode)
1724 this.element.classList.add("no-affect"); 1732 this.propertiesTreeOutline.element.classList.add("no-affect");
1725 1733
1726 this._updateRuleOrigin(); 1734 this._updateRuleOrigin();
1727 if (this.element.parentElement) // Might have been detached already. 1735 if (this.element.parentElement) // Might have been detached already.
1728 this._moveEditorFromSelector(moveDirection); 1736 this._moveEditorFromSelector(moveDirection);
1729 1737
1730 delete this._parentPane._userOperation; 1738 delete this._parentPane._userOperation;
1731 this._editingSelectorEnded(); 1739 this._editingSelectorEnded();
1732 this._markSelectorMatches(); 1740 this._markSelectorMatches();
1733 1741
1734 this._editingSelectorCommittedForTest(); 1742 this._editingSelectorCommittedForTest();
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after
3178 3186
3179 /** 3187 /**
3180 * @override 3188 * @override
3181 * @return {!WebInspector.ToolbarItem} 3189 * @return {!WebInspector.ToolbarItem}
3182 */ 3190 */
3183 item: function() 3191 item: function()
3184 { 3192 {
3185 return this._button; 3193 return this._button;
3186 } 3194 }
3187 } 3195 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/BUILD.gn ('k') | third_party/WebKit/Source/devtools/front_end/elements/elementsPanel.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698