| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 var self = this; | 109 var self = this; |
| 110 function callback(styles) | 110 function callback(styles) |
| 111 { | 111 { |
| 112 if (!styles) | 112 if (!styles) |
| 113 return; | 113 return; |
| 114 node._setStyles(styles.computedStyle, styles.inlineStyle, styles.sty
leAttributes, styles.matchedCSSRules); | 114 node._setStyles(styles.computedStyle, styles.inlineStyle, styles.sty
leAttributes, styles.matchedCSSRules); |
| 115 self._update(refresh, body, node, editedSection, forceUpdate); | 115 self._update(refresh, body, node, editedSection, forceUpdate); |
| 116 } | 116 } |
| 117 | 117 |
| 118 InjectedScriptAccess.getStyles(node.id, !WebInspector.settings.showUserA
gentStyles, callback); | 118 InjectedScriptAccess.get(node.injectedScriptId).getStyles(node.id, !WebI
nspector.settings.showUserAgentStyles, callback); |
| 119 }, | 119 }, |
| 120 | 120 |
| 121 _update: function(refresh, body, node, editedSection, forceUpdate) | 121 _update: function(refresh, body, node, editedSection, forceUpdate) |
| 122 { | 122 { |
| 123 if (!refresh) { | 123 if (!refresh) { |
| 124 body.removeChildren(); | 124 body.removeChildren(); |
| 125 this.sections = []; | 125 this.sections = []; |
| 126 } | 126 } |
| 127 | 127 |
| 128 var styleRules = []; | 128 var styleRules = []; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 var oldIdentifier = this.identifier; | 685 var oldIdentifier = this.identifier; |
| 686 self.identifier = newRule.selectorText + ":" + self.subtitleElement.
textContent; | 686 self.identifier = newRule.selectorText + ":" + self.subtitleElement.
textContent; |
| 687 | 687 |
| 688 self.pane.update(); | 688 self.pane.update(); |
| 689 | 689 |
| 690 WebInspector.panels.elements.renameSelector(oldIdentifier, this.iden
tifier, oldContent, newContent); | 690 WebInspector.panels.elements.renameSelector(oldIdentifier, this.iden
tifier, oldContent, newContent); |
| 691 | 691 |
| 692 moveToNextIfNeeded.call(self); | 692 moveToNextIfNeeded.call(self); |
| 693 } | 693 } |
| 694 | 694 |
| 695 InjectedScriptAccess.applyStyleRuleText(this.rule.id, newContent, this.p
ane.node.id, callback); | 695 InjectedScriptAccess.get(this.rule.injectedScriptId).applyStyleRuleText(
this.rule.id, newContent, this.pane.node.id, callback); |
| 696 }, | 696 }, |
| 697 | 697 |
| 698 editingSelectorCancelled: function() | 698 editingSelectorCancelled: function() |
| 699 { | 699 { |
| 700 // Do nothing, this is overridden by BlankStylePropertiesSection. | 700 // Do nothing, this is overridden by BlankStylePropertiesSection. |
| 701 } | 701 } |
| 702 } | 702 } |
| 703 | 703 |
| 704 WebInspector.StylePropertiesSection.prototype.__proto__ = WebInspector.Propertie
sSection.prototype; | 704 WebInspector.StylePropertiesSection.prototype.__proto__ = WebInspector.Propertie
sSection.prototype; |
| 705 | 705 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 self.noAffect = true; | 739 self.noAffect = true; |
| 740 self.element.addStyleClass("no-affect"); | 740 self.element.addStyleClass("no-affect"); |
| 741 } | 741 } |
| 742 | 742 |
| 743 self.subtitleElement.textContent = WebInspector.UIString("via inspec
tor"); | 743 self.subtitleElement.textContent = WebInspector.UIString("via inspec
tor"); |
| 744 self.expand(); | 744 self.expand(); |
| 745 | 745 |
| 746 self.addNewBlankProperty().startEditing(); | 746 self.addNewBlankProperty().startEditing(); |
| 747 } | 747 } |
| 748 | 748 |
| 749 InjectedScriptAccess.addStyleSelector(newContent, this.pane.node.id, cal
lback); | 749 InjectedScriptAccess.get(this.pane.node.injectedScriptId).addStyleSelect
or(newContent, this.pane.node.id, callback); |
| 750 }, | 750 }, |
| 751 | 751 |
| 752 editingSelectorCancelled: function() | 752 editingSelectorCancelled: function() |
| 753 { | 753 { |
| 754 this.pane.removeSection(this); | 754 this.pane.removeSection(this); |
| 755 }, | 755 }, |
| 756 | 756 |
| 757 makeNormal: function(styleRule) | 757 makeNormal: function(styleRule) |
| 758 { | 758 { |
| 759 this.element.removeStyleClass("blank-section"); | 759 this.element.removeStyleClass("blank-section"); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 // Set the disabled property here, since the code above replies on i
t not changing | 1046 // Set the disabled property here, since the code above replies on i
t not changing |
| 1047 // until after the value and priority are retrieved. | 1047 // until after the value and priority are retrieved. |
| 1048 self.disabled = disabled; | 1048 self.disabled = disabled; |
| 1049 | 1049 |
| 1050 if (self.treeOutline.section && self.treeOutline.section.pane) | 1050 if (self.treeOutline.section && self.treeOutline.section.pane) |
| 1051 self.treeOutline.section.pane.dispatchEventToListeners("style pr
operty toggled"); | 1051 self.treeOutline.section.pane.dispatchEventToListeners("style pr
operty toggled"); |
| 1052 | 1052 |
| 1053 self.updateAll(true); | 1053 self.updateAll(true); |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 InjectedScriptAccess.toggleStyleEnabled(this.style.id, this.name, disabl
ed, callback); | 1056 InjectedScriptAccess.get(this.style.injectedScriptId).toggleStyleEnabled
(this.style.id, this.name, disabled, callback); |
| 1057 }, | 1057 }, |
| 1058 | 1058 |
| 1059 updateState: function() | 1059 updateState: function() |
| 1060 { | 1060 { |
| 1061 if (!this.listItemElement) | 1061 if (!this.listItemElement) |
| 1062 return; | 1062 return; |
| 1063 | 1063 |
| 1064 if (this.style.isPropertyImplicit(this.name) || this.value === "initial"
) | 1064 if (this.style.isPropertyImplicit(this.name) || this.value === "initial"
) |
| 1065 this.listItemElement.addStyleClass("implicit"); | 1065 this.listItemElement.addStyleClass("implicit"); |
| 1066 else | 1066 else |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 event.preventDefault(); | 1209 event.preventDefault(); |
| 1210 event.handled = true; | 1210 event.handled = true; |
| 1211 | 1211 |
| 1212 if (!this.originalCSSText) { | 1212 if (!this.originalCSSText) { |
| 1213 // Remember the rule's original CSS text, so it can be restored | 1213 // Remember the rule's original CSS text, so it can be restored |
| 1214 // if the editing is canceled and before each apply. | 1214 // if the editing is canceled and before each apply. |
| 1215 this.originalCSSText = this.style.styleTextWithShorthands(); | 1215 this.originalCSSText = this.style.styleTextWithShorthands(); |
| 1216 } else { | 1216 } else { |
| 1217 // Restore the original CSS text before applying user changes. This
is needed to prevent | 1217 // Restore the original CSS text before applying user changes. This
is needed to prevent |
| 1218 // new properties from sticking around if the user adds one, then re
moves it. | 1218 // new properties from sticking around if the user adds one, then re
moves it. |
| 1219 InjectedScriptAccess.setStyleText(this.style.id, this.originalCSSTex
t); | 1219 InjectedScriptAccess.get(this.style.injectedScriptId).setStyleText(t
his.style.id, this.originalCSSText); |
| 1220 } | 1220 } |
| 1221 | 1221 |
| 1222 this.applyStyleText(this.listItemElement.textContent); | 1222 this.applyStyleText(this.listItemElement.textContent); |
| 1223 }, | 1223 }, |
| 1224 | 1224 |
| 1225 editingEnded: function(context) | 1225 editingEnded: function(context) |
| 1226 { | 1226 { |
| 1227 this.hasChildren = context.hasChildren; | 1227 this.hasChildren = context.hasChildren; |
| 1228 if (context.expanded) | 1228 if (context.expanded) |
| 1229 this.expand(); | 1229 this.expand(); |
| 1230 delete this.listItemElement.handleKeyEvent; | 1230 delete this.listItemElement.handleKeyEvent; |
| 1231 delete this.originalCSSText; | 1231 delete this.originalCSSText; |
| 1232 }, | 1232 }, |
| 1233 | 1233 |
| 1234 editingCancelled: function(element, context) | 1234 editingCancelled: function(element, context) |
| 1235 { | 1235 { |
| 1236 if (this._newProperty) | 1236 if (this._newProperty) |
| 1237 this.treeOutline.removeChild(this); | 1237 this.treeOutline.removeChild(this); |
| 1238 else if (this.originalCSSText) { | 1238 else if (this.originalCSSText) { |
| 1239 InjectedScriptAccess.setStyleText(this.style.id, this.originalCSSTex
t); | 1239 InjectedScriptAccess.get(this.style.injectedScriptId).setStyleText(t
his.style.id, this.originalCSSText); |
| 1240 | 1240 |
| 1241 if (this.treeOutline.section && this.treeOutline.section.pane) | 1241 if (this.treeOutline.section && this.treeOutline.section.pane) |
| 1242 this.treeOutline.section.pane.dispatchEventToListeners("style ed
ited"); | 1242 this.treeOutline.section.pane.dispatchEventToListeners("style ed
ited"); |
| 1243 | 1243 |
| 1244 this.updateAll(); | 1244 this.updateAll(); |
| 1245 } else | 1245 } else |
| 1246 this.updateTitle(); | 1246 this.updateTitle(); |
| 1247 | 1247 |
| 1248 this.editingEnded(context); | 1248 this.editingEnded(context); |
| 1249 }, | 1249 }, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 if (section && section.pane) | 1354 if (section && section.pane) |
| 1355 section.pane.dispatchEventToListeners("style edited"); | 1355 section.pane.dispatchEventToListeners("style edited"); |
| 1356 | 1356 |
| 1357 if (updateInterface) | 1357 if (updateInterface) |
| 1358 self.updateAll(true); | 1358 self.updateAll(true); |
| 1359 | 1359 |
| 1360 if (!section.rule) | 1360 if (!section.rule) |
| 1361 WebInspector.panels.elements.treeOutline.update(); | 1361 WebInspector.panels.elements.treeOutline.update(); |
| 1362 } | 1362 } |
| 1363 | 1363 |
| 1364 InjectedScriptAccess.applyStyleText(this.style.id, styleText.trimWhitesp
ace(), this.name, callback); | 1364 InjectedScriptAccess.get(this.style.injectedScriptId).applyStyleText(thi
s.style.id, styleText.trimWhitespace(), this.name, callback); |
| 1365 } | 1365 } |
| 1366 } | 1366 } |
| 1367 | 1367 |
| 1368 WebInspector.StylePropertyTreeElement.prototype.__proto__ = TreeElement.prototyp
e; | 1368 WebInspector.StylePropertyTreeElement.prototype.__proto__ = TreeElement.prototyp
e; |
| OLD | NEW |