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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 if (value.endsWith("\9")) | 155 if (value.endsWith("\9")) |
156 return true; | 156 return true; |
157 if (hasUnknownVendorPrefix(value)) | 157 if (hasUnknownVendorPrefix(value)) |
158 return true; | 158 return true; |
159 | 159 |
160 return false; | 160 return false; |
161 } | 161 } |
162 | 162 |
163 WebInspector.StylesSidebarPane.prototype = { | 163 WebInspector.StylesSidebarPane.prototype = { |
164 /** | 164 /** |
165 * @param {!WebInspector.CSSRule} editedRule | |
166 * @param {!WebInspector.TextRange} oldRange | |
167 * @param {!WebInspector.TextRange} newRange | |
168 */ | |
169 _styleSheetRuleEdited: function(editedRule, oldRange, newRange) | |
170 { | |
171 var styleRuleSections = this.sections[0]; | |
172 for (var i = 1; i < styleRuleSections.length; ++i) | |
173 styleRuleSections[i]._styleSheetRuleEdited(editedRule, oldRange, new Range); | |
174 }, | |
175 | |
176 /** | |
165 * @param {?Event} event | 177 * @param {?Event} event |
166 */ | 178 */ |
167 _contextMenuEventFired: function(event) | 179 _contextMenuEventFired: function(event) |
168 { | 180 { |
169 // We start editing upon click -> default navigation to resources panel is not available | 181 // We start editing upon click -> default navigation to resources panel is not available |
170 // Hence we add a soft context menu for hrefs. | 182 // Hence we add a soft context menu for hrefs. |
171 var contextMenu = new WebInspector.ContextMenu(event); | 183 var contextMenu = new WebInspector.ContextMenu(event); |
172 contextMenu.appendApplicableItems(/** @type {!Node} */ (event.target)); | 184 contextMenu.appendApplicableItems(/** @type {!Node} */ (event.target)); |
173 contextMenu.show(); | 185 contextMenu.show(); |
174 }, | 186 }, |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 this.styleRule = styleRule; | 1085 this.styleRule = styleRule; |
1074 this.rule = this.styleRule.rule; | 1086 this.rule = this.styleRule.rule; |
1075 this.editable = editable; | 1087 this.editable = editable; |
1076 this.isInherited = isInherited; | 1088 this.isInherited = isInherited; |
1077 | 1089 |
1078 var extraClasses = (this.rule && (this.rule.isUser || this.rule.isUserAgent) ? " user-rule" : ""); | 1090 var extraClasses = (this.rule && (this.rule.isUser || this.rule.isUserAgent) ? " user-rule" : ""); |
1079 this.element.className = "styles-section matched-styles monospace" + extraCl asses; | 1091 this.element.className = "styles-section matched-styles monospace" + extraCl asses; |
1080 // We don't really use properties' disclosure. | 1092 // We don't really use properties' disclosure. |
1081 this.propertiesElement.classList.remove("properties-tree"); | 1093 this.propertiesElement.classList.remove("properties-tree"); |
1082 | 1094 |
1083 if (styleRule.media) { | |
1084 for (var i = styleRule.media.length - 1; i >= 0; --i) { | |
1085 var media = styleRule.media[i]; | |
1086 var mediaDataElement = this.titleElement.createChild("div", "media") ; | |
1087 var mediaText; | |
1088 switch (media.source) { | |
1089 case WebInspector.CSSMedia.Source.LINKED_SHEET: | |
1090 case WebInspector.CSSMedia.Source.INLINE_SHEET: | |
1091 mediaText = "media=\"" + media.text + "\""; | |
1092 break; | |
1093 case WebInspector.CSSMedia.Source.MEDIA_RULE: | |
1094 mediaText = "@media " + media.text; | |
1095 break; | |
1096 case WebInspector.CSSMedia.Source.IMPORT_RULE: | |
1097 mediaText = "@import " + media.text; | |
1098 break; | |
1099 } | |
1100 | |
1101 if (media.sourceURL) { | |
1102 var refElement = mediaDataElement.createChild("div", "subtitle") ; | |
1103 var rawLocation; | |
1104 var mediaHeader; | |
1105 if (media.range) { | |
1106 mediaHeader = media.header(); | |
1107 if (mediaHeader) { | |
1108 var lineNumber = media.lineNumberInSource(); | |
1109 var columnNumber = media.columnNumberInSource(); | |
1110 console.assert(typeof lineNumber !== "undefined" && type of columnNumber !== "undefined"); | |
1111 rawLocation = new WebInspector.CSSLocation(this._parentP ane._target, media.sourceURL, lineNumber, columnNumber); | |
1112 } | |
1113 } | |
1114 | |
1115 var anchor; | |
1116 if (rawLocation) | |
1117 anchor = this._parentPane._linkifier.linkifyCSSLocation(medi aHeader.id, rawLocation); | |
1118 else { | |
1119 // The "linkedStylesheet" case. | |
1120 anchor = WebInspector.linkifyResourceAsNode(media.sourceURL, undefined, "subtitle", media.sourceURL); | |
1121 } | |
1122 anchor.style.float = "right"; | |
1123 refElement.appendChild(anchor); | |
1124 } | |
1125 | |
1126 var mediaTextElement = mediaDataElement.createChild("span"); | |
1127 mediaTextElement.textContent = mediaText; | |
1128 mediaTextElement.title = media.text; | |
1129 } | |
1130 } | |
1131 | |
1132 var selectorContainer = document.createElement("div"); | 1095 var selectorContainer = document.createElement("div"); |
1133 this._selectorElement = document.createElement("span"); | 1096 this._selectorElement = document.createElement("span"); |
1134 this._selectorElement.textContent = styleRule.selectorText; | 1097 this._selectorElement.textContent = styleRule.selectorText; |
1135 selectorContainer.appendChild(this._selectorElement); | 1098 selectorContainer.appendChild(this._selectorElement); |
1136 | 1099 |
1137 var openBrace = document.createElement("span"); | 1100 var openBrace = document.createElement("span"); |
1138 openBrace.textContent = " {"; | 1101 openBrace.textContent = " {"; |
1139 selectorContainer.appendChild(openBrace); | 1102 selectorContainer.appendChild(openBrace); |
1140 selectorContainer.addEventListener("mousedown", this._handleEmptySpaceMouseD own.bind(this), false); | 1103 selectorContainer.addEventListener("mousedown", this._handleEmptySpaceMouseD own.bind(this), false); |
1141 selectorContainer.addEventListener("click", this._handleSelectorContainerCli ck.bind(this), false); | 1104 selectorContainer.addEventListener("click", this._handleSelectorContainerCli ck.bind(this), false); |
(...skipping 15 matching lines...) Expand all Loading... | |
1157 if (this.rule.id) | 1120 if (this.rule.id) |
1158 this.navigable = !!this.rule.resourceURL(); | 1121 this.navigable = !!this.rule.resourceURL(); |
1159 } | 1122 } |
1160 this.titleElement.classList.add("styles-selector"); | 1123 this.titleElement.classList.add("styles-selector"); |
1161 } | 1124 } |
1162 | 1125 |
1163 this._usedProperties = styleRule.usedProperties; | 1126 this._usedProperties = styleRule.usedProperties; |
1164 | 1127 |
1165 this._selectorRefElement = document.createElement("div"); | 1128 this._selectorRefElement = document.createElement("div"); |
1166 this._selectorRefElement.className = "subtitle"; | 1129 this._selectorRefElement.className = "subtitle"; |
1130 this._mediaListElement = this.titleElement.createChild("div", "media-list"); | |
1131 this._updateMediaList(); | |
1167 this._updateRuleOrigin(); | 1132 this._updateRuleOrigin(); |
1168 selectorContainer.insertBefore(this._selectorRefElement, selectorContainer.f irstChild); | 1133 selectorContainer.insertBefore(this._selectorRefElement, selectorContainer.f irstChild); |
1169 this.titleElement.appendChild(selectorContainer); | 1134 this.titleElement.appendChild(selectorContainer); |
1170 this._selectorContainer = selectorContainer; | 1135 this._selectorContainer = selectorContainer; |
1171 | 1136 |
1172 if (isInherited) | 1137 if (isInherited) |
1173 this.element.classList.add("styles-show-inherited"); // This one is rela ted to inherited rules, not computed style. | 1138 this.element.classList.add("styles-show-inherited"); // This one is rela ted to inherited rules, not computed style. |
1174 | 1139 |
1175 if (this.navigable) | 1140 if (this.navigable) |
1176 this.element.classList.add("navigable"); | 1141 this.element.classList.add("navigable"); |
1177 | 1142 |
1178 if (!this.editable) | 1143 if (!this.editable) |
1179 this.element.classList.add("read-only"); | 1144 this.element.classList.add("read-only"); |
1180 } | 1145 } |
1181 | 1146 |
1182 WebInspector.StylePropertiesSection.prototype = { | 1147 WebInspector.StylePropertiesSection.prototype = { |
1148 /** | |
1149 * @param {!WebInspector.CSSRule} editedRule | |
1150 * @param {!WebInspector.TextRange} oldRange | |
1151 * @param {!WebInspector.TextRange} newRange | |
1152 */ | |
1153 _styleSheetRuleEdited: function(editedRule, oldRange, newRange) | |
1154 { | |
1155 if (!this.rule || !this.rule.id) | |
1156 return; | |
1157 if (this.rule !== editedRule) | |
1158 this.rule.sourceStyleSheetEdited(this.rule.id.styleSheetId, oldRange , newRange); | |
1159 this._updateMediaList(); | |
1160 this._updateRuleOrigin(); | |
1161 }, | |
1162 | |
1163 /** | |
1164 * @param {!Object} styleRule | |
1165 */ | |
1166 _createMediaList: function(styleRule) | |
1167 { | |
1168 if (!styleRule.media) | |
1169 return; | |
1170 for (var i = styleRule.media.length - 1; i >= 0; --i) { | |
1171 var media = styleRule.media[i]; | |
1172 var mediaDataElement = this._mediaListElement.createChild("div", "me dia"); | |
1173 var mediaText; | |
1174 switch (media.source) { | |
1175 case WebInspector.CSSMedia.Source.LINKED_SHEET: | |
1176 case WebInspector.CSSMedia.Source.INLINE_SHEET: | |
1177 mediaText = "media=\"" + media.text + "\""; | |
1178 break; | |
1179 case WebInspector.CSSMedia.Source.MEDIA_RULE: | |
1180 mediaText = "@media " + media.text; | |
1181 break; | |
1182 case WebInspector.CSSMedia.Source.IMPORT_RULE: | |
1183 mediaText = "@import " + media.text; | |
1184 break; | |
1185 } | |
1186 | |
1187 if (media.sourceURL) { | |
1188 var refElement = mediaDataElement.createChild("div", "subtitle") ; | |
1189 var rawLocation; | |
1190 var mediaHeader; | |
1191 if (media.range) { | |
1192 mediaHeader = media.header(); | |
1193 if (mediaHeader) { | |
1194 var lineNumber = media.lineNumberInSource(); | |
1195 var columnNumber = media.columnNumberInSource(); | |
1196 console.assert(typeof lineNumber !== "undefined" && type of columnNumber !== "undefined"); | |
1197 rawLocation = new WebInspector.CSSLocation(this._parentP ane._target, media.sourceURL, lineNumber, columnNumber); | |
1198 } | |
1199 } | |
1200 | |
1201 var anchor; | |
1202 if (rawLocation) | |
1203 anchor = this._parentPane._linkifier.linkifyCSSLocation(medi aHeader.id, rawLocation); | |
1204 else { | |
1205 // The "linkedStylesheet" case. | |
1206 anchor = WebInspector.linkifyResourceAsNode(media.sourceURL, undefined, "subtitle", media.sourceURL); | |
1207 } | |
1208 anchor.style.float = "right"; | |
1209 refElement.appendChild(anchor); | |
1210 } | |
1211 | |
1212 var mediaTextElement = mediaDataElement.createChild("span"); | |
1213 mediaTextElement.textContent = mediaText; | |
1214 mediaTextElement.title = media.text; | |
1215 } | |
1216 }, | |
1217 | |
1218 _updateMediaList: function() | |
1219 { | |
1220 this._mediaListElement.removeChildren(); | |
1221 this._createMediaList(this.styleRule); | |
1222 }, | |
1223 | |
1183 collapse: function() | 1224 collapse: function() |
1184 { | 1225 { |
1185 // Overriding with empty body. | 1226 // Overriding with empty body. |
1186 }, | 1227 }, |
1187 | 1228 |
1188 handleClick: function() | 1229 handleClick: function() |
1189 { | 1230 { |
1190 // Avoid consuming events. | 1231 // Avoid consuming events. |
1191 }, | 1232 }, |
1192 | 1233 |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1615 { | 1656 { |
1616 var doesAffectSelectedNode = newRule.matchingSelectors.length > 0; | 1657 var doesAffectSelectedNode = newRule.matchingSelectors.length > 0; |
1617 if (!doesAffectSelectedNode) { | 1658 if (!doesAffectSelectedNode) { |
1618 this.noAffect = true; | 1659 this.noAffect = true; |
1619 this.element.classList.add("no-affect"); | 1660 this.element.classList.add("no-affect"); |
1620 } else { | 1661 } else { |
1621 delete this.noAffect; | 1662 delete this.noAffect; |
1622 this.element.classList.remove("no-affect"); | 1663 this.element.classList.remove("no-affect"); |
1623 } | 1664 } |
1624 | 1665 |
1666 var oldSelectorRange = this.rule.selectorRange; | |
1625 this.rule = newRule; | 1667 this.rule = newRule; |
1626 this.styleRule = { section: this, style: newRule.style, selectorText : newRule.selectorText, media: newRule.media, sourceURL: newRule.resourceURL(), rule: newRule }; | 1668 this.styleRule = { section: this, style: newRule.style, selectorText : newRule.selectorText, media: newRule.media, sourceURL: newRule.resourceURL(), rule: newRule }; |
1627 | 1669 |
1628 this._parentPane.update(selectedNode); | 1670 this._parentPane.update(selectedNode); |
1629 this._updateRuleOrigin(); | 1671 this._parentPane._styleSheetRuleEdited(this.rule, oldSelectorRange, this.rule.selectorRange); |
1630 | 1672 |
1631 finishOperationAndMoveEditor.call(this, moveDirection); | 1673 finishOperationAndMoveEditor.call(this, moveDirection); |
1632 } | 1674 } |
1633 | 1675 |
1634 /** | 1676 /** |
1635 * @this {WebInspector.StylePropertiesSection} | 1677 * @this {WebInspector.StylePropertiesSection} |
1636 */ | 1678 */ |
1637 function finishOperationAndMoveEditor(direction) | 1679 function finishOperationAndMoveEditor(direction) |
1638 { | 1680 { |
1639 delete this._parentPane._userOperation; | 1681 delete this._parentPane._userOperation; |
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3086 // It did not apply, cancel editing. | 3128 // It did not apply, cancel editing. |
3087 this._revertStyleUponEditingCanceled(originalPropertyText); | 3129 this._revertStyleUponEditingCanceled(originalPropertyText); |
3088 } | 3130 } |
3089 userCallback(); | 3131 userCallback(); |
3090 return; | 3132 return; |
3091 } | 3133 } |
3092 | 3134 |
3093 if (this._newProperty) | 3135 if (this._newProperty) |
3094 this._newPropertyInStyle = true; | 3136 this._newPropertyInStyle = true; |
3095 newStyle.parentRule = this.style.parentRule; | 3137 newStyle.parentRule = this.style.parentRule; |
3138 var oldStyleRange = /** @type {!WebInspector.TextRange} */ (this.sty le.range); | |
3139 var newStyleRange = /** @type {!WebInspector.TextRange} */ (newStyle .range); | |
3096 this.style = newStyle; | 3140 this.style = newStyle; |
3097 this.property = newStyle.propertyAt(this.property.index); | 3141 this.property = newStyle.propertyAt(this.property.index); |
3098 this._styleRule.style = this.style; | 3142 this._styleRule.style = this.style; |
3143 if (this.style.parentRule) | |
3144 this.style.parentRule.style = this.style; | |
3099 | 3145 |
3100 if (section && section._parentPane) | 3146 if (section && section._parentPane) |
3101 section._parentPane.dispatchEventToListeners("style edited"); | 3147 section._parentPane.dispatchEventToListeners("style edited"); |
3148 this._parentPane._styleSheetRuleEdited(this.style.parentRule, oldSty leRange, newStyleRange); | |
apavlov
2014/04/02 15:23:57
check this.style.parentRule
lushnikov
2014/04/02 15:35:04
Done.
| |
3102 | 3149 |
3103 if (updateInterface && currentNode === this.node()) { | 3150 if (updateInterface && currentNode === this.node()) { |
3104 this._updatePane(userCallback); | 3151 this._updatePane(userCallback); |
3105 return; | 3152 return; |
3106 } | 3153 } |
3107 | 3154 |
3108 userCallback(); | 3155 userCallback(); |
3109 } | 3156 } |
3110 | 3157 |
3111 // Append a ";" if the new text does not end in ";". | 3158 // Append a ";" if the new text does not end in ";". |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3255 return; | 3302 return; |
3256 } | 3303 } |
3257 | 3304 |
3258 var results = this._cssCompletions.startsWith(prefix); | 3305 var results = this._cssCompletions.startsWith(prefix); |
3259 var selectedIndex = this._cssCompletions.mostUsedOf(results); | 3306 var selectedIndex = this._cssCompletions.mostUsedOf(results); |
3260 completionsReadyCallback(results, selectedIndex); | 3307 completionsReadyCallback(results, selectedIndex); |
3261 }, | 3308 }, |
3262 | 3309 |
3263 __proto__: WebInspector.TextPrompt.prototype | 3310 __proto__: WebInspector.TextPrompt.prototype |
3264 } | 3311 } |
OLD | NEW |