| OLD | NEW |
| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * @return {!SDK.DOMModel} | 102 * @return {!SDK.DOMModel} |
| 103 */ | 103 */ |
| 104 domModel() { | 104 domModel() { |
| 105 return this._domModel; | 105 return this._domModel; |
| 106 } | 106 } |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * @param {!Protocol.CSS.StyleSheetId} styleSheetId | 109 * @param {!Protocol.CSS.StyleSheetId} styleSheetId |
| 110 * @param {!Common.TextRange} range | 110 * @param {!TextUtils.TextRange} range |
| 111 * @param {string} text | 111 * @param {string} text |
| 112 * @param {boolean} majorChange | 112 * @param {boolean} majorChange |
| 113 * @return {!Promise<boolean>} | 113 * @return {!Promise<boolean>} |
| 114 */ | 114 */ |
| 115 setStyleText(styleSheetId, range, text, majorChange) { | 115 setStyleText(styleSheetId, range, text, majorChange) { |
| 116 var original = this._innerSetStyleTexts.bind(this, [styleSheetId], [range],
[text], majorChange); | 116 var original = this._innerSetStyleTexts.bind(this, [styleSheetId], [range],
[text], majorChange); |
| 117 var header = this.styleSheetHeaderForId(styleSheetId); | 117 var header = this.styleSheetHeaderForId(styleSheetId); |
| 118 if (!header) | 118 if (!header) |
| 119 return original(); | 119 return original(); |
| 120 | 120 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 136 * @this {SDK.CSSModel} | 136 * @this {SDK.CSSModel} |
| 137 */ | 137 */ |
| 138 function onEditingDone(editResult) { | 138 function onEditingDone(editResult) { |
| 139 if (!editResult) | 139 if (!editResult) |
| 140 return Promise.resolve(false); | 140 return Promise.resolve(false); |
| 141 | 141 |
| 142 var edits = editResult.compiledEdits; | 142 var edits = editResult.compiledEdits; |
| 143 if (!edits.length) | 143 if (!edits.length) |
| 144 return onCSSPatched.call(this, editResult, true); | 144 return onCSSPatched.call(this, editResult, true); |
| 145 | 145 |
| 146 edits.sort(Common.SourceEdit.comparator); | 146 edits.sort(TextUtils.SourceEdit.comparator); |
| 147 edits = edits.reverse(); | 147 edits = edits.reverse(); |
| 148 | 148 |
| 149 var styleSheetIds = []; | 149 var styleSheetIds = []; |
| 150 var ranges = []; | 150 var ranges = []; |
| 151 var texts = []; | 151 var texts = []; |
| 152 for (var edit of edits) { | 152 for (var edit of edits) { |
| 153 styleSheetIds.push(header.id); | 153 styleSheetIds.push(header.id); |
| 154 ranges.push(edit.oldRange); | 154 ranges.push(edit.oldRange); |
| 155 texts.push(edit.newText); | 155 texts.push(edit.newText); |
| 156 } | 156 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 function detachIfSuccess(success) { | 201 function detachIfSuccess(success) { |
| 202 if (success) | 202 if (success) |
| 203 this._sourceMapManager.detachSourceMap(header); | 203 this._sourceMapManager.detachSourceMap(header); |
| 204 return success; | 204 return success; |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 /** | 209 /** |
| 210 * @param {!Array<!Protocol.CSS.StyleSheetId>} styleSheetIds | 210 * @param {!Array<!Protocol.CSS.StyleSheetId>} styleSheetIds |
| 211 * @param {!Array<!Common.TextRange>} ranges | 211 * @param {!Array<!TextUtils.TextRange>} ranges |
| 212 * @param {!Array<string>} texts | 212 * @param {!Array<string>} texts |
| 213 * @param {boolean} majorChange | 213 * @param {boolean} majorChange |
| 214 * @return {!Promise<boolean>} | 214 * @return {!Promise<boolean>} |
| 215 */ | 215 */ |
| 216 _innerSetStyleTexts(styleSheetIds, ranges, texts, majorChange) { | 216 _innerSetStyleTexts(styleSheetIds, ranges, texts, majorChange) { |
| 217 /** | 217 /** |
| 218 * @param {?Protocol.Error} error | 218 * @param {?Protocol.Error} error |
| 219 * @param {?Array<!Protocol.CSS.CSSStyle>} stylePayloads | 219 * @param {?Array<!Protocol.CSS.CSSStyle>} stylePayloads |
| 220 * @return {boolean} | 220 * @return {boolean} |
| 221 * @this {SDK.CSSModel} | 221 * @this {SDK.CSSModel} |
| (...skipping 20 matching lines...) Expand all Loading... |
| 242 ensureContentPromises.push(this._ensureOriginalStyleSheetText(styleSheetId
s[i])); | 242 ensureContentPromises.push(this._ensureOriginalStyleSheetText(styleSheetId
s[i])); |
| 243 } | 243 } |
| 244 | 244 |
| 245 return Promise.all(ensureContentPromises) | 245 return Promise.all(ensureContentPromises) |
| 246 .then(() => this._agent.setStyleTexts(edits, parsePayload.bind(this))) | 246 .then(() => this._agent.setStyleTexts(edits, parsePayload.bind(this))) |
| 247 .catchException(false); | 247 .catchException(false); |
| 248 } | 248 } |
| 249 | 249 |
| 250 /** | 250 /** |
| 251 * @param {!Protocol.CSS.StyleSheetId} styleSheetId | 251 * @param {!Protocol.CSS.StyleSheetId} styleSheetId |
| 252 * @param {!Common.TextRange} range | 252 * @param {!TextUtils.TextRange} range |
| 253 * @param {string} text | 253 * @param {string} text |
| 254 * @return {!Promise<boolean>} | 254 * @return {!Promise<boolean>} |
| 255 */ | 255 */ |
| 256 setSelectorText(styleSheetId, range, text) { | 256 setSelectorText(styleSheetId, range, text) { |
| 257 /** | 257 /** |
| 258 * @param {?Protocol.Error} error | 258 * @param {?Protocol.Error} error |
| 259 * @param {?Protocol.CSS.SelectorList} selectorPayload | 259 * @param {?Protocol.CSS.SelectorList} selectorPayload |
| 260 * @return {boolean} | 260 * @return {boolean} |
| 261 * @this {SDK.CSSModel} | 261 * @this {SDK.CSSModel} |
| 262 */ | 262 */ |
| 263 function callback(error, selectorPayload) { | 263 function callback(error, selectorPayload) { |
| 264 if (error || !selectorPayload) | 264 if (error || !selectorPayload) |
| 265 return false; | 265 return false; |
| 266 this._domModel.markUndoableState(); | 266 this._domModel.markUndoableState(); |
| 267 var edit = new SDK.CSSModel.Edit(styleSheetId, range, text, selectorPayloa
d); | 267 var edit = new SDK.CSSModel.Edit(styleSheetId, range, text, selectorPayloa
d); |
| 268 this._fireStyleSheetChanged(styleSheetId, edit); | 268 this._fireStyleSheetChanged(styleSheetId, edit); |
| 269 return true; | 269 return true; |
| 270 } | 270 } |
| 271 | 271 |
| 272 Host.userMetrics.actionTaken(Host.UserMetrics.Action.StyleRuleEdited); | 272 Host.userMetrics.actionTaken(Host.UserMetrics.Action.StyleRuleEdited); |
| 273 return this._ensureOriginalStyleSheetText(styleSheetId) | 273 return this._ensureOriginalStyleSheetText(styleSheetId) |
| 274 .then(() => this._agent.setRuleSelector(styleSheetId, range, text, callb
ack.bind(this))) | 274 .then(() => this._agent.setRuleSelector(styleSheetId, range, text, callb
ack.bind(this))) |
| 275 .catchException(false); | 275 .catchException(false); |
| 276 } | 276 } |
| 277 | 277 |
| 278 /** | 278 /** |
| 279 * @param {!Protocol.CSS.StyleSheetId} styleSheetId | 279 * @param {!Protocol.CSS.StyleSheetId} styleSheetId |
| 280 * @param {!Common.TextRange} range | 280 * @param {!TextUtils.TextRange} range |
| 281 * @param {string} text | 281 * @param {string} text |
| 282 * @return {!Promise<boolean>} | 282 * @return {!Promise<boolean>} |
| 283 */ | 283 */ |
| 284 setKeyframeKey(styleSheetId, range, text) { | 284 setKeyframeKey(styleSheetId, range, text) { |
| 285 /** | 285 /** |
| 286 * @param {?Protocol.Error} error | 286 * @param {?Protocol.Error} error |
| 287 * @param {!Protocol.CSS.Value} payload | 287 * @param {!Protocol.CSS.Value} payload |
| 288 * @return {boolean} | 288 * @return {boolean} |
| 289 * @this {SDK.CSSModel} | 289 * @this {SDK.CSSModel} |
| 290 */ | 290 */ |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 /** | 533 /** |
| 534 * @param {!SDK.DOMNode} node | 534 * @param {!SDK.DOMNode} node |
| 535 * @return {?Array<string>} state | 535 * @return {?Array<string>} state |
| 536 */ | 536 */ |
| 537 pseudoState(node) { | 537 pseudoState(node) { |
| 538 return node.marker(SDK.CSSModel.PseudoStateMarker) || []; | 538 return node.marker(SDK.CSSModel.PseudoStateMarker) || []; |
| 539 } | 539 } |
| 540 | 540 |
| 541 /** | 541 /** |
| 542 * @param {!Protocol.CSS.StyleSheetId} styleSheetId | 542 * @param {!Protocol.CSS.StyleSheetId} styleSheetId |
| 543 * @param {!Common.TextRange} range | 543 * @param {!TextUtils.TextRange} range |
| 544 * @param {string} newMediaText | 544 * @param {string} newMediaText |
| 545 * @return {!Promise<boolean>} | 545 * @return {!Promise<boolean>} |
| 546 */ | 546 */ |
| 547 setMediaText(styleSheetId, range, newMediaText) { | 547 setMediaText(styleSheetId, range, newMediaText) { |
| 548 /** | 548 /** |
| 549 * @param {?Protocol.Error} error | 549 * @param {?Protocol.Error} error |
| 550 * @param {!Protocol.CSS.CSSMedia} mediaPayload | 550 * @param {!Protocol.CSS.CSSMedia} mediaPayload |
| 551 * @return {boolean} | 551 * @return {boolean} |
| 552 * @this {SDK.CSSModel} | 552 * @this {SDK.CSSModel} |
| 553 */ | 553 */ |
| 554 function parsePayload(error, mediaPayload) { | 554 function parsePayload(error, mediaPayload) { |
| 555 if (!mediaPayload) | 555 if (!mediaPayload) |
| 556 return false; | 556 return false; |
| 557 this._domModel.markUndoableState(); | 557 this._domModel.markUndoableState(); |
| 558 var edit = new SDK.CSSModel.Edit(styleSheetId, range, newMediaText, mediaP
ayload); | 558 var edit = new SDK.CSSModel.Edit(styleSheetId, range, newMediaText, mediaP
ayload); |
| 559 this._fireStyleSheetChanged(styleSheetId, edit); | 559 this._fireStyleSheetChanged(styleSheetId, edit); |
| 560 return true; | 560 return true; |
| 561 } | 561 } |
| 562 | 562 |
| 563 Host.userMetrics.actionTaken(Host.UserMetrics.Action.StyleRuleEdited); | 563 Host.userMetrics.actionTaken(Host.UserMetrics.Action.StyleRuleEdited); |
| 564 return this._ensureOriginalStyleSheetText(styleSheetId) | 564 return this._ensureOriginalStyleSheetText(styleSheetId) |
| 565 .then(() => this._agent.setMediaText(styleSheetId, range, newMediaText,
parsePayload.bind(this))) | 565 .then(() => this._agent.setMediaText(styleSheetId, range, newMediaText,
parsePayload.bind(this))) |
| 566 .catchException(false); | 566 .catchException(false); |
| 567 } | 567 } |
| 568 | 568 |
| 569 /** | 569 /** |
| 570 * @param {!Protocol.CSS.StyleSheetId} styleSheetId | 570 * @param {!Protocol.CSS.StyleSheetId} styleSheetId |
| 571 * @param {string} ruleText | 571 * @param {string} ruleText |
| 572 * @param {!Common.TextRange} ruleLocation | 572 * @param {!TextUtils.TextRange} ruleLocation |
| 573 * @return {!Promise<?SDK.CSSStyleRule>} | 573 * @return {!Promise<?SDK.CSSStyleRule>} |
| 574 */ | 574 */ |
| 575 addRule(styleSheetId, ruleText, ruleLocation) { | 575 addRule(styleSheetId, ruleText, ruleLocation) { |
| 576 return this._ensureOriginalStyleSheetText(styleSheetId) | 576 return this._ensureOriginalStyleSheetText(styleSheetId) |
| 577 .then(() => this._agent.addRule(styleSheetId, ruleText, ruleLocation, pa
rsePayload.bind(this))) | 577 .then(() => this._agent.addRule(styleSheetId, ruleText, ruleLocation, pa
rsePayload.bind(this))) |
| 578 .catchException(/** @type {?SDK.CSSStyleRule} */ (null)); | 578 .catchException(/** @type {?SDK.CSSStyleRule} */ (null)); |
| 579 | 579 |
| 580 /** | 580 /** |
| 581 * @param {?Protocol.Error} error | 581 * @param {?Protocol.Error} error |
| 582 * @param {?Protocol.CSS.CSSRule} rulePayload | 582 * @param {?Protocol.CSS.CSSRule} rulePayload |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 ['all', 'braille', 'embossed', 'handheld', 'print', 'projection', 'screen',
'speech', 'tty', 'tv']; | 881 ['all', 'braille', 'embossed', 'handheld', 'print', 'projection', 'screen',
'speech', 'tty', 'tv']; |
| 882 | 882 |
| 883 SDK.CSSModel.PseudoStateMarker = 'pseudo-state-marker'; | 883 SDK.CSSModel.PseudoStateMarker = 'pseudo-state-marker'; |
| 884 | 884 |
| 885 /** | 885 /** |
| 886 * @unrestricted | 886 * @unrestricted |
| 887 */ | 887 */ |
| 888 SDK.CSSModel.Edit = class { | 888 SDK.CSSModel.Edit = class { |
| 889 /** | 889 /** |
| 890 * @param {!Protocol.CSS.StyleSheetId} styleSheetId | 890 * @param {!Protocol.CSS.StyleSheetId} styleSheetId |
| 891 * @param {!Common.TextRange} oldRange | 891 * @param {!TextUtils.TextRange} oldRange |
| 892 * @param {string} newText | 892 * @param {string} newText |
| 893 * @param {?Object} payload | 893 * @param {?Object} payload |
| 894 */ | 894 */ |
| 895 constructor(styleSheetId, oldRange, newText, payload) { | 895 constructor(styleSheetId, oldRange, newText, payload) { |
| 896 this.styleSheetId = styleSheetId; | 896 this.styleSheetId = styleSheetId; |
| 897 this.oldRange = oldRange; | 897 this.oldRange = oldRange; |
| 898 this.newRange = Common.TextRange.fromEdit(oldRange, newText); | 898 this.newRange = TextUtils.TextRange.fromEdit(oldRange, newText); |
| 899 this.payload = payload; | 899 this.payload = payload; |
| 900 } | 900 } |
| 901 }; | 901 }; |
| 902 | 902 |
| 903 SDK.CSSLocation = class { | 903 SDK.CSSLocation = class { |
| 904 /** | 904 /** |
| 905 * @param {!SDK.CSSStyleSheetHeader} header | 905 * @param {!SDK.CSSStyleSheetHeader} header |
| 906 * @param {number} lineNumber | 906 * @param {number} lineNumber |
| 907 * @param {number=} columnNumber | 907 * @param {number=} columnNumber |
| 908 */ | 908 */ |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 SDK.CSSModel.InlineStyleResult = class { | 1038 SDK.CSSModel.InlineStyleResult = class { |
| 1039 /** | 1039 /** |
| 1040 * @param {?SDK.CSSStyleDeclaration} inlineStyle | 1040 * @param {?SDK.CSSStyleDeclaration} inlineStyle |
| 1041 * @param {?SDK.CSSStyleDeclaration} attributesStyle | 1041 * @param {?SDK.CSSStyleDeclaration} attributesStyle |
| 1042 */ | 1042 */ |
| 1043 constructor(inlineStyle, attributesStyle) { | 1043 constructor(inlineStyle, attributesStyle) { |
| 1044 this.inlineStyle = inlineStyle; | 1044 this.inlineStyle = inlineStyle; |
| 1045 this.attributesStyle = attributesStyle; | 1045 this.attributesStyle = attributesStyle; |
| 1046 } | 1046 } |
| 1047 }; | 1047 }; |
| OLD | NEW |