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

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

Issue 898673004: DevTools: [SSP] fix matched selector highlight for style rules (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 this.element = createElementWithClass("div", "styles-section matched-styles monospace" + extraClasses); 1438 this.element = createElementWithClass("div", "styles-section matched-styles monospace" + extraClasses);
1439 this.element._section = this; 1439 this.element._section = this;
1440 1440
1441 this.titleElement = this.element.createChild("div", "styles-section-title " + (rule ? "styles-selector" : "")); 1441 this.titleElement = this.element.createChild("div", "styles-section-title " + (rule ? "styles-selector" : ""));
1442 this.propertiesElement = this.element.createChild("ol", "style-properties mo nospace"); 1442 this.propertiesElement = this.element.createChild("ol", "style-properties mo nospace");
1443 this.propertiesTreeOutline = new TreeOutline(this.propertiesElement, true); 1443 this.propertiesTreeOutline = new TreeOutline(this.propertiesElement, true);
1444 this.propertiesTreeOutline.setFocusable(false); 1444 this.propertiesTreeOutline.setFocusable(false);
1445 this.propertiesTreeOutline.section = this; 1445 this.propertiesTreeOutline.section = this;
1446 1446
1447 var selectorContainer = createElement("div"); 1447 var selectorContainer = createElement("div");
1448 this._selectorElement = createElement("span"); 1448 this._selectorElement = createElementWithClass("span", "selector");
1449 this._selectorElement.textContent = styleRule.selectorText(); 1449 this._selectorElement.textContent = styleRule.selectorText();
1450 selectorContainer.appendChild(this._selectorElement); 1450 selectorContainer.appendChild(this._selectorElement);
1451 1451
1452 var openBrace = createElement("span"); 1452 var openBrace = createElement("span");
1453 openBrace.textContent = " {"; 1453 openBrace.textContent = " {";
1454 selectorContainer.appendChild(openBrace); 1454 selectorContainer.appendChild(openBrace);
1455 selectorContainer.addEventListener("mousedown", this._handleEmptySpaceMouseD own.bind(this), false); 1455 selectorContainer.addEventListener("mousedown", this._handleEmptySpaceMouseD own.bind(this), false);
1456 selectorContainer.addEventListener("click", this._handleSelectorContainerCli ck.bind(this), false); 1456 selectorContainer.addEventListener("click", this._handleSelectorContainerCli ck.bind(this), false);
1457 1457
1458 var closeBrace = createElement("div"); 1458 var closeBrace = createElement("div");
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 }, 1832 },
1833 1833
1834 _markSelectorMatches: function() 1834 _markSelectorMatches: function()
1835 { 1835 {
1836 var rule = this.styleRule.rule(); 1836 var rule = this.styleRule.rule();
1837 if (!rule) 1837 if (!rule)
1838 return; 1838 return;
1839 1839
1840 this._mediaListElement.classList.toggle("media-matches", this.styleRule. mediaMatches()); 1840 this._mediaListElement.classList.toggle("media-matches", this.styleRule. mediaMatches());
1841 1841
1842 // .selector is rendered as non-affecting selector by default. 1842 if (!this.styleRule.hasMatchingSelectors())
1843 if (!this.styleRule.hasMatchingSelectors()) {
1844 this._selectorElement.className = "selector";
1845 return; 1843 return;
1846 }
1847 1844
1848 var selectors = rule.selectors; 1845 var selectors = rule.selectors;
1849 var fragment = createDocumentFragment(); 1846 var fragment = createDocumentFragment();
1850 var currentMatch = 0; 1847 var currentMatch = 0;
1851 var matchingSelectors = rule.matchingSelectors; 1848 var matchingSelectors = rule.matchingSelectors;
1852 for (var i = 0; i < selectors.length ; ++i) { 1849 for (var i = 0; i < selectors.length ; ++i) {
1853 if (i) 1850 if (i)
1854 fragment.createTextChild(", "); 1851 fragment.createTextChild(", ");
1855 var isSelectorMatching = matchingSelectors[currentMatch] === i; 1852 var isSelectorMatching = matchingSelectors[currentMatch] === i;
1856 if (isSelectorMatching) 1853 if (isSelectorMatching)
(...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after
4046 4043
4047 WebInspector.StylesSidebarPane.MatchedRulesPayload.prototype = { 4044 WebInspector.StylesSidebarPane.MatchedRulesPayload.prototype = {
4048 /** 4045 /**
4049 * @return {boolean} 4046 * @return {boolean}
4050 */ 4047 */
4051 fulfilled: function() 4048 fulfilled: function()
4052 { 4049 {
4053 return !!(this.matchedCSSRules && this.pseudoElements && this.inherited) ; 4050 return !!(this.matchedCSSRules && this.pseudoElements && this.inherited) ;
4054 } 4051 }
4055 } 4052 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698