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: Source/devtools/front_end/StylesSidebarPane.js

Issue 211193004: DevTools: move search in styles out of experimental. It proved to be stable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
« no previous file with comments | « Source/devtools/front_end/Settings.js ('k') | Source/devtools/front_end/elementsPanel.css » ('j') | 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 contextMenu.appendApplicableItems(/** @type {!Node} */ (event.target)); 179 contextMenu.appendApplicableItems(/** @type {!Node} */ (event.target));
180 contextMenu.show(); 180 contextMenu.show();
181 }, 181 },
182 182
183 /** 183 /**
184 * @param {!Element} matchedStylesElement 184 * @param {!Element} matchedStylesElement
185 * @param {!Element} computedStylesElement 185 * @param {!Element} computedStylesElement
186 */ 186 */
187 setFilterBoxContainers: function(matchedStylesElement, computedStylesElement ) 187 setFilterBoxContainers: function(matchedStylesElement, computedStylesElement )
188 { 188 {
189 if (!WebInspector.experimentsSettings.cssStyleSearch.isEnabled())
190 return;
191
192 matchedStylesElement.appendChild(this._createCSSFilterControl()); 189 matchedStylesElement.appendChild(this._createCSSFilterControl());
193 this._computedStylePane.setFilterBoxContainer(computedStylesElement); 190 this._computedStylePane.setFilterBoxContainer(computedStylesElement);
194 }, 191 },
195 192
196 /** 193 /**
197 * @return {!Element} 194 * @return {!Element}
198 */ 195 */
199 _createCSSFilterControl: function() 196 _createCSSFilterControl: function()
200 { 197 {
201 var filterInput = this._createPropertyFilterElement(false, searchHandler .bind(this)); 198 var filterInput = this._createPropertyFilterElement(false, searchHandler .bind(this));
202 199
203 /** 200 /**
204 * @param {?RegExp} regex 201 * @param {?RegExp} regex
205 * @this {WebInspector.StylesSidebarPane} 202 * @this {WebInspector.StylesSidebarPane}
206 */ 203 */
207 function searchHandler(regex) 204 function searchHandler(regex)
208 { 205 {
209 this._filterRegex = regex; 206 this._filterRegex = regex;
210 } 207 }
211 208
212 filterInput.addEventListener("keydown", tabHandler.bind(this), false);
213
214 /**
215 * @param {?Event} event
216 * @this {WebInspector.StylesSidebarPane}
217 */
218 function tabHandler(event)
219 {
220 if (event.keyIdentifier !== "U+0009")
221 return;
222
223 event.consume(true);
224 var firstSection = this.sections[0][1];
225 if (!firstSection)
226 return;
227 firstSection._moveEditorFromSelector(event.shiftKey ? "backward" : " forward");
228 }
229 return filterInput; 209 return filterInput;
230 }, 210 },
231 211
232 get _forcedPseudoClasses() 212 get _forcedPseudoClasses()
233 { 213 {
234 return this.node ? (this.node.getUserProperty("pseudoState") || undefine d) : undefined; 214 return this.node ? (this.node.getUserProperty("pseudoState") || undefine d) : undefined;
235 }, 215 },
236 216
237 _updateForcedPseudoStateInputs: function() 217 _updateForcedPseudoStateInputs: function()
238 { 218 {
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 /** 865 /**
886 * @param {boolean} isComputedStyleFilter 866 * @param {boolean} isComputedStyleFilter
887 * @return {!Element} 867 * @return {!Element}
888 * @param {function(?RegExp)} filterCallback 868 * @param {function(?RegExp)} filterCallback
889 */ 869 */
890 _createPropertyFilterElement: function(isComputedStyleFilter, filterCallback ) 870 _createPropertyFilterElement: function(isComputedStyleFilter, filterCallback )
891 { 871 {
892 var input = document.createElement("input"); 872 var input = document.createElement("input");
893 input.type = "text"; 873 input.type = "text";
894 input.placeholder = isComputedStyleFilter ? WebInspector.UIString("Filte r") : WebInspector.UIString("Find in Styles"); 874 input.placeholder = isComputedStyleFilter ? WebInspector.UIString("Filte r") : WebInspector.UIString("Find in Styles");
895 input.className = "filter-box toolbar-search-control search-replace";
896 var boundSearchHandler = searchHandler.bind(this); 875 var boundSearchHandler = searchHandler.bind(this);
897 876
898 /** 877 /**
899 * @this {WebInspector.StylesSidebarPane} 878 * @this {WebInspector.StylesSidebarPane}
900 */ 879 */
901 function searchHandler() 880 function searchHandler()
902 { 881 {
903 var regex = input.value ? new RegExp(input.value.escapeForRegExp(), "i") : null; 882 var regex = input.value ? new RegExp(input.value.escapeForRegExp(), "i") : null;
904 filterCallback(regex); 883 filterCallback(regex);
884 input.parentNode.classList.toggle("styles-filter-engaged", !!input.v alue);
905 this._updateFilter(isComputedStyleFilter); 885 this._updateFilter(isComputedStyleFilter);
906 } 886 }
907 input.addEventListener("input", boundSearchHandler, false); 887 input.addEventListener("input", boundSearchHandler, false);
908 888
909 /** 889 /**
910 * @param {?Event} event 890 * @param {?Event} event
911 */ 891 */
912 function keydownHandler(event) 892 function keydownHandler(event)
913 { 893 {
914 var Esc = "U+001B"; 894 var Esc = "U+001B";
(...skipping 12 matching lines...) Expand all
927 * @param {boolean} isComputedStyleFilter 907 * @param {boolean} isComputedStyleFilter
928 */ 908 */
929 _updateFilter: function(isComputedStyleFilter) 909 _updateFilter: function(isComputedStyleFilter)
930 { 910 {
931 for (var pseudoId in this.sections) { 911 for (var pseudoId in this.sections) {
932 var sections = this.sections[pseudoId]; 912 var sections = this.sections[pseudoId];
933 for (var i = 0; i < sections.length; ++i) { 913 for (var i = 0; i < sections.length; ++i) {
934 var section = sections[i]; 914 var section = sections[i];
935 if (isComputedStyleFilter !== !!section.computedStyle) 915 if (isComputedStyleFilter !== !!section.computedStyle)
936 continue; 916 continue;
937 section.updateFilter(); 917 section._updateFilter();
938 } 918 }
939 } 919 }
940 }, 920 },
941 921
942 /** 922 /**
943 * @param {!WebInspector.Event} event 923 * @param {!WebInspector.Event} event
944 */ 924 */
945 _showUserAgentStylesSettingChanged: function(event) 925 _showUserAgentStylesSettingChanged: function(event)
946 { 926 {
947 var showStyles = /** @type {boolean} */ (event.data); 927 var showStyles = /** @type {boolean} */ (event.data);
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 if (shorthandPropertyAvailable) 1344 if (shorthandPropertyAvailable)
1365 continue; // Shorthand for the property found. 1345 continue; // Shorthand for the property found.
1366 1346
1367 var inherited = this.isPropertyInherited(property.name); 1347 var inherited = this.isPropertyInherited(property.name);
1368 var overloaded = property.inactive || this.isPropertyOverloaded(prop erty.name, isShorthand); 1348 var overloaded = property.inactive || this.isPropertyOverloaded(prop erty.name, isShorthand);
1369 var item = new WebInspector.StylePropertyTreeElement(this._parentPan e, this.styleRule, style, property, isShorthand, inherited, overloaded); 1349 var item = new WebInspector.StylePropertyTreeElement(this._parentPan e, this.styleRule, style, property, isShorthand, inherited, overloaded);
1370 this.propertiesTreeOutline.appendChild(item); 1350 this.propertiesTreeOutline.appendChild(item);
1371 } 1351 }
1372 }, 1352 },
1373 1353
1374 updateFilter: function() 1354 _updateFilter: function()
1375 { 1355 {
1356 if (this.styleRule.isAttribute)
1357 return;
1358 var regex = this._parentPane.filterRegex();
1359 var hideRule = regex && !regex.test(this.element.textContent);
1360 this.element.classList.toggle("hidden", hideRule);
1361 if (hideRule)
1362 return;
1363
1376 var children = this.propertiesTreeOutline.children; 1364 var children = this.propertiesTreeOutline.children;
1377 for (var i = 0; i < children.length; ++i) 1365 for (var i = 0; i < children.length; ++i)
1378 children[i].updateFilter(); 1366 children[i]._updateFilter();
1379 1367
1380 if (this.styleRule.rule) 1368 if (this.styleRule.rule)
1381 this._markSelectorHighlights(); 1369 this._markSelectorHighlights();
1382 }, 1370 },
1383 1371
1384 _markSelectorMatches: function() 1372 _markSelectorMatches: function()
1385 { 1373 {
1386 var rule = this.styleRule.rule; 1374 var rule = this.styleRule.rule;
1387 if (!rule) 1375 if (!rule)
1388 return; 1376 return;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 this._expandedPropertyNames = {}; 1717 this._expandedPropertyNames = {};
1730 for (var name in this._propertyTreeElements) { 1718 for (var name in this._propertyTreeElements) {
1731 if (this._propertyTreeElements[name].expanded) 1719 if (this._propertyTreeElements[name].expanded)
1732 this._expandedPropertyNames[name] = true; 1720 this._expandedPropertyNames[name] = true;
1733 } 1721 }
1734 this._propertyTreeElements = {}; 1722 this._propertyTreeElements = {};
1735 this.propertiesTreeOutline.removeChildren(); 1723 this.propertiesTreeOutline.removeChildren();
1736 this.populated = false; 1724 this.populated = false;
1737 }, 1725 },
1738 1726
1739 updateFilter: function() 1727 _updateFilter: function()
1740 { 1728 {
1741 var children = this.propertiesTreeOutline.children; 1729 var children = this.propertiesTreeOutline.children;
1742 for (var i = 0; i < children.length; ++i) 1730 for (var i = 0; i < children.length; ++i)
1743 children[i].updateFilter(); 1731 children[i]._updateFilter();
1744 }, 1732 },
1745 1733
1746 onpopulate: function() 1734 onpopulate: function()
1747 { 1735 {
1748 function sorter(a, b) 1736 function sorter(a, b)
1749 { 1737 {
1750 return a.name.compareTo(b.name); 1738 return a.name.compareTo(b.name);
1751 } 1739 }
1752 1740
1753 var style = this.styleRule.style; 1741 var style = this.styleRule.style;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 if (!this.parsedOk) { 2131 if (!this.parsedOk) {
2144 // Avoid having longhands under an invalid shorthand. 2132 // Avoid having longhands under an invalid shorthand.
2145 this.hasChildren = false; 2133 this.hasChildren = false;
2146 this.listItemElement.classList.add("not-parsed-ok"); 2134 this.listItemElement.classList.add("not-parsed-ok");
2147 2135
2148 // Add a separate exclamation mark IMG element with a tooltip. 2136 // Add a separate exclamation mark IMG element with a tooltip.
2149 this.listItemElement.insertBefore(WebInspector.StylesSidebarPane.cre ateExclamationMark(this.property), this.listItemElement.firstChild); 2137 this.listItemElement.insertBefore(WebInspector.StylesSidebarPane.cre ateExclamationMark(this.property), this.listItemElement.firstChild);
2150 } 2138 }
2151 if (this.property.inactive) 2139 if (this.property.inactive)
2152 this.listItemElement.classList.add("inactive"); 2140 this.listItemElement.classList.add("inactive");
2153 this.updateFilter(); 2141 this._updateFilter();
2154 }, 2142 },
2155 2143
2156 updateFilter: function() 2144 _updateFilter: function()
2157 { 2145 {
2158 var regEx = this.parentPane().filterRegex(); 2146 var regEx = this.parentPane().filterRegex();
2159 this.listItemElement.classList.toggle("filter-match", !!regEx && (regEx. test(this.property.name) || regEx.test(this.property.value))); 2147 this.listItemElement.classList.toggle("filter-match", !!regEx && (regEx. test(this.property.name) || regEx.test(this.property.value)));
2160 }, 2148 },
2161 2149
2162 /** 2150 /**
2163 * @param {!Element} nameElement 2151 * @param {!Element} nameElement
2164 * @param {!Element} valueElement 2152 * @param {!Element} valueElement
2165 * @param {string} text 2153 * @param {string} text
2166 */ 2154 */
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 }, 2377 },
2390 2378
2391 /** 2379 /**
2392 * @return {!WebInspector.ComputedStyleSidebarPane} 2380 * @return {!WebInspector.ComputedStyleSidebarPane}
2393 */ 2381 */
2394 parentPane: function() 2382 parentPane: function()
2395 { 2383 {
2396 return this._stylesPane._computedStylePane; 2384 return this._stylesPane._computedStylePane;
2397 }, 2385 },
2398 2386
2399 updateFilter: function() 2387 _updateFilter: function()
2400 { 2388 {
2401 var regEx = this.parentPane().filterRegex(); 2389 var regEx = this.parentPane().filterRegex();
2402 this.listItemElement.classList.toggle("hidden", !!regEx && (!regEx.test( this.property.name) && !regEx.test(this.property.value))); 2390 this.listItemElement.classList.toggle("hidden", !!regEx && (!regEx.test( this.property.name) && !regEx.test(this.property.value)));
2403 }, 2391 },
2404 2392
2405 __proto__: WebInspector.StylePropertyTreeElementBase.prototype 2393 __proto__: WebInspector.StylePropertyTreeElementBase.prototype
2406 } 2394 }
2407 2395
2408 /** 2396 /**
2409 * @constructor 2397 * @constructor
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
3251 return; 3239 return;
3252 } 3240 }
3253 3241
3254 var results = this._cssCompletions.startsWith(prefix); 3242 var results = this._cssCompletions.startsWith(prefix);
3255 var selectedIndex = this._cssCompletions.mostUsedOf(results); 3243 var selectedIndex = this._cssCompletions.mostUsedOf(results);
3256 completionsReadyCallback(results, selectedIndex); 3244 completionsReadyCallback(results, selectedIndex);
3257 }, 3245 },
3258 3246
3259 __proto__: WebInspector.TextPrompt.prototype 3247 __proto__: WebInspector.TextPrompt.prototype
3260 } 3248 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/Settings.js ('k') | Source/devtools/front_end/elementsPanel.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698