| OLD | NEW |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 this.titleElement.appendChild(this._elementStateButton); | 44 this.titleElement.appendChild(this._elementStateButton); |
| 45 | 45 |
| 46 var addButton = document.createElement("button"); | 46 var addButton = document.createElement("button"); |
| 47 addButton.className = "pane-title-button add"; | 47 addButton.className = "pane-title-button add"; |
| 48 addButton.id = "add-style-button-test-id"; | 48 addButton.id = "add-style-button-test-id"; |
| 49 addButton.title = WebInspector.UIString("New Style Rule"); | 49 addButton.title = WebInspector.UIString("New Style Rule"); |
| 50 addButton.addEventListener("click", this._createNewRule.bind(this), false); | 50 addButton.addEventListener("click", this._createNewRule.bind(this), false); |
| 51 this.titleElement.appendChild(addButton); | 51 this.titleElement.appendChild(addButton); |
| 52 | 52 |
| 53 this._computedStylePane = computedStylePane; | 53 this._computedStylePane = computedStylePane; |
| 54 computedStylePane.setHostingPane(this); | 54 computedStylePane._stylesSidebarPane = this; |
| 55 this._setPseudoClassCallback = setPseudoClassCallback; | 55 this._setPseudoClassCallback = setPseudoClassCallback; |
| 56 this.element.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this), true); | 56 this.element.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this), true); |
| 57 WebInspector.settings.colorFormat.addChangeListener(this._colorFormatSetting
Changed.bind(this)); | 57 WebInspector.settings.colorFormat.addChangeListener(this._colorFormatSetting
Changed.bind(this)); |
| 58 | 58 |
| 59 this._createElementStatePane(); | 59 this._createElementStatePane(); |
| 60 this.bodyElement.appendChild(this._elementStatePane); | 60 this.bodyElement.appendChild(this._elementStatePane); |
| 61 this._sectionsContainer = document.createElement("div"); | 61 this._sectionsContainer = document.createElement("div"); |
| 62 this.bodyElement.appendChild(this._sectionsContainer); | 62 this.bodyElement.appendChild(this._sectionsContainer); |
| 63 | 63 |
| 64 this._spectrumHelper = new WebInspector.SpectrumPopupHelper(); | 64 this._spectrumHelper = new WebInspector.SpectrumPopupHelper(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 */ | 173 */ |
| 174 _contextMenuEventFired: function(event) | 174 _contextMenuEventFired: function(event) |
| 175 { | 175 { |
| 176 // We start editing upon click -> default navigation to resources panel
is not available | 176 // We start editing upon click -> default navigation to resources panel
is not available |
| 177 // Hence we add a soft context menu for hrefs. | 177 // Hence we add a soft context menu for hrefs. |
| 178 var contextMenu = new WebInspector.ContextMenu(event); | 178 var contextMenu = new WebInspector.ContextMenu(event); |
| 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 /** | |
| 184 * @param {!Element} matchedStylesElement | |
| 185 * @param {!Element} computedStylesElement | |
| 186 */ | |
| 187 setFilterBoxContainers: function(matchedStylesElement, computedStylesElement
) | |
| 188 { | |
| 189 if (!WebInspector.experimentsSettings.cssStyleSearch.isEnabled()) | |
| 190 return; | |
| 191 | |
| 192 matchedStylesElement.appendChild(this._createCSSFilterControl()); | |
| 193 this._computedStylePane.setFilterBoxContainer(computedStylesElement); | |
| 194 }, | |
| 195 | |
| 196 /** | |
| 197 * @return {!Element} | |
| 198 */ | |
| 199 _createCSSFilterControl: function() | |
| 200 { | |
| 201 var filterInput = this._createPropertyFilterElement(false, searchHandler
.bind(this)); | |
| 202 | |
| 203 /** | |
| 204 * @param {?RegExp} regex | |
| 205 * @this {WebInspector.StylesSidebarPane} | |
| 206 */ | |
| 207 function searchHandler(regex) | |
| 208 { | |
| 209 this._filterRegex = regex; | |
| 210 } | |
| 211 | |
| 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; | |
| 230 }, | |
| 231 | |
| 232 get _forcedPseudoClasses() | 183 get _forcedPseudoClasses() |
| 233 { | 184 { |
| 234 return this.node ? (this.node.getUserProperty("pseudoState") || undefine
d) : undefined; | 185 return this.node ? (this.node.getUserProperty("pseudoState") || undefine
d) : undefined; |
| 235 }, | 186 }, |
| 236 | 187 |
| 237 _updateForcedPseudoStateInputs: function() | 188 _updateForcedPseudoStateInputs: function() |
| 238 { | 189 { |
| 239 if (!this.node) | 190 if (!this.node) |
| 240 return; | 191 return; |
| 241 | 192 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 this._rebuildUpdate(); | 239 this._rebuildUpdate(); |
| 289 }, | 240 }, |
| 290 | 241 |
| 291 /** | 242 /** |
| 292 * @param {!WebInspector.StylePropertiesSection=} editedSection | 243 * @param {!WebInspector.StylePropertiesSection=} editedSection |
| 293 * @param {boolean=} forceFetchComputedStyle | 244 * @param {boolean=} forceFetchComputedStyle |
| 294 * @param {function()=} userCallback | 245 * @param {function()=} userCallback |
| 295 */ | 246 */ |
| 296 _refreshUpdate: function(editedSection, forceFetchComputedStyle, userCallbac
k) | 247 _refreshUpdate: function(editedSection, forceFetchComputedStyle, userCallbac
k) |
| 297 { | 248 { |
| 298 var callbackWrapper = function() | |
| 299 { | |
| 300 if (this._filterRegex) | |
| 301 this._updateFilter(false); | |
| 302 if (userCallback) | |
| 303 userCallback(); | |
| 304 }.bind(this); | |
| 305 | |
| 306 if (this._refreshUpdateInProgress) { | 249 if (this._refreshUpdateInProgress) { |
| 307 this._lastNodeForInnerRefresh = this.node; | 250 this._lastNodeForInnerRefresh = this.node; |
| 308 return; | 251 return; |
| 309 } | 252 } |
| 310 | 253 |
| 311 var node = this._validateNode(userCallback); | 254 var node = this._validateNode(userCallback); |
| 312 if (!node) | 255 if (!node) |
| 313 return; | 256 return; |
| 314 | 257 |
| 315 /** | 258 /** |
| 316 * @param {?WebInspector.CSSStyleDeclaration} computedStyle | 259 * @param {?WebInspector.CSSStyleDeclaration} computedStyle |
| 317 * @this {WebInspector.StylesSidebarPane} | 260 * @this {WebInspector.StylesSidebarPane} |
| 318 */ | 261 */ |
| 319 function computedStyleCallback(computedStyle) | 262 function computedStyleCallback(computedStyle) |
| 320 { | 263 { |
| 321 delete this._refreshUpdateInProgress; | 264 delete this._refreshUpdateInProgress; |
| 322 | 265 |
| 323 if (this._lastNodeForInnerRefresh) { | 266 if (this._lastNodeForInnerRefresh) { |
| 324 delete this._lastNodeForInnerRefresh; | 267 delete this._lastNodeForInnerRefresh; |
| 325 this._refreshUpdate(editedSection, forceFetchComputedStyle, call
backWrapper); | 268 this._refreshUpdate(editedSection, forceFetchComputedStyle, user
Callback); |
| 326 return; | 269 return; |
| 327 } | 270 } |
| 328 | 271 |
| 329 if (this.node === node && computedStyle) | 272 if (this.node === node && computedStyle) |
| 330 this._innerRefreshUpdate(node, computedStyle, editedSection); | 273 this._innerRefreshUpdate(node, computedStyle, editedSection); |
| 331 | 274 |
| 332 callbackWrapper(); | 275 if (userCallback) |
| 276 userCallback(); |
| 333 } | 277 } |
| 334 | 278 |
| 335 if (this._computedStylePane.isShowing() || forceFetchComputedStyle) { | 279 if (this._computedStylePane.isShowing() || forceFetchComputedStyle) { |
| 336 this._refreshUpdateInProgress = true; | 280 this._refreshUpdateInProgress = true; |
| 337 WebInspector.cssModel.getComputedStyleAsync(node.id, computedStyleCa
llback.bind(this)); | 281 WebInspector.cssModel.getComputedStyleAsync(node.id, computedStyleCa
llback.bind(this)); |
| 338 } else { | 282 } else { |
| 339 this._innerRefreshUpdate(node, null, editedSection); | 283 this._innerRefreshUpdate(node, null, editedSection); |
| 340 callbackWrapper(); | 284 if (userCallback) |
| 285 userCallback(); |
| 341 } | 286 } |
| 342 }, | 287 }, |
| 343 | 288 |
| 344 _rebuildUpdate: function() | 289 _rebuildUpdate: function() |
| 345 { | 290 { |
| 346 if (this._rebuildUpdateInProgress) { | 291 if (this._rebuildUpdateInProgress) { |
| 347 this._lastNodeForInnerRebuild = this.node; | 292 this._lastNodeForInnerRebuild = this.node; |
| 348 return; | 293 return; |
| 349 } | 294 } |
| 350 | 295 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 // Add rules in reverse order to match the cascade order. | 456 // Add rules in reverse order to match the cascade order. |
| 512 for (var j = pseudoElementCSSRules.rules.length - 1; j >= 0; --j) { | 457 for (var j = pseudoElementCSSRules.rules.length - 1; j >= 0; --j) { |
| 513 var rule = pseudoElementCSSRules.rules[j]; | 458 var rule = pseudoElementCSSRules.rules[j]; |
| 514 styleRules.push({ style: rule.style, selectorText: rule.selector
Text, media: rule.media, sourceURL: rule.resourceURL(), rule: rule, editable: !!
(rule.style && rule.style.id) }); | 459 styleRules.push({ style: rule.style, selectorText: rule.selector
Text, media: rule.media, sourceURL: rule.resourceURL(), rule: rule, editable: !!
(rule.style && rule.style.id) }); |
| 515 } | 460 } |
| 516 usedProperties = {}; | 461 usedProperties = {}; |
| 517 this._markUsedProperties(styleRules, usedProperties); | 462 this._markUsedProperties(styleRules, usedProperties); |
| 518 this.sections[pseudoId] = this._rebuildSectionsForStyleRules(styleRu
les, usedProperties, anchorElement); | 463 this.sections[pseudoId] = this._rebuildSectionsForStyleRules(styleRu
les, usedProperties, anchorElement); |
| 519 } | 464 } |
| 520 | 465 |
| 521 if (this._filterRegex) | |
| 522 this._updateFilter(false); | |
| 523 this._nodeStylesUpdatedForTest(node, true); | 466 this._nodeStylesUpdatedForTest(node, true); |
| 524 }, | 467 }, |
| 525 | 468 |
| 526 _nodeStylesUpdatedForTest: function(node, rebuild) | 469 _nodeStylesUpdatedForTest: function(node, rebuild) |
| 527 { | 470 { |
| 528 // Tests override this method. | 471 // Tests override this method. |
| 529 }, | 472 }, |
| 530 | 473 |
| 531 _refreshStyleRules: function(sections, computedStyle) | 474 _refreshStyleRules: function(sections, computedStyle) |
| 532 { | 475 { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 input.type = "checkbox"; | 799 input.type = "checkbox"; |
| 857 input.state = state; | 800 input.state = state; |
| 858 input.addEventListener("click", clickListener.bind(this), false); | 801 input.addEventListener("click", clickListener.bind(this), false); |
| 859 inputs.push(input); | 802 inputs.push(input); |
| 860 label.appendChild(input); | 803 label.appendChild(input); |
| 861 label.appendChild(document.createTextNode(":" + state)); | 804 label.appendChild(document.createTextNode(":" + state)); |
| 862 td.appendChild(label); | 805 td.appendChild(label); |
| 863 return td; | 806 return td; |
| 864 } | 807 } |
| 865 | 808 |
| 866 var tr = table.createChild("tr"); | 809 var tr = document.createElement("tr"); |
| 867 tr.appendChild(createCheckbox.call(this, "active")); | 810 tr.appendChild(createCheckbox.call(this, "active")); |
| 868 tr.appendChild(createCheckbox.call(this, "hover")); | 811 tr.appendChild(createCheckbox.call(this, "hover")); |
| 812 table.appendChild(tr); |
| 869 | 813 |
| 870 tr = table.createChild("tr"); | 814 tr = document.createElement("tr"); |
| 871 tr.appendChild(createCheckbox.call(this, "focus")); | 815 tr.appendChild(createCheckbox.call(this, "focus")); |
| 872 tr.appendChild(createCheckbox.call(this, "visited")); | 816 tr.appendChild(createCheckbox.call(this, "visited")); |
| 817 table.appendChild(tr); |
| 873 | 818 |
| 874 this._elementStatePane.appendChild(table); | 819 this._elementStatePane.appendChild(table); |
| 875 }, | 820 }, |
| 876 | 821 |
| 877 /** | 822 /** |
| 878 * @return {?RegExp} | |
| 879 */ | |
| 880 filterRegex: function() | |
| 881 { | |
| 882 return this._filterRegex; | |
| 883 }, | |
| 884 | |
| 885 /** | |
| 886 * @param {boolean} isComputedStyleFilter | |
| 887 * @return {!Element} | |
| 888 * @param {function(?RegExp)} filterCallback | |
| 889 */ | |
| 890 _createPropertyFilterElement: function(isComputedStyleFilter, filterCallback
) | |
| 891 { | |
| 892 var input = document.createElement("input"); | |
| 893 input.type = "text"; | |
| 894 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); | |
| 897 | |
| 898 /** | |
| 899 * @this {WebInspector.StylesSidebarPane} | |
| 900 */ | |
| 901 function searchHandler() | |
| 902 { | |
| 903 var regex = input.value ? new RegExp(input.value.escapeForRegExp(),
"i") : null; | |
| 904 filterCallback(regex); | |
| 905 this._updateFilter(isComputedStyleFilter); | |
| 906 } | |
| 907 input.addEventListener("input", boundSearchHandler, false); | |
| 908 | |
| 909 /** | |
| 910 * @param {?Event} event | |
| 911 */ | |
| 912 function keydownHandler(event) | |
| 913 { | |
| 914 var Esc = "U+001B"; | |
| 915 if (event.keyIdentifier !== Esc || !input.value) | |
| 916 return; | |
| 917 event.consume(true); | |
| 918 input.value = ""; | |
| 919 boundSearchHandler(); | |
| 920 } | |
| 921 input.addEventListener("keydown", keydownHandler, false); | |
| 922 | |
| 923 return input; | |
| 924 }, | |
| 925 | |
| 926 /** | |
| 927 * @param {boolean} isComputedStyleFilter | |
| 928 */ | |
| 929 _updateFilter: function(isComputedStyleFilter) | |
| 930 { | |
| 931 for (var pseudoId in this.sections) { | |
| 932 var sections = this.sections[pseudoId]; | |
| 933 for (var i = 0; i < sections.length; ++i) { | |
| 934 var section = sections[i]; | |
| 935 if (isComputedStyleFilter !== !!section.computedStyle) | |
| 936 continue; | |
| 937 section.updateFilter(); | |
| 938 } | |
| 939 } | |
| 940 }, | |
| 941 | |
| 942 /** | |
| 943 * @param {!WebInspector.Event} event | 823 * @param {!WebInspector.Event} event |
| 944 */ | 824 */ |
| 945 _showUserAgentStylesSettingChanged: function(event) | 825 _showUserAgentStylesSettingChanged: function(event) |
| 946 { | 826 { |
| 947 var showStyles = /** @type {boolean} */ (event.data); | 827 var showStyles = /** @type {boolean} */ (event.data); |
| 948 this.element.classList.toggle("show-user-styles", showStyles); | 828 this.element.classList.toggle("show-user-styles", showStyles); |
| 949 }, | 829 }, |
| 950 | 830 |
| 951 willHide: function() | 831 willHide: function() |
| 952 { | 832 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 /** | 873 /** |
| 994 * @constructor | 874 * @constructor |
| 995 * @extends {WebInspector.SidebarPane} | 875 * @extends {WebInspector.SidebarPane} |
| 996 */ | 876 */ |
| 997 WebInspector.ComputedStyleSidebarPane = function() | 877 WebInspector.ComputedStyleSidebarPane = function() |
| 998 { | 878 { |
| 999 WebInspector.SidebarPane.call(this, WebInspector.UIString("Computed Style"))
; | 879 WebInspector.SidebarPane.call(this, WebInspector.UIString("Computed Style"))
; |
| 1000 } | 880 } |
| 1001 | 881 |
| 1002 WebInspector.ComputedStyleSidebarPane.prototype = { | 882 WebInspector.ComputedStyleSidebarPane.prototype = { |
| 1003 /** | |
| 1004 * @param {!WebInspector.StylesSidebarPane} pane | |
| 1005 */ | |
| 1006 setHostingPane: function(pane) | |
| 1007 { | |
| 1008 this._stylesSidebarPane = pane; | |
| 1009 }, | |
| 1010 | |
| 1011 setFilterBoxContainer: function(element) | |
| 1012 { | |
| 1013 element.appendChild(this._stylesSidebarPane._createPropertyFilterElement
(true, filterCallback.bind(this))); | |
| 1014 | |
| 1015 /** | |
| 1016 * @param {?RegExp} regex | |
| 1017 * @this {WebInspector.ComputedStyleSidebarPane} | |
| 1018 */ | |
| 1019 function filterCallback(regex) | |
| 1020 { | |
| 1021 this._filterRegex = regex; | |
| 1022 } | |
| 1023 }, | |
| 1024 | |
| 1025 wasShown: function() | 883 wasShown: function() |
| 1026 { | 884 { |
| 1027 WebInspector.SidebarPane.prototype.wasShown.call(this); | 885 WebInspector.SidebarPane.prototype.wasShown.call(this); |
| 1028 if (!this._hasFreshContent) | 886 if (!this._hasFreshContent) |
| 1029 this.prepareContent(); | 887 this.prepareContent(); |
| 1030 }, | 888 }, |
| 1031 | 889 |
| 1032 /** | 890 /** |
| 1033 * @param {function()=} callback | 891 * @param {function()=} callback |
| 1034 */ | 892 */ |
| 1035 prepareContent: function(callback) | 893 prepareContent: function(callback) |
| 1036 { | 894 { |
| 1037 /** | 895 /** |
| 1038 * @this {WebInspector.ComputedStyleSidebarPane} | 896 * @this {WebInspector.ComputedStyleSidebarPane} |
| 1039 */ | 897 */ |
| 1040 function wrappedCallback() { | 898 function wrappedCallback() { |
| 1041 this._hasFreshContent = true; | 899 this._hasFreshContent = true; |
| 1042 if (callback) | 900 if (callback) |
| 1043 callback(); | 901 callback(); |
| 1044 delete this._hasFreshContent; | 902 delete this._hasFreshContent; |
| 1045 } | 903 } |
| 1046 this._stylesSidebarPane._refreshUpdate(null, true, wrappedCallback.bind(
this)); | 904 this._stylesSidebarPane._refreshUpdate(null, true, wrappedCallback.bind(
this)); |
| 1047 }, | 905 }, |
| 1048 | 906 |
| 1049 /** | |
| 1050 * @return {?RegExp} | |
| 1051 */ | |
| 1052 filterRegex: function() | |
| 1053 { | |
| 1054 return this._filterRegex; | |
| 1055 }, | |
| 1056 | |
| 1057 __proto__: WebInspector.SidebarPane.prototype | 907 __proto__: WebInspector.SidebarPane.prototype |
| 1058 } | 908 } |
| 1059 | 909 |
| 1060 /** | 910 /** |
| 1061 * @constructor | 911 * @constructor |
| 1062 * @extends {WebInspector.PropertiesSection} | 912 * @extends {WebInspector.PropertiesSection} |
| 1063 * @param {!WebInspector.StylesSidebarPane} parentPane | 913 * @param {!WebInspector.StylesSidebarPane} parentPane |
| 1064 * @param {!Object} styleRule | 914 * @param {!Object} styleRule |
| 1065 * @param {boolean} editable | 915 * @param {boolean} editable |
| 1066 * @param {boolean} isInherited | 916 * @param {boolean} isInherited |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 if (shorthandPropertyAvailable) | 1214 if (shorthandPropertyAvailable) |
| 1365 continue; // Shorthand for the property found. | 1215 continue; // Shorthand for the property found. |
| 1366 | 1216 |
| 1367 var inherited = this.isPropertyInherited(property.name); | 1217 var inherited = this.isPropertyInherited(property.name); |
| 1368 var overloaded = property.inactive || this.isPropertyOverloaded(prop
erty.name, isShorthand); | 1218 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); | 1219 var item = new WebInspector.StylePropertyTreeElement(this._parentPan
e, this.styleRule, style, property, isShorthand, inherited, overloaded); |
| 1370 this.propertiesTreeOutline.appendChild(item); | 1220 this.propertiesTreeOutline.appendChild(item); |
| 1371 } | 1221 } |
| 1372 }, | 1222 }, |
| 1373 | 1223 |
| 1374 updateFilter: function() | |
| 1375 { | |
| 1376 var children = this.propertiesTreeOutline.children; | |
| 1377 for (var i = 0; i < children.length; ++i) | |
| 1378 children[i].updateFilter(); | |
| 1379 | |
| 1380 if (this.styleRule.rule) | |
| 1381 this._markSelectorHighlights(); | |
| 1382 }, | |
| 1383 | |
| 1384 _markSelectorMatches: function() | 1224 _markSelectorMatches: function() |
| 1385 { | 1225 { |
| 1386 var rule = this.styleRule.rule; | 1226 var rule = this.styleRule.rule; |
| 1387 if (!rule) | 1227 if (!rule) |
| 1388 return; | 1228 return; |
| 1389 | 1229 |
| 1390 var matchingSelectors = rule.matchingSelectors; | 1230 var matchingSelectors = rule.matchingSelectors; |
| 1391 // .selector is rendered as non-affecting selector by default. | 1231 // .selector is rendered as non-affecting selector by default. |
| 1392 if (this.noAffect || matchingSelectors) | 1232 if (this.noAffect || matchingSelectors) |
| 1393 this._selectorElement.className = "selector"; | 1233 this._selectorElement.className = "selector"; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1409 selectorElement.className = "simple-selector" + matchingSelectorClas
s; | 1249 selectorElement.className = "simple-selector" + matchingSelectorClas
s; |
| 1410 if (rule.id) | 1250 if (rule.id) |
| 1411 selectorElement._selectorIndex = i; | 1251 selectorElement._selectorIndex = i; |
| 1412 selectorElement.textContent = selectors[i].value; | 1252 selectorElement.textContent = selectors[i].value; |
| 1413 | 1253 |
| 1414 fragment.appendChild(selectorElement); | 1254 fragment.appendChild(selectorElement); |
| 1415 } | 1255 } |
| 1416 | 1256 |
| 1417 this._selectorElement.removeChildren(); | 1257 this._selectorElement.removeChildren(); |
| 1418 this._selectorElement.appendChild(fragment); | 1258 this._selectorElement.appendChild(fragment); |
| 1419 this._markSelectorHighlights(); | |
| 1420 }, | |
| 1421 | |
| 1422 _markSelectorHighlights: function() | |
| 1423 { | |
| 1424 var selectors = this._selectorElement.getElementsByClassName("simple-sel
ector"); | |
| 1425 var regex = this.pane.filterRegex(); | |
| 1426 for (var i = 0; i < selectors.length; ++i) { | |
| 1427 var selectorMatchesFilter = regex && regex.test(selectors[i].textCon
tent); | |
| 1428 selectors[i].classList.toggle("filter-match", selectorMatchesFilter)
; | |
| 1429 } | |
| 1430 }, | 1259 }, |
| 1431 | 1260 |
| 1432 _checkWillCancelEditing: function() | 1261 _checkWillCancelEditing: function() |
| 1433 { | 1262 { |
| 1434 var willCauseCancelEditing = this._willCauseCancelEditing; | 1263 var willCauseCancelEditing = this._willCauseCancelEditing; |
| 1435 delete this._willCauseCancelEditing; | 1264 delete this._willCauseCancelEditing; |
| 1436 return willCauseCancelEditing; | 1265 return willCauseCancelEditing; |
| 1437 }, | 1266 }, |
| 1438 | 1267 |
| 1439 _handleSelectorContainerClick: function(event) | 1268 _handleSelectorContainerClick: function(event) |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 * @constructor | 1498 * @constructor |
| 1670 * @extends {WebInspector.PropertiesSection} | 1499 * @extends {WebInspector.PropertiesSection} |
| 1671 * @param {!WebInspector.StylesSidebarPane} stylesPane | 1500 * @param {!WebInspector.StylesSidebarPane} stylesPane |
| 1672 * @param {!Object} styleRule | 1501 * @param {!Object} styleRule |
| 1673 * @param {!Object.<string, boolean>} usedProperties | 1502 * @param {!Object.<string, boolean>} usedProperties |
| 1674 */ | 1503 */ |
| 1675 WebInspector.ComputedStylePropertiesSection = function(stylesPane, styleRule, us
edProperties) | 1504 WebInspector.ComputedStylePropertiesSection = function(stylesPane, styleRule, us
edProperties) |
| 1676 { | 1505 { |
| 1677 WebInspector.PropertiesSection.call(this, ""); | 1506 WebInspector.PropertiesSection.call(this, ""); |
| 1678 | 1507 |
| 1679 var subtitle = this.headerElement.createChild("div", "sidebar-pane-subtitle
vbox"); | 1508 var showInheritedCheckbox = new WebInspector.Checkbox(WebInspector.UIString(
"Show inherited properties"), "sidebar-pane-subtitle"); |
| 1680 var showInheritedCheckbox = new WebInspector.Checkbox(WebInspector.UIString(
"Show inherited properties"), "hbox"); | 1509 this.headerElement.appendChild(showInheritedCheckbox.element); |
| 1681 subtitle.appendChild(showInheritedCheckbox.element); | |
| 1682 | |
| 1683 this._hasFreshContent = false; | 1510 this._hasFreshContent = false; |
| 1684 | 1511 |
| 1685 /** | 1512 /** |
| 1686 * @this {WebInspector.ComputedStylePropertiesSection} | 1513 * @this {WebInspector.ComputedStylePropertiesSection} |
| 1687 */ | 1514 */ |
| 1688 function showInheritedToggleFunction() | 1515 function showInheritedToggleFunction() |
| 1689 { | 1516 { |
| 1690 var showInherited = showInheritedCheckbox.checked; | 1517 var showInherited = showInheritedCheckbox.checked; |
| 1691 WebInspector.settings.showInheritedComputedStyleProperties.set(showInher
ited); | 1518 WebInspector.settings.showInheritedComputedStyleProperties.set(showInher
ited); |
| 1692 if (showInherited) | 1519 if (showInherited) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 this._expandedPropertyNames = {}; | 1556 this._expandedPropertyNames = {}; |
| 1730 for (var name in this._propertyTreeElements) { | 1557 for (var name in this._propertyTreeElements) { |
| 1731 if (this._propertyTreeElements[name].expanded) | 1558 if (this._propertyTreeElements[name].expanded) |
| 1732 this._expandedPropertyNames[name] = true; | 1559 this._expandedPropertyNames[name] = true; |
| 1733 } | 1560 } |
| 1734 this._propertyTreeElements = {}; | 1561 this._propertyTreeElements = {}; |
| 1735 this.propertiesTreeOutline.removeChildren(); | 1562 this.propertiesTreeOutline.removeChildren(); |
| 1736 this.populated = false; | 1563 this.populated = false; |
| 1737 }, | 1564 }, |
| 1738 | 1565 |
| 1739 updateFilter: function() | |
| 1740 { | |
| 1741 var children = this.propertiesTreeOutline.children; | |
| 1742 for (var i = 0; i < children.length; ++i) | |
| 1743 children[i].updateFilter(); | |
| 1744 }, | |
| 1745 | |
| 1746 onpopulate: function() | 1566 onpopulate: function() |
| 1747 { | 1567 { |
| 1748 function sorter(a, b) | 1568 function sorter(a, b) |
| 1749 { | 1569 { |
| 1750 return a.name.compareTo(b.name); | 1570 return a.name.compareTo(b.name); |
| 1751 } | 1571 } |
| 1752 | 1572 |
| 1753 var style = this.styleRule.style; | 1573 var style = this.styleRule.style; |
| 1754 if (!style) | 1574 if (!style) |
| 1755 return; | 1575 return; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 }, | 1773 }, |
| 1954 | 1774 |
| 1955 /** | 1775 /** |
| 1956 * @return {?WebInspector.StylesSidebarPane} | 1776 * @return {?WebInspector.StylesSidebarPane} |
| 1957 */ | 1777 */ |
| 1958 editablePane: function() | 1778 editablePane: function() |
| 1959 { | 1779 { |
| 1960 return null; // Overridden by ancestors. | 1780 return null; // Overridden by ancestors. |
| 1961 }, | 1781 }, |
| 1962 | 1782 |
| 1963 /** | |
| 1964 * @return {!WebInspector.StylesSidebarPane|!WebInspector.ComputedStyleSideb
arPane} | |
| 1965 */ | |
| 1966 parentPane: function() | |
| 1967 { | |
| 1968 throw "Not implemented"; | |
| 1969 }, | |
| 1970 | |
| 1971 get inherited() | 1783 get inherited() |
| 1972 { | 1784 { |
| 1973 return this._inherited; | 1785 return this._inherited; |
| 1974 }, | 1786 }, |
| 1975 | 1787 |
| 1976 /** | 1788 /** |
| 1977 * @return {boolean} | 1789 * @return {boolean} |
| 1978 */ | 1790 */ |
| 1979 hasIgnorableError: function() | 1791 hasIgnorableError: function() |
| 1980 { | 1792 { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2143 if (!this.parsedOk) { | 1955 if (!this.parsedOk) { |
| 2144 // Avoid having longhands under an invalid shorthand. | 1956 // Avoid having longhands under an invalid shorthand. |
| 2145 this.hasChildren = false; | 1957 this.hasChildren = false; |
| 2146 this.listItemElement.classList.add("not-parsed-ok"); | 1958 this.listItemElement.classList.add("not-parsed-ok"); |
| 2147 | 1959 |
| 2148 // Add a separate exclamation mark IMG element with a tooltip. | 1960 // Add a separate exclamation mark IMG element with a tooltip. |
| 2149 this.listItemElement.insertBefore(WebInspector.StylesSidebarPane.cre
ateExclamationMark(this.property), this.listItemElement.firstChild); | 1961 this.listItemElement.insertBefore(WebInspector.StylesSidebarPane.cre
ateExclamationMark(this.property), this.listItemElement.firstChild); |
| 2150 } | 1962 } |
| 2151 if (this.property.inactive) | 1963 if (this.property.inactive) |
| 2152 this.listItemElement.classList.add("inactive"); | 1964 this.listItemElement.classList.add("inactive"); |
| 2153 this.updateFilter(); | |
| 2154 }, | |
| 2155 | |
| 2156 updateFilter: function() | |
| 2157 { | |
| 2158 var regEx = this.parentPane().filterRegex(); | |
| 2159 this.listItemElement.classList.toggle("filter-match", !!regEx && (regEx.
test(this.property.name) || regEx.test(this.property.value))); | |
| 2160 }, | 1965 }, |
| 2161 | 1966 |
| 2162 /** | 1967 /** |
| 2163 * @param {!Element} nameElement | 1968 * @param {!Element} nameElement |
| 2164 * @param {!Element} valueElement | 1969 * @param {!Element} valueElement |
| 2165 * @param {string} text | 1970 * @param {string} text |
| 2166 */ | 1971 */ |
| 2167 _processColor: function(nameElement, valueElement, text) | 1972 _processColor: function(nameElement, valueElement, text) |
| 2168 { | 1973 { |
| 2169 var color = WebInspector.Color.parse(text); | 1974 var color = WebInspector.Color.parse(text); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2381 }, | 2186 }, |
| 2382 | 2187 |
| 2383 /** | 2188 /** |
| 2384 * @return {?WebInspector.StylesSidebarPane} | 2189 * @return {?WebInspector.StylesSidebarPane} |
| 2385 */ | 2190 */ |
| 2386 editablePane: function() | 2191 editablePane: function() |
| 2387 { | 2192 { |
| 2388 return null; | 2193 return null; |
| 2389 }, | 2194 }, |
| 2390 | 2195 |
| 2391 /** | |
| 2392 * @return {!WebInspector.ComputedStyleSidebarPane} | |
| 2393 */ | |
| 2394 parentPane: function() | |
| 2395 { | |
| 2396 return this._stylesPane._computedStylePane; | |
| 2397 }, | |
| 2398 | |
| 2399 updateFilter: function() | |
| 2400 { | |
| 2401 var regEx = this.parentPane().filterRegex(); | |
| 2402 this.listItemElement.classList.toggle("hidden", !!regEx && (!regEx.test(
this.property.name) && !regEx.test(this.property.value))); | |
| 2403 }, | |
| 2404 | |
| 2405 __proto__: WebInspector.StylePropertyTreeElementBase.prototype | 2196 __proto__: WebInspector.StylePropertyTreeElementBase.prototype |
| 2406 } | 2197 } |
| 2407 | 2198 |
| 2408 /** | 2199 /** |
| 2409 * @constructor | 2200 * @constructor |
| 2410 * @extends {WebInspector.StylePropertyTreeElementBase} | 2201 * @extends {WebInspector.StylePropertyTreeElementBase} |
| 2411 * @param {!WebInspector.StylesSidebarPane} stylesPane | 2202 * @param {!WebInspector.StylesSidebarPane} stylesPane |
| 2412 * @param {!Object} styleRule | 2203 * @param {!Object} styleRule |
| 2413 * @param {!WebInspector.CSSStyleDeclaration} style | 2204 * @param {!WebInspector.CSSStyleDeclaration} style |
| 2414 * @param {!WebInspector.CSSProperty} property | 2205 * @param {!WebInspector.CSSProperty} property |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2432 return this._parentPane.node; | 2223 return this._parentPane.node; |
| 2433 }, | 2224 }, |
| 2434 | 2225 |
| 2435 /** | 2226 /** |
| 2436 * @return {?WebInspector.StylesSidebarPane} | 2227 * @return {?WebInspector.StylesSidebarPane} |
| 2437 */ | 2228 */ |
| 2438 editablePane: function() | 2229 editablePane: function() |
| 2439 { | 2230 { |
| 2440 return this._parentPane; | 2231 return this._parentPane; |
| 2441 }, | 2232 }, |
| 2442 | |
| 2443 /** | |
| 2444 * @return {!WebInspector.StylesSidebarPane} | |
| 2445 */ | |
| 2446 parentPane: function() | |
| 2447 { | |
| 2448 return this._parentPane; | |
| 2449 }, | |
| 2450 | 2233 |
| 2451 /** | 2234 /** |
| 2452 * @return {?WebInspector.StylePropertiesSection} | 2235 * @return {?WebInspector.StylePropertiesSection} |
| 2453 */ | 2236 */ |
| 2454 section: function() | 2237 section: function() |
| 2455 { | 2238 { |
| 2456 return this.treeOutline && this.treeOutline.section; | 2239 return this.treeOutline && this.treeOutline.section; |
| 2457 }, | 2240 }, |
| 2458 | 2241 |
| 2459 /** | 2242 /** |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3251 return; | 3034 return; |
| 3252 } | 3035 } |
| 3253 | 3036 |
| 3254 var results = this._cssCompletions.startsWith(prefix); | 3037 var results = this._cssCompletions.startsWith(prefix); |
| 3255 var selectedIndex = this._cssCompletions.mostUsedOf(results); | 3038 var selectedIndex = this._cssCompletions.mostUsedOf(results); |
| 3256 completionsReadyCallback(results, selectedIndex); | 3039 completionsReadyCallback(results, selectedIndex); |
| 3257 }, | 3040 }, |
| 3258 | 3041 |
| 3259 __proto__: WebInspector.TextPrompt.prototype | 3042 __proto__: WebInspector.TextPrompt.prototype |
| 3260 } | 3043 } |
| OLD | NEW |