Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(929)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/CSSModel.js

Issue 2116903002: DevTools: do not detach sourcemap in case of style sheet editing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-edit-property-after-invalid-rule.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (!header) 253 if (!header)
254 return original(); 254 return original();
255 255
256 var sourceMap = this.sourceMapForHeader(header); 256 var sourceMap = this.sourceMapForHeader(header);
257 if (!sourceMap) 257 if (!sourceMap)
258 return original(); 258 return original();
259 259
260 var originalAndDetach = originalAndDetachIfSuccess.bind(this, header); 260 var originalAndDetach = originalAndDetachIfSuccess.bind(this, header);
261 261
262 if (!sourceMap.editable()) 262 if (!sourceMap.editable())
263 return originalAndDetach(); 263 return original();
264 264
265 return /** @type {!Promise<boolean>} */(sourceMap.editCompiled([range], [text]) 265 return /** @type {!Promise<boolean>} */(sourceMap.editCompiled([range], [text])
266 .then(onEditingDone.bind(this)) 266 .then(onEditingDone.bind(this))
267 .catch(onError.bind(this, header))); 267 .catch(onError.bind(this, header)));
268 268
269 /** 269 /**
270 * @param {?WebInspector.SourceMap.EditResult} editResult 270 * @param {?WebInspector.SourceMap.EditResult} editResult
271 * @return {!Promise<boolean>} 271 * @return {!Promise<boolean>}
272 * @this {WebInspector.CSSModel} 272 * @this {WebInspector.CSSModel}
273 */ 273 */
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 * @param {?CSSAgent.SelectorList} selectorPayload 411 * @param {?CSSAgent.SelectorList} selectorPayload
412 * @return {boolean} 412 * @return {boolean}
413 * @this {WebInspector.CSSModel} 413 * @this {WebInspector.CSSModel}
414 */ 414 */
415 function callback(error, selectorPayload) 415 function callback(error, selectorPayload)
416 { 416 {
417 if (error || !selectorPayload) 417 if (error || !selectorPayload)
418 return false; 418 return false;
419 this._domModel.markUndoableState(); 419 this._domModel.markUndoableState();
420 var edit = new WebInspector.CSSModel.Edit(styleSheetId, range, text, selectorPayload); 420 var edit = new WebInspector.CSSModel.Edit(styleSheetId, range, text, selectorPayload);
421 this._fireStyleSheetChangedAndDetach(styleSheetId, edit); 421 this._fireStyleSheetChanged(styleSheetId, edit);
422 return true; 422 return true;
423 } 423 }
424 424
425 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Sty leRuleEdited); 425 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Sty leRuleEdited);
426 return this._ensureOriginalStyleSheetText(styleSheetId) 426 return this._ensureOriginalStyleSheetText(styleSheetId)
427 .then(() => this._agent.setRuleSelector(styleSheetId, range, text, c allback.bind(this))) 427 .then(() => this._agent.setRuleSelector(styleSheetId, range, text, c allback.bind(this)))
428 .catchException(false); 428 .catchException(false);
429 }, 429 },
430 430
431 /** 431 /**
432 * @param {!CSSAgent.StyleSheetId} styleSheetId 432 * @param {!CSSAgent.StyleSheetId} styleSheetId
433 * @param {!WebInspector.TextRange} range 433 * @param {!WebInspector.TextRange} range
434 * @param {string} text 434 * @param {string} text
435 * @return {!Promise<boolean>} 435 * @return {!Promise<boolean>}
436 */ 436 */
437 setKeyframeKey: function(styleSheetId, range, text) 437 setKeyframeKey: function(styleSheetId, range, text)
438 { 438 {
439 /** 439 /**
440 * @param {?Protocol.Error} error 440 * @param {?Protocol.Error} error
441 * @param {!CSSAgent.Value} payload 441 * @param {!CSSAgent.Value} payload
442 * @return {boolean} 442 * @return {boolean}
443 * @this {WebInspector.CSSModel} 443 * @this {WebInspector.CSSModel}
444 */ 444 */
445 function callback(error, payload) 445 function callback(error, payload)
446 { 446 {
447 if (error || !payload) 447 if (error || !payload)
448 return false; 448 return false;
449 this._domModel.markUndoableState(); 449 this._domModel.markUndoableState();
450 var edit = new WebInspector.CSSModel.Edit(styleSheetId, range, text, payload); 450 var edit = new WebInspector.CSSModel.Edit(styleSheetId, range, text, payload);
451 this._fireStyleSheetChangedAndDetach(styleSheetId, edit); 451 this._fireStyleSheetChanged(styleSheetId, edit);
452 return true; 452 return true;
453 } 453 }
454 454
455 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Sty leRuleEdited); 455 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Sty leRuleEdited);
456 return this._ensureOriginalStyleSheetText(styleSheetId) 456 return this._ensureOriginalStyleSheetText(styleSheetId)
457 .then(() => this._agent.setKeyframeKey(styleSheetId, range, text, ca llback.bind(this))) 457 .then(() => this._agent.setKeyframeKey(styleSheetId, range, text, ca llback.bind(this)))
458 .catchException(false); 458 .catchException(false);
459 }, 459 },
460 460
461 /** 461 /**
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 * @param {!CSSAgent.CSSMedia} mediaPayload 675 * @param {!CSSAgent.CSSMedia} mediaPayload
676 * @return {boolean} 676 * @return {boolean}
677 * @this {WebInspector.CSSModel} 677 * @this {WebInspector.CSSModel}
678 */ 678 */
679 function parsePayload(error, mediaPayload) 679 function parsePayload(error, mediaPayload)
680 { 680 {
681 if (!mediaPayload) 681 if (!mediaPayload)
682 return false; 682 return false;
683 this._domModel.markUndoableState(); 683 this._domModel.markUndoableState();
684 var edit = new WebInspector.CSSModel.Edit(styleSheetId, range, newMe diaText, mediaPayload); 684 var edit = new WebInspector.CSSModel.Edit(styleSheetId, range, newMe diaText, mediaPayload);
685 this._fireStyleSheetChangedAndDetach(styleSheetId, edit); 685 this._fireStyleSheetChanged(styleSheetId, edit);
686 return true; 686 return true;
687 } 687 }
688 688
689 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Sty leRuleEdited); 689 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Sty leRuleEdited);
690 return this._ensureOriginalStyleSheetText(styleSheetId) 690 return this._ensureOriginalStyleSheetText(styleSheetId)
691 .then(() => this._agent.setMediaText(styleSheetId, range, newMediaTe xt, parsePayload.bind(this))) 691 .then(() => this._agent.setMediaText(styleSheetId, range, newMediaTe xt, parsePayload.bind(this)))
692 .catchException(false); 692 .catchException(false);
693 }, 693 },
694 694
695 /** 695 /**
(...skipping 13 matching lines...) Expand all
709 * @param {?CSSAgent.CSSRule} rulePayload 709 * @param {?CSSAgent.CSSRule} rulePayload
710 * @return {?WebInspector.CSSStyleRule} 710 * @return {?WebInspector.CSSStyleRule}
711 * @this {WebInspector.CSSModel} 711 * @this {WebInspector.CSSModel}
712 */ 712 */
713 function parsePayload(error, rulePayload) 713 function parsePayload(error, rulePayload)
714 { 714 {
715 if (error || !rulePayload) 715 if (error || !rulePayload)
716 return null; 716 return null;
717 this._domModel.markUndoableState(); 717 this._domModel.markUndoableState();
718 var edit = new WebInspector.CSSModel.Edit(styleSheetId, ruleLocation , ruleText, rulePayload); 718 var edit = new WebInspector.CSSModel.Edit(styleSheetId, ruleLocation , ruleText, rulePayload);
719 this._fireStyleSheetChangedAndDetach(styleSheetId, edit); 719 this._fireStyleSheetChanged(styleSheetId, edit);
720 return new WebInspector.CSSStyleRule(this, rulePayload); 720 return new WebInspector.CSSStyleRule(this, rulePayload);
721 } 721 }
722 }, 722 },
723 723
724 /** 724 /**
725 * @param {!WebInspector.DOMNode} node 725 * @param {!WebInspector.DOMNode} node
726 * @param {function(?WebInspector.CSSStyleSheetHeader)} userCallback 726 * @param {function(?WebInspector.CSSStyleSheetHeader)} userCallback
727 */ 727 */
728 requestViaInspectorStylesheet: function(node, userCallback) 728 requestViaInspectorStylesheet: function(node, userCallback)
729 { 729 {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 * @param {!CSSAgent.StyleSheetId} styleSheetId 779 * @param {!CSSAgent.StyleSheetId} styleSheetId
780 * @param {!WebInspector.CSSModel.Edit=} edit 780 * @param {!WebInspector.CSSModel.Edit=} edit
781 */ 781 */
782 _fireStyleSheetChanged: function(styleSheetId, edit) 782 _fireStyleSheetChanged: function(styleSheetId, edit)
783 { 783 {
784 this.dispatchEventToListeners(WebInspector.CSSModel.Events.StyleSheetCha nged, { styleSheetId: styleSheetId, edit: edit }); 784 this.dispatchEventToListeners(WebInspector.CSSModel.Events.StyleSheetCha nged, { styleSheetId: styleSheetId, edit: edit });
785 }, 785 },
786 786
787 /** 787 /**
788 * @param {!CSSAgent.StyleSheetId} styleSheetId 788 * @param {!CSSAgent.StyleSheetId} styleSheetId
789 * @param {!WebInspector.CSSModel.Edit=} edit
790 */
791 _fireStyleSheetChangedAndDetach: function(styleSheetId, edit)
792 {
793 this.dispatchEventToListeners(WebInspector.CSSModel.Events.StyleSheetCha nged, { styleSheetId: styleSheetId, edit: edit });
794 var header = this.styleSheetHeaderForId(styleSheetId);
795 if (header)
796 this._detachSourceMap(header);
797 },
798
799 /**
800 * @param {!CSSAgent.StyleSheetId} styleSheetId
801 * @return {!Promise<string>} 789 * @return {!Promise<string>}
802 */ 790 */
803 _ensureOriginalStyleSheetText: function(styleSheetId) 791 _ensureOriginalStyleSheetText: function(styleSheetId)
804 { 792 {
805 var header = this.styleSheetHeaderForId(styleSheetId); 793 var header = this.styleSheetHeaderForId(styleSheetId);
806 if (!header) 794 if (!header)
807 return Promise.resolve(""); 795 return Promise.resolve("");
808 var promise = this._originalStyleSheetText.get(header); 796 var promise = this._originalStyleSheetText.get(header);
809 if (!promise) { 797 if (!promise) {
810 promise = this.getStyleSheetText(header.id); 798 promise = this.getStyleSheetText(header.id);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 { 1077 {
1090 this._cssModel.mediaQueryResultChanged(); 1078 this._cssModel.mediaQueryResultChanged();
1091 }, 1079 },
1092 1080
1093 /** 1081 /**
1094 * @override 1082 * @override
1095 * @param {!CSSAgent.StyleSheetId} styleSheetId 1083 * @param {!CSSAgent.StyleSheetId} styleSheetId
1096 */ 1084 */
1097 styleSheetChanged: function(styleSheetId) 1085 styleSheetChanged: function(styleSheetId)
1098 { 1086 {
1099 this._cssModel._fireStyleSheetChangedAndDetach(styleSheetId); 1087 this._cssModel._fireStyleSheetChanged(styleSheetId);
1100 }, 1088 },
1101 1089
1102 /** 1090 /**
1103 * @override 1091 * @override
1104 * @param {!CSSAgent.CSSStyleSheetHeader} header 1092 * @param {!CSSAgent.CSSStyleSheetHeader} header
1105 */ 1093 */
1106 styleSheetAdded: function(header) 1094 styleSheetAdded: function(header)
1107 { 1095 {
1108 this._cssModel._styleSheetAdded(header); 1096 this._cssModel._styleSheetAdded(header);
1109 }, 1097 },
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 /** 1190 /**
1203 * @constructor 1191 * @constructor
1204 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle 1192 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle
1205 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle 1193 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle
1206 */ 1194 */
1207 WebInspector.CSSModel.InlineStyleResult = function(inlineStyle, attributesStyle) 1195 WebInspector.CSSModel.InlineStyleResult = function(inlineStyle, attributesStyle)
1208 { 1196 {
1209 this.inlineStyle = inlineStyle; 1197 this.inlineStyle = inlineStyle;
1210 this.attributesStyle = attributesStyle; 1198 this.attributesStyle = attributesStyle;
1211 } 1199 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-edit-property-after-invalid-rule.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698