| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 | 308 |
| 309 if (this._filterRegex) | 309 if (this._filterRegex) |
| 310 this._updateFilter(); | 310 this._updateFilter(); |
| 311 this._nodeStylesUpdatedForTest(node, false); | 311 this._nodeStylesUpdatedForTest(node, false); |
| 312 }, | 312 }, |
| 313 | 313 |
| 314 /** | 314 /** |
| 315 * @override | 315 * @override |
| 316 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback | 316 * @return {!Promise.<?>} |
| 317 */ | 317 */ |
| 318 doUpdate: function(finishedCallback) | 318 doUpdate: function() |
| 319 { | 319 { |
| 320 this._discardElementUnderMouse(); | 320 this._discardElementUnderMouse(); |
| 321 | 321 |
| 322 this.fetchMatchedCascade() | 322 return this.fetchMatchedCascade() |
| 323 .then(this._innerRebuildUpdate.bind(this)) | 323 .then(this._innerRebuildUpdate.bind(this)) |
| 324 .then(finishedCallback) | |
| 325 .catch(/** @type {function()} */(finishedCallback)); | |
| 326 }, | 324 }, |
| 327 | 325 |
| 328 _resetCache: function() | 326 _resetCache: function() |
| 329 { | 327 { |
| 330 delete this._matchedCascadePromise; | 328 delete this._matchedCascadePromise; |
| 331 }, | 329 }, |
| 332 | 330 |
| 333 /** | 331 /** |
| 334 * @return {!Promise.<?{matched: !WebInspector.SectionCascade, pseudo: !Map.
<number, !WebInspector.SectionCascade>}>} | 332 * @return {!Promise.<?{matched: !WebInspector.SectionCascade, pseudo: !Map.
<number, !WebInspector.SectionCascade>}>} |
| 335 */ | 333 */ |
| (...skipping 2461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2797 * @param {boolean} majorChange | 2795 * @param {boolean} majorChange |
| 2798 */ | 2796 */ |
| 2799 applyStyleText: function(styleText, majorChange) | 2797 applyStyleText: function(styleText, majorChange) |
| 2800 { | 2798 { |
| 2801 this._applyStyleThrottler.schedule(this._innerApplyStyleText.bind(this,
styleText, majorChange)); | 2799 this._applyStyleThrottler.schedule(this._innerApplyStyleText.bind(this,
styleText, majorChange)); |
| 2802 }, | 2800 }, |
| 2803 | 2801 |
| 2804 /** | 2802 /** |
| 2805 * @param {string} styleText | 2803 * @param {string} styleText |
| 2806 * @param {boolean} majorChange | 2804 * @param {boolean} majorChange |
| 2807 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback | 2805 * @return {!Promise.<undefined>} |
| 2808 */ | 2806 */ |
| 2809 _innerApplyStyleText: function(styleText, majorChange, finishedCallback) | 2807 _innerApplyStyleText: function(styleText, majorChange) |
| 2810 { | 2808 { |
| 2811 if (!this.treeOutline) { | 2809 if (!this.treeOutline) |
| 2812 finishedCallback(); | 2810 return Promise.resolve(); |
| 2813 return; | |
| 2814 } | |
| 2815 | 2811 |
| 2816 styleText = styleText.replace(/\s/g, " ").trim(); // Replace with
whitespace. | 2812 styleText = styleText.replace(/\s/g, " ").trim(); // Replace with
whitespace. |
| 2817 if (!styleText.length && majorChange && this._newProperty && !this._prop
ertyHasBeenEditedIncrementally) { | 2813 if (!styleText.length && majorChange && this._newProperty && !this._prop
ertyHasBeenEditedIncrementally) { |
| 2818 // The user deleted everything and never applied a new property valu
e via Up/Down scrolling/live editing, so remove the tree element and update. | 2814 // The user deleted everything and never applied a new property valu
e via Up/Down scrolling/live editing, so remove the tree element and update. |
| 2819 var section = this.section(); | 2815 var section = this.section(); |
| 2820 this.parent.removeChild(this); | 2816 this.parent.removeChild(this); |
| 2821 section.afterUpdate(); | 2817 section.afterUpdate(); |
| 2822 return; | 2818 return Promise.resolve(); |
| 2823 } | 2819 } |
| 2824 | 2820 |
| 2825 var currentNode = this._parentPane.node(); | 2821 var currentNode = this._parentPane.node(); |
| 2826 this._parentPane._userOperation = true; | 2822 this._parentPane._userOperation = true; |
| 2827 | 2823 |
| 2828 /** | 2824 /** |
| 2829 * @param {?WebInspector.CSSStyleDeclaration} newStyle | 2825 * @param {?WebInspector.CSSStyleDeclaration} newStyle |
| 2830 * @this {WebInspector.StylePropertyTreeElement} | 2826 * @this {WebInspector.StylePropertyTreeElement} |
| 2831 */ | 2827 */ |
| 2832 function callback(newStyle) | 2828 function callback(newStyle) |
| 2833 { | 2829 { |
| 2834 delete this._parentPane._userOperation; | 2830 delete this._parentPane._userOperation; |
| 2835 | 2831 |
| 2836 if (!newStyle) { | 2832 if (!newStyle) { |
| 2837 if (majorChange) { | 2833 if (majorChange) { |
| 2838 // It did not apply, cancel editing. | 2834 // It did not apply, cancel editing. |
| 2839 this._revertStyleUponEditingCanceled(); | 2835 this._revertStyleUponEditingCanceled(); |
| 2840 } | 2836 } |
| 2841 finishedCallback(); | |
| 2842 this.styleTextAppliedForTest(); | 2837 this.styleTextAppliedForTest(); |
| 2843 return; | 2838 return; |
| 2844 } | 2839 } |
| 2845 this._applyNewStyle(newStyle); | 2840 this._applyNewStyle(newStyle); |
| 2846 | 2841 |
| 2847 this._propertyHasBeenEditedIncrementally = true; | 2842 this._propertyHasBeenEditedIncrementally = true; |
| 2848 this.property = newStyle.propertyAt(this.property.index); | 2843 this.property = newStyle.propertyAt(this.property.index); |
| 2849 | 2844 |
| 2850 // We are happy to update UI if user is not editing. | 2845 // We are happy to update UI if user is not editing. |
| 2851 if (!this._parentPane._isEditingStyle && currentNode === this.node()
) | 2846 if (!this._parentPane._isEditingStyle && currentNode === this.node()
) |
| 2852 this._updatePane(); | 2847 this._updatePane(); |
| 2853 | 2848 |
| 2854 finishedCallback(); | |
| 2855 this.styleTextAppliedForTest(); | 2849 this.styleTextAppliedForTest(); |
| 2856 } | 2850 } |
| 2857 | 2851 |
| 2858 // Append a ";" if the new text does not end in ";". | 2852 // Append a ";" if the new text does not end in ";". |
| 2859 // FIXME: this does not handle trailing comments. | 2853 // FIXME: this does not handle trailing comments. |
| 2860 if (styleText.length && !/;\s*$/.test(styleText)) | 2854 if (styleText.length && !/;\s*$/.test(styleText)) |
| 2861 styleText += ";"; | 2855 styleText += ";"; |
| 2862 var overwriteProperty = !this._newProperty || this._propertyHasBeenEdite
dIncrementally; | 2856 var overwriteProperty = !this._newProperty || this._propertyHasBeenEdite
dIncrementally; |
| 2863 this.property.setText(styleText, majorChange, overwriteProperty) | 2857 return this.property.setText(styleText, majorChange, overwriteProperty) |
| 2864 .then(callback.bind(this)) | 2858 .then(callback.bind(this)); |
| 2865 .catch(/** @type {function()} */(finishedCallback)); | |
| 2866 }, | 2859 }, |
| 2867 | 2860 |
| 2868 /** | 2861 /** |
| 2869 * @override | 2862 * @override |
| 2870 * @return {boolean} | 2863 * @return {boolean} |
| 2871 */ | 2864 */ |
| 2872 ondblclick: function() | 2865 ondblclick: function() |
| 2873 { | 2866 { |
| 2874 return true; // handled | 2867 return true; // handled |
| 2875 }, | 2868 }, |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3248 | 3241 |
| 3249 /** | 3242 /** |
| 3250 * @override | 3243 * @override |
| 3251 * @return {?WebInspector.ToolbarItem} | 3244 * @return {?WebInspector.ToolbarItem} |
| 3252 */ | 3245 */ |
| 3253 item: function() | 3246 item: function() |
| 3254 { | 3247 { |
| 3255 return this._button; | 3248 return this._button; |
| 3256 } | 3249 } |
| 3257 } | 3250 } |
| OLD | NEW |