| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 node = null; | 231 node = null; |
| 232 | 232 |
| 233 if (node) | 233 if (node) |
| 234 this.node = node; | 234 this.node = node; |
| 235 else | 235 else |
| 236 node = this.node; | 236 node = this.node; |
| 237 | 237 |
| 238 this._innerUpdate(refresh, null); | 238 this._innerUpdate(refresh, null); |
| 239 }, | 239 }, |
| 240 | 240 |
| 241 _innerUpdate: function(refresh, editedSection) | 241 _innerUpdate: function(refresh, editedSection, userCallback) |
| 242 { | 242 { |
| 243 var node = this.node; | 243 var node = this.node; |
| 244 if (!node) { | 244 if (!node) { |
| 245 this._sectionsContainer.removeChildren(); | 245 this._sectionsContainer.removeChildren(); |
| 246 this._computedStylePane.bodyElement.removeChildren(); | 246 this._computedStylePane.bodyElement.removeChildren(); |
| 247 this.sections = {}; | 247 this.sections = {}; |
| 248 if (userCallback) |
| 249 userCallback(); |
| 248 return; | 250 return; |
| 249 } | 251 } |
| 250 | 252 |
| 251 function stylesCallback(styles) | 253 function stylesCallback(styles) |
| 252 { | 254 { |
| 253 if (this.node === node && styles) | 255 if (this.node === node && styles) |
| 254 this._rebuildUpdate(node, styles); | 256 this._rebuildUpdate(node, styles); |
| 257 if (userCallback) |
| 258 userCallback(); |
| 255 } | 259 } |
| 256 | 260 |
| 257 function computedStyleCallback(computedStyle) | 261 function computedStyleCallback(computedStyle) |
| 258 { | 262 { |
| 259 if (this.node === node && computedStyle) | 263 if (this.node === node && computedStyle) |
| 260 this._refreshUpdate(node, computedStyle, editedSection); | 264 this._refreshUpdate(node, computedStyle, editedSection); |
| 265 if (userCallback) |
| 266 userCallback(); |
| 261 } | 267 } |
| 262 | 268 |
| 263 if (refresh) | 269 if (refresh) |
| 264 WebInspector.cssModel.getComputedStyleAsync(node.id, computedStyleCa
llback.bind(this)); | 270 WebInspector.cssModel.getComputedStyleAsync(node.id, computedStyleCa
llback.bind(this)); |
| 265 else | 271 else |
| 266 WebInspector.cssModel.getStylesAsync(node.id, this._forcedPseudoClas
ses, stylesCallback.bind(this)); | 272 WebInspector.cssModel.getStylesAsync(node.id, this._forcedPseudoClas
ses, stylesCallback.bind(this)); |
| 267 }, | 273 }, |
| 268 | 274 |
| 269 _styleSheetChanged: function() | 275 _styleSheetChanged: function() |
| 270 { | 276 { |
| (...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 // Avoid having longhands under an invalid shorthand. | 1610 // Avoid having longhands under an invalid shorthand. |
| 1605 this.hasChildren = false; | 1611 this.hasChildren = false; |
| 1606 this.listItemElement.addStyleClass("not-parsed-ok"); | 1612 this.listItemElement.addStyleClass("not-parsed-ok"); |
| 1607 } | 1613 } |
| 1608 if (this.property.inactive) | 1614 if (this.property.inactive) |
| 1609 this.listItemElement.addStyleClass("inactive"); | 1615 this.listItemElement.addStyleClass("inactive"); |
| 1610 | 1616 |
| 1611 this.tooltip = this.property.propertyText; | 1617 this.tooltip = this.property.propertyText; |
| 1612 }, | 1618 }, |
| 1613 | 1619 |
| 1614 _updateAll: function() | 1620 _updatePane: function(userCallback) |
| 1615 { | 1621 { |
| 1616 if (!this.treeOutline) | 1622 if (this.treeOutline && this.treeOutline.section && this.treeOutline.sec
tion.pane) |
| 1617 return; | 1623 this.treeOutline.section.pane._innerUpdate(true, this.treeOutline.se
ction, userCallback); |
| 1618 if (this.treeOutline.section && this.treeOutline.section.pane) | 1624 else { |
| 1619 this.treeOutline.section.pane._innerUpdate(true, this.treeOutline.se
ction); | 1625 if (userCallback) |
| 1620 else if (this.treeOutline.section) | 1626 userCallback(); |
| 1621 this.treeOutline.section.update(true); | 1627 } |
| 1622 else | |
| 1623 this.updateTitle(); // FIXME: this will not show new properties. But
we don't hit this case yet. | |
| 1624 }, | 1628 }, |
| 1625 | 1629 |
| 1626 toggleEnabled: function(event) | 1630 toggleEnabled: function(event) |
| 1627 { | 1631 { |
| 1628 var disabled = !event.target.checked; | 1632 var disabled = !event.target.checked; |
| 1629 | 1633 |
| 1630 function callback(newStyle) | 1634 function callback(newStyle) |
| 1631 { | 1635 { |
| 1632 if (!newStyle) | 1636 if (!newStyle) |
| 1633 return; | 1637 return; |
| 1634 | 1638 |
| 1635 this.style = newStyle; | 1639 this.style = newStyle; |
| 1636 this._styleRule.style = newStyle; | 1640 this._styleRule.style = newStyle; |
| 1637 | 1641 |
| 1638 if (this.treeOutline.section && this.treeOutline.section.pane) | 1642 if (this.treeOutline.section && this.treeOutline.section.pane) |
| 1639 this.treeOutline.section.pane.dispatchEventToListeners("style pr
operty toggled"); | 1643 this.treeOutline.section.pane.dispatchEventToListeners("style pr
operty toggled"); |
| 1640 | 1644 |
| 1641 this._updateAll(); | 1645 this._updatePane(); |
| 1642 } | 1646 } |
| 1643 | 1647 |
| 1644 this.property.setDisabled(disabled, callback.bind(this)); | 1648 this.property.setDisabled(disabled, callback.bind(this)); |
| 1645 }, | 1649 }, |
| 1646 | 1650 |
| 1647 updateState: function() | 1651 updateState: function() |
| 1648 { | 1652 { |
| 1649 if (!this.listItemElement) | 1653 if (!this.listItemElement) |
| 1650 return; | 1654 return; |
| 1651 | 1655 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 | 2077 |
| 2074 _hasBeenModifiedIncrementally: function() | 2078 _hasBeenModifiedIncrementally: function() |
| 2075 { | 2079 { |
| 2076 // New properties applied via up/down have an originalPropertyText and w
ill be deleted later | 2080 // New properties applied via up/down have an originalPropertyText and w
ill be deleted later |
| 2077 // on, if cancelled, when the empty string gets applied as their style t
ext. | 2081 // on, if cancelled, when the empty string gets applied as their style t
ext. |
| 2078 return typeof this.originalPropertyText === "string"; | 2082 return typeof this.originalPropertyText === "string"; |
| 2079 }, | 2083 }, |
| 2080 | 2084 |
| 2081 applyStyleText: function(styleText, updateInterface, majorChange, isRevert) | 2085 applyStyleText: function(styleText, updateInterface, majorChange, isRevert) |
| 2082 { | 2086 { |
| 2087 function userOperationFinishedCallback(parentPane, updateInterface) |
| 2088 { |
| 2089 if (updateInterface) |
| 2090 delete parentPane._userOperation; |
| 2091 } |
| 2092 |
| 2083 // Leave a way to cancel editing after incremental changes. | 2093 // Leave a way to cancel editing after incremental changes. |
| 2084 if (!isRevert && !updateInterface && !this._hasBeenModifiedIncrementally
()) { | 2094 if (!isRevert && !updateInterface && !this._hasBeenModifiedIncrementally
()) { |
| 2085 // Remember the rule's original CSS text on [Page](Up|Down), so it c
an be restored | 2095 // Remember the rule's original CSS text on [Page](Up|Down), so it c
an be restored |
| 2086 // if the editing is canceled. | 2096 // if the editing is canceled. |
| 2087 this.originalPropertyText = this.property.propertyText; | 2097 this.originalPropertyText = this.property.propertyText; |
| 2088 } | 2098 } |
| 2089 | 2099 |
| 2090 var section = this.treeOutline.section; | 2100 var section = this.treeOutline.section; |
| 2091 var elementsPanel = WebInspector.panels.elements; | 2101 var elementsPanel = WebInspector.panels.elements; |
| 2092 styleText = styleText.replace(/\s/g, " ").trim(); // Replace with
whitespace. | 2102 styleText = styleText.replace(/\s/g, " ").trim(); // Replace with
whitespace. |
| 2093 var styleTextLength = styleText.length; | 2103 var styleTextLength = styleText.length; |
| 2094 if (!styleTextLength && updateInterface && !isRevert && this._newPropert
y && !this._hasBeenModifiedIncrementally()) { | 2104 if (!styleTextLength && updateInterface && !isRevert && this._newPropert
y && !this._hasBeenModifiedIncrementally()) { |
| 2095 // The user deleted everything and never applied a new property valu
e via Up/Down scrolling, so remove the tree element and update. | 2105 // The user deleted everything and never applied a new property valu
e via Up/Down scrolling, so remove the tree element and update. |
| 2096 this.parent.removeChild(this); | 2106 this.parent.removeChild(this); |
| 2097 section.afterUpdate(); | 2107 section.afterUpdate(); |
| 2098 return; | 2108 return; |
| 2099 } | 2109 } |
| 2100 | 2110 |
| 2101 var currentNode = this._parentPane.node; | 2111 var currentNode = this._parentPane.node; |
| 2102 this._parentPane._userOperation = true; | 2112 if (updateInterface) |
| 2113 this._parentPane._userOperation = true; |
| 2103 | 2114 |
| 2104 function callback(originalPropertyText, newStyle) | 2115 function callback(userCallback, originalPropertyText, newStyle) |
| 2105 { | 2116 { |
| 2106 delete this._parentPane._userOperation; | |
| 2107 if (!newStyle) { | 2117 if (!newStyle) { |
| 2108 if (updateInterface) { | 2118 if (updateInterface) { |
| 2109 // It did not apply, cancel editing. | 2119 // It did not apply, cancel editing. |
| 2110 this._revertStyleUponEditingCanceled(originalPropertyText); | 2120 this._revertStyleUponEditingCanceled(originalPropertyText); |
| 2111 } | 2121 } |
| 2122 userCallback(); |
| 2112 return; | 2123 return; |
| 2113 } | 2124 } |
| 2114 | 2125 |
| 2115 this.style = newStyle; | 2126 this.style = newStyle; |
| 2116 this.property = newStyle.propertyAt(this.property.index); | 2127 this.property = newStyle.propertyAt(this.property.index); |
| 2117 this._styleRule.style = this.style; | 2128 this._styleRule.style = this.style; |
| 2118 | 2129 |
| 2119 if (section && section.pane) | 2130 if (section && section.pane) |
| 2120 section.pane.dispatchEventToListeners("style edited"); | 2131 section.pane.dispatchEventToListeners("style edited"); |
| 2121 | 2132 |
| 2122 if (updateInterface && currentNode === section.pane.node) | 2133 if (updateInterface && currentNode === section.pane.node) { |
| 2123 this._updateAll(); | 2134 this._updatePane(userCallback); |
| 2135 return; |
| 2136 } |
| 2137 |
| 2138 userCallback(); |
| 2124 } | 2139 } |
| 2125 | 2140 |
| 2126 // Append a ";" if the new text does not end in ";". | 2141 // Append a ";" if the new text does not end in ";". |
| 2127 // FIXME: this does not handle trailing comments. | 2142 // FIXME: this does not handle trailing comments. |
| 2128 if (styleText.length && !/;\s*$/.test(styleText)) | 2143 if (styleText.length && !/;\s*$/.test(styleText)) |
| 2129 styleText += ";"; | 2144 styleText += ";"; |
| 2130 this.property.setText(styleText, majorChange, callback.bind(this, this.o
riginalPropertyText)); | 2145 this.property.setText(styleText, majorChange, callback.bind(this, userOp
erationFinishedCallback.bind(null, this._parentPane, updateInterface), this.orig
inalPropertyText)); |
| 2131 } | 2146 } |
| 2132 } | 2147 } |
| 2133 | 2148 |
| 2134 WebInspector.StylePropertyTreeElement.prototype.__proto__ = TreeElement.prototyp
e; | 2149 WebInspector.StylePropertyTreeElement.prototype.__proto__ = TreeElement.prototyp
e; |
| 2135 | 2150 |
| 2136 WebInspector.StylesSidebarPane.CSSPropertyPrompt = function(element, cssCompleti
ons) | 2151 WebInspector.StylesSidebarPane.CSSPropertyPrompt = function(element, cssCompleti
ons) |
| 2137 { | 2152 { |
| 2138 WebInspector.TextPrompt.call(this, element, this._buildPropertyCompletions.b
ind(this), WebInspector.StylesSidebarPane.StyleValueDelimiters, true); | 2153 WebInspector.TextPrompt.call(this, element, this._buildPropertyCompletions.b
ind(this), WebInspector.StylesSidebarPane.StyleValueDelimiters, true); |
| 2139 this._cssCompletions = cssCompletions; | 2154 this._cssCompletions = cssCompletions; |
| 2140 } | 2155 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 return completionsReadyCallback(results); | 2215 return completionsReadyCallback(results); |
| 2201 } | 2216 } |
| 2202 | 2217 |
| 2203 results = this._cssCompletions.startsWith(prefix); | 2218 results = this._cssCompletions.startsWith(prefix); |
| 2204 if (results) | 2219 if (results) |
| 2205 completionsReadyCallback(results); | 2220 completionsReadyCallback(results); |
| 2206 } | 2221 } |
| 2207 } | 2222 } |
| 2208 | 2223 |
| 2209 WebInspector.StylesSidebarPane.CSSPropertyPrompt.prototype.__proto__ = WebInspec
tor.TextPrompt.prototype; | 2224 WebInspector.StylesSidebarPane.CSSPropertyPrompt.prototype.__proto__ = WebInspec
tor.TextPrompt.prototype; |
| OLD | NEW |