| Index: Source/devtools/front_end/elements/StylesSidebarPane.js
|
| diff --git a/Source/devtools/front_end/elements/StylesSidebarPane.js b/Source/devtools/front_end/elements/StylesSidebarPane.js
|
| index 28c3da877d3460293b6a8940f7b9abd82217f034..64edcdf6327820994fffd57389868707fabec73a 100644
|
| --- a/Source/devtools/front_end/elements/StylesSidebarPane.js
|
| +++ b/Source/devtools/front_end/elements/StylesSidebarPane.js
|
| @@ -1549,28 +1549,22 @@ WebInspector.StylePropertiesSection.prototype = {
|
| newContent = newContent.trim();
|
|
|
| /**
|
| - * @param {!WebInspector.CSSMedia} newMedia
|
| + * @param {?WebInspector.CSSMedia} newMedia
|
| * @this {WebInspector.StylePropertiesSection}
|
| */
|
| - function successCallback(newMedia)
|
| - {
|
| - this._parentPane._styleSheetMediaEdited(media, newMedia);
|
| - this._parentPane._refreshUpdate(this);
|
| - finishOperation.call(this);
|
| - }
|
| -
|
| - /**
|
| - * @this {WebInspector.StylePropertiesSection}
|
| - */
|
| - function finishOperation()
|
| + function userCallback(newMedia)
|
| {
|
| + if (newMedia) {
|
| + this._parentPane._styleSheetMediaEdited(media, newMedia);
|
| + this._parentPane._refreshUpdate(this);
|
| + }
|
| delete this._parentPane._userOperation;
|
| this._editingMediaTextCommittedForTest();
|
| }
|
|
|
| // This gets deleted in finishOperation(), which is called both on success and failure.
|
| this._parentPane._userOperation = true;
|
| - this._parentPane._cssModel.setMediaText(media, newContent, successCallback.bind(this), finishOperation.bind(this));
|
| + this._parentPane._cssModel.setMediaText(media, newContent, userCallback.bind(this));
|
| },
|
|
|
| _editingMediaTextCommittedForTest: function() { },
|
| @@ -1700,38 +1694,31 @@ WebInspector.StylePropertiesSection.prototype = {
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.CSSRule} newRule
|
| + * @param {?WebInspector.CSSRule} newRule
|
| * @this {WebInspector.StylePropertiesSection}
|
| */
|
| - function successCallback(newRule)
|
| + function finishCallback(newRule)
|
| {
|
| - var doesAffectSelectedNode = newRule.matchingSelectors.length > 0;
|
| - this.element.classList.toggle("no-affect", !doesAffectSelectedNode);
|
| -
|
| - var oldSelectorRange = this.rule().selectorRange;
|
| - this.styleRule.updateRule(newRule);
|
| + if (newRule) {
|
| + var doesAffectSelectedNode = newRule.matchingSelectors.length > 0;
|
| + this.element.classList.toggle("no-affect", !doesAffectSelectedNode);
|
|
|
| - this._parentPane._refreshUpdate(this);
|
| - this._parentPane._styleSheetRuleEdited(newRule, oldSelectorRange, newRule.selectorRange);
|
| + var oldSelectorRange = this.rule().selectorRange;
|
| + this.styleRule.updateRule(newRule);
|
|
|
| - finishOperationAndMoveEditor.call(this, moveDirection);
|
| - }
|
| + this._parentPane._refreshUpdate(this);
|
| + this._parentPane._styleSheetRuleEdited(newRule, oldSelectorRange, newRule.selectorRange);
|
| + }
|
|
|
| - /**
|
| - * @param {string} direction
|
| - * @this {WebInspector.StylePropertiesSection}
|
| - */
|
| - function finishOperationAndMoveEditor(direction)
|
| - {
|
| delete this._parentPane._userOperation;
|
| - this._moveEditorFromSelector(direction);
|
| + this._moveEditorFromSelector(moveDirection);
|
| this._editingSelectorCommittedForTest();
|
| }
|
|
|
| // This gets deleted in finishOperationAndMoveEditor(), which is called both on success and failure.
|
| this._parentPane._userOperation = true;
|
| var selectedNode = this._parentPane.node();
|
| - this._parentPane._cssModel.setRuleSelector(this.rule(), selectedNode ? selectedNode.id : 0, newContent, successCallback.bind(this), finishOperationAndMoveEditor.bind(this, moveDirection));
|
| + this._parentPane._cssModel.setRuleSelector(this.rule(), selectedNode ? selectedNode.id : 0, newContent, finishCallback.bind(this));
|
| },
|
|
|
| _editingSelectorCommittedForTest: function() { },
|
| @@ -1878,11 +1865,16 @@ WebInspector.BlankStylePropertiesSection.prototype = {
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.CSSRule} newRule
|
| + * @param {?WebInspector.CSSRule} newRule
|
| * @this {WebInspector.StylePropertiesSection}
|
| */
|
| - function successCallback(newRule)
|
| + function userCallback(newRule)
|
| {
|
| + if (!newRule) {
|
| + this.editingSelectorCancelled();
|
| + this._editingSelectorCommittedForTest();
|
| + return;
|
| + }
|
| var doesSelectorAffectSelectedNode = newRule.matchingSelectors.length > 0;
|
| this._makeNormal(newRule);
|
|
|
| @@ -1906,22 +1898,13 @@ WebInspector.BlankStylePropertiesSection.prototype = {
|
| this._editingSelectorCommittedForTest();
|
| }
|
|
|
| - /**
|
| - * @this {WebInspector.StylePropertiesSection}
|
| - */
|
| - function failureCallback()
|
| - {
|
| - this.editingSelectorCancelled();
|
| - this._editingSelectorCommittedForTest();
|
| - }
|
| -
|
| if (newContent)
|
| newContent = newContent.trim();
|
| this._parentPane._userOperation = true;
|
|
|
| var cssModel = this._parentPane._cssModel;
|
| var ruleText = this._rulePrefix() + newContent + " {}";
|
| - cssModel.addRule(this._styleSheetId, this._parentPane.node(), ruleText, this._ruleLocation, successCallback.bind(this), failureCallback.bind(this));
|
| + cssModel.addRule(this._styleSheetId, this._parentPane.node(), ruleText, this._ruleLocation, userCallback.bind(this));
|
| },
|
|
|
| editingSelectorCancelled: function()
|
|
|