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._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultCSSFormatter()); | 44 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultCSSFormatter()); |
45 | 45 |
46 this.element.classList.add("styles-pane"); | 46 this.element.classList.add("styles-pane"); |
47 this.element.addEventListener("mousemove", this._mouseMovedOverElement.bind( this), false); | 47 this.element.addEventListener("mousemove", this._mouseMovedOverElement.bind( this), false); |
48 this._keyDownBound = this._keyDown.bind(this); | 48 this._keyDownBound = this._keyDown.bind(this); |
49 this._keyUpBound = this._keyUp.bind(this); | 49 this._keyUpBound = this._keyUp.bind(this); |
50 new WebInspector.PropertyChangeHighlighter(this); | 50 new WebInspector.PropertyChangeHighlighter(this); |
51 } | 51 } |
52 | 52 |
53 /** | 53 /** |
54 * @enum {string} | |
55 */ | |
56 WebInspector.StylesSidebarPane.Events = { | |
57 SelectorEditingStarted: "SelectorEditingStarted", | |
58 SelectorEditingEnded: "SelectorEditingEnded" | |
59 }; | |
60 | |
61 /** | |
62 * @param {!WebInspector.CSSProperty} property | 54 * @param {!WebInspector.CSSProperty} property |
63 * @return {!Element} | 55 * @return {!Element} |
64 */ | 56 */ |
65 WebInspector.StylesSidebarPane.createExclamationMark = function(property) | 57 WebInspector.StylesSidebarPane.createExclamationMark = function(property) |
66 { | 58 { |
67 var exclamationElement = createElement("label", "dt-icon-label"); | 59 var exclamationElement = createElement("label", "dt-icon-label"); |
68 exclamationElement.className = "exclamation-mark"; | 60 exclamationElement.className = "exclamation-mark"; |
69 if (!WebInspector.StylesSidebarPane.ignoreErrorsForProperty(property)) | 61 if (!WebInspector.StylesSidebarPane.ignoreErrorsForProperty(property)) |
70 exclamationElement.type = "warning-icon"; | 62 exclamationElement.type = "warning-icon"; |
71 exclamationElement.title = WebInspector.CSSMetadata.cssPropertiesMetainfo.ke ySet()[property.name.toLowerCase()] ? WebInspector.UIString("Invalid property va lue") : WebInspector.UIString("Unknown property name"); | 63 exclamationElement.title = WebInspector.CSSMetadata.cssPropertiesMetainfo.ke ySet()[property.name.toLowerCase()] ? WebInspector.UIString("Invalid property va lue") : WebInspector.UIString("Unknown property name"); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 }, | 237 }, |
246 | 238 |
247 /** | 239 /** |
248 * @override | 240 * @override |
249 * @return {!Promise.<?>} | 241 * @return {!Promise.<?>} |
250 */ | 242 */ |
251 doUpdate: function() | 243 doUpdate: function() |
252 { | 244 { |
253 this._discardElementUnderMouse(); | 245 this._discardElementUnderMouse(); |
254 | 246 |
255 return this.fetchMatchedCascade() | 247 var promises = [ |
256 .then(this._innerRebuildUpdate.bind(this)); | 248 this.fetchMatchedCascade(), |
249 this._fetchMatchedKeyframes() | |
250 ]; | |
251 | |
252 return Promise.all(promises).spread(this._innerRebuildUpdate.bind(this)) ; | |
257 }, | 253 }, |
258 | 254 |
259 /** | 255 /** |
260 * @param {function()} callback | 256 * @param {function()} callback |
261 */ | 257 */ |
262 runDecoratorAfterUpdate: function(callback) | 258 runDecoratorAfterUpdate: function(callback) |
263 { | 259 { |
264 this._decoratorCallback = callback; | 260 this._decoratorCallback = callback; |
265 }, | 261 }, |
266 | 262 |
(...skipping 19 matching lines...) Expand all Loading... | |
286 * @return {?WebInspector.CSSStyleModel.MatchedStyleResult} | 282 * @return {?WebInspector.CSSStyleModel.MatchedStyleResult} |
287 * @this {WebInspector.StylesSidebarPane} | 283 * @this {WebInspector.StylesSidebarPane} |
288 */ | 284 */ |
289 function validateStyles(matchedStyles) | 285 function validateStyles(matchedStyles) |
290 { | 286 { |
291 return matchedStyles && matchedStyles.node() === this.node() ? match edStyles : null; | 287 return matchedStyles && matchedStyles.node() === this.node() ? match edStyles : null; |
292 } | 288 } |
293 }, | 289 }, |
294 | 290 |
295 /** | 291 /** |
292 * @return {!Promise.<?Array.<!WebInspector.CSSKeyframesRule>>} | |
293 */ | |
294 _fetchMatchedKeyframes: function() | |
295 { | |
296 var node = this.node(); | |
297 if (!node || !this.cssModel()) | |
298 return Promise.resolve(); | |
299 return this.cssModel().matchedKeyframesPromise(node.id); | |
300 }, | |
301 | |
302 /** | |
296 * @param {!WebInspector.DOMNode} node | 303 * @param {!WebInspector.DOMNode} node |
297 * @return {!Promise.<?WebInspector.CSSStyleModel.MatchedStyleResult>} | 304 * @return {!Promise.<?WebInspector.CSSStyleModel.MatchedStyleResult>} |
298 */ | 305 */ |
299 _matchedStylesForNode: function(node) | 306 _matchedStylesForNode: function(node) |
300 { | 307 { |
301 var cssModel = this.cssModel(); | 308 var cssModel = this.cssModel(); |
302 if (!cssModel) | 309 if (!cssModel) |
303 return Promise.resolve(/** @type {?WebInspector.CSSStyleModel.Matche dStyleResult} */(null)); | 310 return Promise.resolve(/** @type {?WebInspector.CSSStyleModel.Matche dStyleResult} */(null)); |
304 return cssModel.matchedStylesPromise(node.id) | 311 return cssModel.matchedStylesPromise(node.id) |
305 }, | 312 }, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 * @param {?WebInspector.DOMNode} node | 364 * @param {?WebInspector.DOMNode} node |
358 */ | 365 */ |
359 _canAffectCurrentStyles: function(node) | 366 _canAffectCurrentStyles: function(node) |
360 { | 367 { |
361 var currentNode = this.node(); | 368 var currentNode = this.node(); |
362 return currentNode && (currentNode === node || node.parentNode === curre ntNode.parentNode || node.isAncestor(currentNode)); | 369 return currentNode && (currentNode === node || node.parentNode === curre ntNode.parentNode || node.isAncestor(currentNode)); |
363 }, | 370 }, |
364 | 371 |
365 /** | 372 /** |
366 * @param {?WebInspector.CSSStyleModel.MatchedStyleResult} matchedStyles | 373 * @param {?WebInspector.CSSStyleModel.MatchedStyleResult} matchedStyles |
374 * @param {?Array.<!WebInspector.CSSKeyframesRule>} keyframesRules | |
367 */ | 375 */ |
368 _innerRebuildUpdate: function(matchedStyles) | 376 _innerRebuildUpdate: function(matchedStyles, keyframesRules) |
369 { | 377 { |
370 this._linkifier.reset(); | 378 this._linkifier.reset(); |
371 this._sectionsContainer.removeChildren(); | 379 this._sectionsContainer.removeChildren(); |
372 this._sectionBlocks = []; | 380 this._sectionBlocks = []; |
373 | 381 |
374 var node = this.node(); | 382 var node = this.node(); |
375 if (!matchedStyles || !node) | 383 if (!matchedStyles || !node) |
376 return; | 384 return; |
377 | 385 |
378 this._sectionBlocks = this._rebuildSectionsForMatchedStyleRules(matchedS tyles); | 386 this._sectionBlocks = this._rebuildSectionsForMatchedStyleRules(matchedS tyles); |
379 var pseudoTypes = []; | 387 var pseudoTypes = []; |
380 var keys = new Set(matchedStyles.pseudoStyles().keys()); | 388 var keys = new Set(matchedStyles.pseudoStyles().keys()); |
381 if (keys.delete(DOMAgent.PseudoType.Before)) | 389 if (keys.delete(DOMAgent.PseudoType.Before)) |
382 pseudoTypes.push(DOMAgent.PseudoType.Before); | 390 pseudoTypes.push(DOMAgent.PseudoType.Before); |
383 pseudoTypes = pseudoTypes.concat(keys.valuesArray().sort()); | 391 pseudoTypes = pseudoTypes.concat(keys.valuesArray().sort()); |
384 for (var pseudoType of pseudoTypes) { | 392 for (var pseudoType of pseudoTypes) { |
385 var block = WebInspector.SectionBlock.createPseudoTypeBlock(pseudoTy pe); | 393 var block = WebInspector.SectionBlock.createPseudoTypeBlock(pseudoTy pe); |
386 var styles = /** @type {!Array<!WebInspector.CSSStyleDeclaration>} * /(matchedStyles.pseudoStyles().get(pseudoType)); | 394 var styles = /** @type {!Array<!WebInspector.CSSStyleDeclaration>} * /(matchedStyles.pseudoStyles().get(pseudoType)); |
387 for (var style of styles) { | 395 for (var style of styles) { |
388 var section = new WebInspector.StylePropertiesSection(this, matc hedStyles, style); | 396 var section = new WebInspector.StylePropertiesSection(this, matc hedStyles, style); |
389 block.sections.push(section); | 397 block.sections.push(section); |
390 } | 398 } |
391 this._sectionBlocks.push(block); | 399 this._sectionBlocks.push(block); |
392 } | 400 } |
393 | 401 |
402 if (keyframesRules) { | |
403 for (var keyframesRule of keyframesRules) { | |
404 var block = WebInspector.SectionBlock.createKeyframesBlock(keyfr amesRule.name().text); | |
405 for (var keyframe of keyframesRule.keyframes()) | |
406 block.sections.push(new WebInspector.KeyframePropertiesSecti on(this, keyframe.style)); | |
407 this._sectionBlocks.push(block); | |
408 } | |
409 } | |
410 | |
394 for (var block of this._sectionBlocks) { | 411 for (var block of this._sectionBlocks) { |
395 var titleElement = block.titleElement(); | 412 var titleElement = block.titleElement(); |
396 if (titleElement) | 413 if (titleElement) |
397 this._sectionsContainer.appendChild(titleElement); | 414 this._sectionsContainer.appendChild(titleElement); |
398 for (var section of block.sections) | 415 for (var section of block.sections) |
399 this._sectionsContainer.appendChild(section.element); | 416 this._sectionsContainer.appendChild(section.element); |
400 } | 417 } |
401 | 418 |
402 if (this._filterRegex) | 419 if (this._filterRegex) |
403 this._updateFilter(); | 420 this._updateFilter(); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
671 */ | 688 */ |
672 WebInspector.SectionBlock.createPseudoTypeBlock = function(pseudoType) | 689 WebInspector.SectionBlock.createPseudoTypeBlock = function(pseudoType) |
673 { | 690 { |
674 var separatorElement = createElement("div"); | 691 var separatorElement = createElement("div"); |
675 separatorElement.className = "sidebar-separator"; | 692 separatorElement.className = "sidebar-separator"; |
676 separatorElement.textContent = WebInspector.UIString("Pseudo ::%s element", pseudoType); | 693 separatorElement.textContent = WebInspector.UIString("Pseudo ::%s element", pseudoType); |
677 return new WebInspector.SectionBlock(separatorElement); | 694 return new WebInspector.SectionBlock(separatorElement); |
678 } | 695 } |
679 | 696 |
680 /** | 697 /** |
698 * @param {string} keyframesName | |
699 * @return {!WebInspector.SectionBlock} | |
700 */ | |
701 WebInspector.SectionBlock.createKeyframesBlock = function(keyframesName) | |
702 { | |
703 var separatorElement = createElement("div"); | |
704 separatorElement.className = "sidebar-separator"; | |
705 separatorElement.textContent = WebInspector.UIString("@keyframes " + keyfram esName); | |
706 return new WebInspector.SectionBlock(separatorElement); | |
707 } | |
708 | |
709 /** | |
681 * @param {!WebInspector.DOMNode} node | 710 * @param {!WebInspector.DOMNode} node |
682 * @return {!WebInspector.SectionBlock} | 711 * @return {!WebInspector.SectionBlock} |
683 */ | 712 */ |
684 WebInspector.SectionBlock.createInheritedNodeBlock = function(node) | 713 WebInspector.SectionBlock.createInheritedNodeBlock = function(node) |
685 { | 714 { |
686 var separatorElement = createElement("div"); | 715 var separatorElement = createElement("div"); |
687 separatorElement.className = "sidebar-separator"; | 716 separatorElement.className = "sidebar-separator"; |
688 var link = WebInspector.DOMPresentationUtils.linkifyNodeReference(node); | 717 var link = WebInspector.DOMPresentationUtils.linkifyNodeReference(node); |
689 separatorElement.createTextChild(WebInspector.UIString("Inherited from") + " "); | 718 separatorElement.createTextChild(WebInspector.UIString("Inherited from") + " "); |
690 separatorElement.appendChild(link); | 719 separatorElement.appendChild(link); |
(...skipping 15 matching lines...) Expand all Loading... | |
706 */ | 735 */ |
707 titleElement: function() | 736 titleElement: function() |
708 { | 737 { |
709 return this._titleElement; | 738 return this._titleElement; |
710 } | 739 } |
711 } | 740 } |
712 | 741 |
713 /** | 742 /** |
714 * @constructor | 743 * @constructor |
715 * @param {!WebInspector.StylesSidebarPane} parentPane | 744 * @param {!WebInspector.StylesSidebarPane} parentPane |
716 * @param {!WebInspector.CSSStyleModel.MatchedStyleResult} matchedStyles | 745 * @param {?WebInspector.CSSStyleModel.MatchedStyleResult} matchedStyles |
lushnikov
2016/01/13 01:42:18
can we keep matchedStyles non-nullable? You can ma
samli
2016/01/13 04:59:36
I just tried this and think it's semantically wron
| |
717 * @param {!WebInspector.CSSStyleDeclaration} style | 746 * @param {!WebInspector.CSSStyleDeclaration} style |
718 */ | 747 */ |
719 WebInspector.StylePropertiesSection = function(parentPane, matchedStyles, style) | 748 WebInspector.StylePropertiesSection = function(parentPane, matchedStyles, style) |
720 { | 749 { |
721 this._parentPane = parentPane; | 750 this._parentPane = parentPane; |
722 this._style = style; | 751 this._style = style; |
723 this._matchedStyles = matchedStyles; | 752 this._matchedStyles = matchedStyles; |
724 this.editable = !!(style.styleSheetId && style.range); | 753 this.editable = !!(style.styleSheetId && style.range); |
725 | 754 |
726 var rule = style.parentRule; | 755 var rule = style.parentRule; |
727 this.element = createElementWithClass("div", "styles-section matched-styles monospace"); | 756 this.element = createElementWithClass("div", "styles-section matched-styles monospace"); |
728 this.element._section = this; | 757 this.element._section = this; |
729 | 758 |
730 this._titleElement = this.element.createChild("div", "styles-section-title " + (rule ? "styles-selector" : "")); | 759 this._titleElement = this.element.createChild("div", "styles-section-title " + (rule ? "styles-selector" : "")); |
731 | 760 |
732 this.propertiesTreeOutline = new TreeOutline(); | 761 this.propertiesTreeOutline = new TreeOutline(); |
733 this.propertiesTreeOutline.element.classList.add("style-properties", "monosp ace"); | 762 this.propertiesTreeOutline.element.classList.add("style-properties", "monosp ace"); |
734 this.propertiesTreeOutline.section = this; | 763 this.propertiesTreeOutline.section = this; |
735 this.element.appendChild(this.propertiesTreeOutline.element); | 764 this.element.appendChild(this.propertiesTreeOutline.element); |
736 | 765 |
766 // TODO(samli): Rename selector to header text. | |
737 var selectorContainer = createElement("div"); | 767 var selectorContainer = createElement("div"); |
738 this._selectorElement = createElementWithClass("span", "selector"); | 768 this._selectorElement = createElementWithClass("span", "selector"); |
739 this._selectorElement.textContent = this._selectorText(); | 769 this._selectorElement.textContent = this._selectorText(); |
740 selectorContainer.appendChild(this._selectorElement); | 770 selectorContainer.appendChild(this._selectorElement); |
741 this._selectorElement.addEventListener("mouseenter", this._onMouseEnterSelec tor.bind(this), false); | 771 this._selectorElement.addEventListener("mouseenter", this._onMouseEnterSelec tor.bind(this), false); |
742 this._selectorElement.addEventListener("mouseleave", this._onMouseOutSelecto r.bind(this), false); | 772 this._selectorElement.addEventListener("mouseleave", this._onMouseOutSelecto r.bind(this), false); |
743 | 773 |
744 var openBrace = createElement("span"); | 774 var openBrace = createElement("span"); |
745 openBrace.textContent = " {"; | 775 openBrace.textContent = " {"; |
746 selectorContainer.appendChild(openBrace); | 776 selectorContainer.appendChild(openBrace); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 | 886 |
857 _onMouseEnterSelector: function() | 887 _onMouseEnterSelector: function() |
858 { | 888 { |
859 if (this._hoverTimer) | 889 if (this._hoverTimer) |
860 clearTimeout(this._hoverTimer); | 890 clearTimeout(this._hoverTimer); |
861 this._hoverTimer = setTimeout(this._highlight.bind(this), 300); | 891 this._hoverTimer = setTimeout(this._highlight.bind(this), 300); |
862 }, | 892 }, |
863 | 893 |
864 _highlight: function() | 894 _highlight: function() |
865 { | 895 { |
866 WebInspector.DOMModel.hideDOMNodeHighlight() | 896 WebInspector.DOMModel.hideDOMNodeHighlight(); |
867 var node = this._parentPane.node(); | 897 var node = this._parentPane.node(); |
868 var domModel = node.domModel(); | 898 var domModel = node.domModel(); |
869 var selectors = this._style.parentRule ? this._style.parentRule.selector Text() : undefined; | 899 var selectors = this._style.parentRule ? this._style.parentRule.selector Text() : undefined; |
870 domModel.highlightDOMNodeWithConfig(node.id, { mode: "all", showInfo: un defined, selectors: selectors }); | 900 domModel.highlightDOMNodeWithConfig(node.id, { mode: "all", showInfo: un defined, selectors: selectors }); |
871 }, | 901 }, |
872 | 902 |
873 /** | 903 /** |
874 * @return {?WebInspector.StylePropertiesSection} | 904 * @return {?WebInspector.StylePropertiesSection} |
875 */ | 905 */ |
876 firstSibling: function() | 906 firstSibling: function() |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1046 this._mediaListElement.removeChildren(); | 1076 this._mediaListElement.removeChildren(); |
1047 this._createMediaList(this._style.parentRule ? this._style.parentRule.me dia : null); | 1077 this._createMediaList(this._style.parentRule ? this._style.parentRule.me dia : null); |
1048 }, | 1078 }, |
1049 | 1079 |
1050 /** | 1080 /** |
1051 * @param {string} propertyName | 1081 * @param {string} propertyName |
1052 * @return {boolean} | 1082 * @return {boolean} |
1053 */ | 1083 */ |
1054 isPropertyInherited: function(propertyName) | 1084 isPropertyInherited: function(propertyName) |
1055 { | 1085 { |
1056 if (this._matchedStyles.isInherited(this._style)) { | 1086 if (this._matchedStyles && this._matchedStyles.isInherited(this._style)) { |
1057 // While rendering inherited stylesheet, reverse meaning of this pro perty. | 1087 // While rendering inherited stylesheet, reverse meaning of this pro perty. |
1058 // Render truly inherited properties with black, i.e. return them as non-inherited. | 1088 // Render truly inherited properties with black, i.e. return them as non-inherited. |
1059 return !WebInspector.CSSMetadata.isPropertyInherited(propertyName); | 1089 return !WebInspector.CSSMetadata.isPropertyInherited(propertyName); |
1060 } | 1090 } |
1061 return false; | 1091 return false; |
1062 }, | 1092 }, |
1063 | 1093 |
1064 /** | 1094 /** |
1065 * @return {?WebInspector.StylePropertiesSection} | 1095 * @return {?WebInspector.StylePropertiesSection} |
1066 */ | 1096 */ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1105 update: function(full) | 1135 update: function(full) |
1106 { | 1136 { |
1107 this._selectorElement.textContent = this._selectorText(); | 1137 this._selectorElement.textContent = this._selectorText(); |
1108 this._markSelectorMatches(); | 1138 this._markSelectorMatches(); |
1109 if (full) { | 1139 if (full) { |
1110 this.propertiesTreeOutline.removeChildren(); | 1140 this.propertiesTreeOutline.removeChildren(); |
1111 this.onpopulate(); | 1141 this.onpopulate(); |
1112 } else { | 1142 } else { |
1113 var child = this.propertiesTreeOutline.firstChild(); | 1143 var child = this.propertiesTreeOutline.firstChild(); |
1114 while (child) { | 1144 while (child) { |
1115 var overloaded = this._matchedStyles.propertyState(child.propert y) === WebInspector.CSSStyleModel.MatchedStyleResult.PropertyState.Overloaded; | 1145 child.setOverloaded(this._isPropertyOverloaded(child.property)); |
1116 child.setOverloaded(overloaded); | |
1117 child = child.traverseNextTreeElement(false, null, true); | 1146 child = child.traverseNextTreeElement(false, null, true); |
1118 } | 1147 } |
1119 } | 1148 } |
1120 this.afterUpdate(); | 1149 this.afterUpdate(); |
1121 }, | 1150 }, |
1122 | 1151 |
1123 afterUpdate: function() | 1152 afterUpdate: function() |
1124 { | 1153 { |
1125 if (this._afterUpdate) { | 1154 if (this._afterUpdate) { |
1126 this._afterUpdate(this); | 1155 this._afterUpdate(this); |
1127 delete this._afterUpdate; | 1156 delete this._afterUpdate; |
1128 this._afterUpdateFinishedForTest(); | 1157 this._afterUpdateFinishedForTest(); |
1129 } | 1158 } |
1130 }, | 1159 }, |
1131 | 1160 |
1132 _afterUpdateFinishedForTest: function() | 1161 _afterUpdateFinishedForTest: function() |
1133 { | 1162 { |
1134 }, | 1163 }, |
1135 | 1164 |
1136 onpopulate: function() | 1165 onpopulate: function() |
1137 { | 1166 { |
1138 var style = this._style; | 1167 var style = this._style; |
1139 for (var property of style.leadingProperties()) { | 1168 for (var property of style.leadingProperties()) { |
1140 var isShorthand = !!WebInspector.CSSMetadata.cssPropertiesMetainfo.l onghands(property.name); | 1169 var isShorthand = !!WebInspector.CSSMetadata.cssPropertiesMetainfo.l onghands(property.name); |
1141 var inherited = this.isPropertyInherited(property.name); | 1170 var inherited = this.isPropertyInherited(property.name); |
1142 var overloaded = this._matchedStyles.propertyState(property) === Web Inspector.CSSStyleModel.MatchedStyleResult.PropertyState.Overloaded; | 1171 var overloaded = this._isPropertyOverloaded(property); |
1143 var item = new WebInspector.StylePropertyTreeElement(this._parentPan e, this._matchedStyles, property, isShorthand, inherited, overloaded); | 1172 var item = new WebInspector.StylePropertyTreeElement(this._parentPan e, this._matchedStyles, property, isShorthand, inherited, overloaded); |
1144 this.propertiesTreeOutline.appendChild(item); | 1173 this.propertiesTreeOutline.appendChild(item); |
1145 } | 1174 } |
1146 }, | 1175 }, |
1147 | 1176 |
1148 /** | 1177 /** |
1178 * @param {!WebInspector.CSSProperty} property | |
1179 * @return {boolean} | |
1180 */ | |
1181 _isPropertyOverloaded: function(property) | |
lushnikov
2016/01/13 01:42:18
you can avoid doing this if matchedStyles will be
samli
2016/01/13 04:59:36
Ack, see above comment.
| |
1182 { | |
1183 return !!this._matchedStyles && this._matchedStyles.propertyState(proper ty) === WebInspector.CSSStyleModel.MatchedStyleResult.PropertyState.Overloaded; | |
1184 }, | |
1185 | |
1186 /** | |
1149 * @return {boolean} | 1187 * @return {boolean} |
1150 */ | 1188 */ |
1151 _updateFilter: function() | 1189 _updateFilter: function() |
1152 { | 1190 { |
1153 var hasMatchingChild = false; | 1191 var hasMatchingChild = false; |
1154 for (var child of this.propertiesTreeOutline.rootElement().children()) | 1192 for (var child of this.propertiesTreeOutline.rootElement().children()) |
1155 hasMatchingChild |= child._updateFilter(); | 1193 hasMatchingChild |= child._updateFilter(); |
1156 | 1194 |
1157 var regex = this._parentPane.filterRegex(); | 1195 var regex = this._parentPane.filterRegex(); |
1158 var hideRule = !hasMatchingChild && regex && !regex.test(this.element.te xtContent); | 1196 var hideRule = !hasMatchingChild && regex && !regex.test(this.element.te xtContent); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1546 * @param {!WebInspector.Linkifier} linkifier | 1584 * @param {!WebInspector.Linkifier} linkifier |
1547 * @param {?WebInspector.CSSRule} rule | 1585 * @param {?WebInspector.CSSRule} rule |
1548 * @return {!Node} | 1586 * @return {!Node} |
1549 */ | 1587 */ |
1550 WebInspector.StylePropertiesSection.createRuleOriginNode = function(cssModel, li nkifier, rule) | 1588 WebInspector.StylePropertiesSection.createRuleOriginNode = function(cssModel, li nkifier, rule) |
1551 { | 1589 { |
1552 if (!rule) | 1590 if (!rule) |
1553 return createTextNode(""); | 1591 return createTextNode(""); |
1554 | 1592 |
1555 var firstMatchingIndex = rule.matchingSelectors && rule.matchingSelectors.le ngth ? rule.matchingSelectors[0] : 0; | 1593 var firstMatchingIndex = rule.matchingSelectors && rule.matchingSelectors.le ngth ? rule.matchingSelectors[0] : 0; |
1556 var ruleLocation = rule.selectors[firstMatchingIndex].range; | 1594 var ruleLocation; |
1595 if (rule instanceof WebInspector.CSSStyleRule) | |
1596 ruleLocation = rule.selectors[firstMatchingIndex].range; | |
1597 else if (rule instanceof WebInspector.CSSKeyframeRule) | |
1598 ruleLocation = rule.key().range; | |
1557 | 1599 |
1558 var header = rule.styleSheetId ? cssModel.styleSheetHeaderForId(rule.styleSh eetId) : null; | 1600 var header = rule.styleSheetId ? cssModel.styleSheetHeaderForId(rule.styleSh eetId) : null; |
1559 if (ruleLocation && rule.styleSheetId && header && header.resourceURL()) | 1601 if (ruleLocation && rule.styleSheetId && header && header.resourceURL()) |
1560 return WebInspector.StylePropertiesSection._linkifyRuleLocation(cssModel , linkifier, rule.styleSheetId, ruleLocation); | 1602 return WebInspector.StylePropertiesSection._linkifyRuleLocation(cssModel , linkifier, rule.styleSheetId, ruleLocation); |
1561 | 1603 |
1562 if (rule.isUserAgent()) | 1604 if (rule.isUserAgent()) |
1563 return createTextNode(WebInspector.UIString("user agent stylesheet")); | 1605 return createTextNode(WebInspector.UIString("user agent stylesheet")); |
1564 if (rule.isInjected()) | 1606 if (rule.isInjected()) |
1565 return createTextNode(WebInspector.UIString("injected stylesheet")); | 1607 return createTextNode(WebInspector.UIString("injected stylesheet")); |
1566 if (rule.isViaInspector()) | 1608 if (rule.isViaInspector()) |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1721 this._style = newRule.style; | 1763 this._style = newRule.style; |
1722 // FIXME: replace this instance by a normal WebInspector.StyleProperties Section. | 1764 // FIXME: replace this instance by a normal WebInspector.StyleProperties Section. |
1723 this._normal = true; | 1765 this._normal = true; |
1724 }, | 1766 }, |
1725 | 1767 |
1726 __proto__: WebInspector.StylePropertiesSection.prototype | 1768 __proto__: WebInspector.StylePropertiesSection.prototype |
1727 } | 1769 } |
1728 | 1770 |
1729 /** | 1771 /** |
1730 * @constructor | 1772 * @constructor |
1773 * @extends {WebInspector.StylePropertiesSection} | |
1774 * @param {!WebInspector.StylesSidebarPane} stylesPane | |
1775 * @param {!WebInspector.CSSStyleDeclaration} style | |
1776 */ | |
1777 WebInspector.KeyframePropertiesSection = function(stylesPane, style) | |
1778 { | |
1779 WebInspector.StylePropertiesSection.call(this, stylesPane, null, style); | |
1780 this._selectorElement.className = "keyframe-key"; | |
1781 } | |
1782 | |
1783 WebInspector.KeyframePropertiesSection.prototype = { | |
1784 /** | |
1785 * @override | |
1786 * @return {string} | |
1787 */ | |
1788 _selectorText: function() | |
1789 { | |
1790 return this._style.parentRule.key().text; | |
1791 }, | |
1792 | |
1793 /** | |
1794 * @override | |
1795 * @param {!Element} element | |
1796 * @param {string} newContent | |
1797 * @param {string} oldContent | |
1798 * @param {!WebInspector.StylePropertyTreeElement.Context|undefined} context | |
1799 * @param {string} moveDirection | |
1800 */ | |
1801 editingSelectorCommitted: function(element, newContent, oldContent, context, moveDirection) | |
1802 { | |
1803 this._editingSelectorEnded(); | |
1804 if (newContent) | |
1805 newContent = newContent.trim(); | |
1806 if (newContent === oldContent) { | |
1807 // Revert to a trimmed version of the selector if need be. | |
1808 this._selectorElement.textContent = newContent; | |
1809 this._moveEditorFromSelector(moveDirection); | |
1810 return; | |
1811 } | |
1812 var rule = this._style.parentRule; | |
1813 var oldRange = rule.key().range; | |
1814 if (!rule || !oldRange) | |
1815 return; | |
1816 | |
1817 /** | |
1818 * @param {!WebInspector.CSSRule} rule | |
1819 * @param {!WebInspector.TextRange} oldRange | |
1820 * @param {boolean} success | |
1821 * @this {WebInspector.StylePropertiesSection} | |
1822 */ | |
1823 function finishCallback(rule, oldRange, success) | |
1824 { | |
1825 if (success) { | |
1826 var newRange = /** @type {!WebInspector.TextRange} */(rule.key() .range); | |
1827 rule.style.sourceStyleSheetEdited(/** @type {string} */(rule.sty leSheetId), oldRange, newRange); | |
1828 this._parentPane._styleSheetRuleEdited(rule, oldRange, newRange) ; | |
1829 this._parentPane._refreshUpdate(this); | |
1830 } | |
1831 | |
1832 delete this._parentPane._userOperation; | |
1833 this._moveEditorFromSelector(moveDirection); | |
1834 this._editingSelectorCommittedForTest(); | |
1835 } | |
1836 | |
1837 // This gets deleted in finishOperationAndMoveEditor(), which is called both on success and failure. | |
1838 this._parentPane._userOperation = true; | |
1839 var selectedNode = this._parentPane.node(); | |
1840 rule.setKeyText(newContent, finishCallback.bind(this, rule, oldRange)); | |
1841 }, | |
1842 | |
1843 /** | |
1844 * @override | |
1845 */ | |
1846 _markSelectorHighlights: function() | |
1847 { | |
1848 }, | |
1849 | |
1850 /** | |
1851 * @override | |
1852 */ | |
1853 _markSelectorMatches: function() | |
1854 { | |
1855 this._selectorElement.textContent = this._style.parentRule.key().text; | |
1856 }, | |
1857 | |
1858 /** | |
1859 * @override | |
1860 */ | |
1861 _highlight: function() | |
1862 { | |
1863 }, | |
1864 | |
1865 __proto__: WebInspector.StylePropertiesSection.prototype | |
1866 } | |
1867 | |
1868 /** | |
1869 * @constructor | |
1731 * @extends {TreeElement} | 1870 * @extends {TreeElement} |
1732 * @param {!WebInspector.StylesSidebarPane} stylesPane | 1871 * @param {!WebInspector.StylesSidebarPane} stylesPane |
1733 * @param {!WebInspector.CSSStyleModel.MatchedStyleResult} matchedStyles | 1872 * @param {?WebInspector.CSSStyleModel.MatchedStyleResult} matchedStyles |
1734 * @param {!WebInspector.CSSProperty} property | 1873 * @param {!WebInspector.CSSProperty} property |
1735 * @param {boolean} isShorthand | 1874 * @param {boolean} isShorthand |
1736 * @param {boolean} inherited | 1875 * @param {boolean} inherited |
1737 * @param {boolean} overloaded | 1876 * @param {boolean} overloaded |
1738 */ | 1877 */ |
1739 WebInspector.StylePropertyTreeElement = function(stylesPane, matchedStyles, prop erty, isShorthand, inherited, overloaded) | 1878 WebInspector.StylePropertyTreeElement = function(stylesPane, matchedStyles, prop erty, isShorthand, inherited, overloaded) |
1740 { | 1879 { |
1741 // Pass an empty title, the title gets made later in onattach. | 1880 // Pass an empty title, the title gets made later in onattach. |
1742 TreeElement.call(this, "", isShorthand); | 1881 TreeElement.call(this, "", isShorthand); |
1743 this._style = property.ownerStyle; | 1882 this._style = property.ownerStyle; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1966 if (section && section._parentPane) | 2105 if (section && section._parentPane) |
1967 section._parentPane._refreshUpdate(section); | 2106 section._parentPane._refreshUpdate(section); |
1968 }, | 2107 }, |
1969 | 2108 |
1970 /** | 2109 /** |
1971 * @param {!WebInspector.TextRange} oldStyleRange | 2110 * @param {!WebInspector.TextRange} oldStyleRange |
1972 */ | 2111 */ |
1973 _styleTextEdited: function(oldStyleRange) | 2112 _styleTextEdited: function(oldStyleRange) |
1974 { | 2113 { |
1975 var newStyleRange = /** @type {!WebInspector.TextRange} */ (this._style. range); | 2114 var newStyleRange = /** @type {!WebInspector.TextRange} */ (this._style. range); |
1976 this._matchedStyles.resetActiveProperties(); | 2115 if (this._matchedStyles) |
2116 this._matchedStyles.resetActiveProperties(); | |
1977 if (this._style.parentRule) | 2117 if (this._style.parentRule) |
1978 this._parentPane._styleSheetRuleEdited(this._style.parentRule, oldSt yleRange, newStyleRange); | 2118 this._parentPane._styleSheetRuleEdited(this._style.parentRule, oldSt yleRange, newStyleRange); |
1979 }, | 2119 }, |
1980 | 2120 |
1981 /** | 2121 /** |
1982 * @param {!Event} event | 2122 * @param {!Event} event |
1983 */ | 2123 */ |
1984 _toggleEnabled: function(event) | 2124 _toggleEnabled: function(event) |
1985 { | 2125 { |
1986 var disabled = !event.target.checked; | 2126 var disabled = !event.target.checked; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2020 | 2160 |
2021 var longhandProperties = this._style.longhandProperties(this.name); | 2161 var longhandProperties = this._style.longhandProperties(this.name); |
2022 for (var i = 0; i < longhandProperties.length; ++i) { | 2162 for (var i = 0; i < longhandProperties.length; ++i) { |
2023 var name = longhandProperties[i].name; | 2163 var name = longhandProperties[i].name; |
2024 var inherited = false; | 2164 var inherited = false; |
2025 var overloaded = false; | 2165 var overloaded = false; |
2026 | 2166 |
2027 var section = this.section(); | 2167 var section = this.section(); |
2028 if (section) { | 2168 if (section) { |
2029 inherited = section.isPropertyInherited(name); | 2169 inherited = section.isPropertyInherited(name); |
2030 overloaded = this._matchedStyles.propertyState(longhandPropertie s[i]) === WebInspector.CSSStyleModel.MatchedStyleResult.PropertyState.Overloaded ; | 2170 overloaded = this._matchedStyles |
2171 ? this._matchedStyles.propertyState(longhandProperties[i]) = == WebInspector.CSSStyleModel.MatchedStyleResult.PropertyState.Overloaded | |
2172 : false; | |
2031 } | 2173 } |
2032 | 2174 |
2033 var item = new WebInspector.StylePropertyTreeElement(this._parentPan e, this._matchedStyles, longhandProperties[i], false, inherited, overloaded); | 2175 var item = new WebInspector.StylePropertyTreeElement(this._parentPan e, this._matchedStyles, longhandProperties[i], false, inherited, overloaded); |
2034 this.appendChild(item); | 2176 this.appendChild(item); |
2035 } | 2177 } |
2036 }, | 2178 }, |
2037 | 2179 |
2038 /** | 2180 /** |
2039 * @override | 2181 * @override |
2040 */ | 2182 */ |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2960 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, onNodeCha nged); | 3102 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, onNodeCha nged); |
2961 onNodeChanged(); | 3103 onNodeChanged(); |
2962 return button; | 3104 return button; |
2963 | 3105 |
2964 function onNodeChanged() | 3106 function onNodeChanged() |
2965 { | 3107 { |
2966 var node = WebInspector.context.flavor(WebInspector.DOMNode); | 3108 var node = WebInspector.context.flavor(WebInspector.DOMNode); |
2967 button.setEnabled(!!node); | 3109 button.setEnabled(!!node); |
2968 } | 3110 } |
2969 } | 3111 } |
OLD | NEW |