Chromium Code Reviews| 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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 var result = []; | 550 var result = []; |
| 551 for (var frameId in frameIdToStyleSheetIds) | 551 for (var frameId in frameIdToStyleSheetIds) |
| 552 result = result.concat(frameIdToStyleSheetIds[frameId]); | 552 result = result.concat(frameIdToStyleSheetIds[frameId]); |
| 553 return result; | 553 return result; |
| 554 }, | 554 }, |
| 555 | 555 |
| 556 /** | 556 /** |
| 557 * @param {!CSSAgent.StyleSheetId} styleSheetId | 557 * @param {!CSSAgent.StyleSheetId} styleSheetId |
| 558 * @param {string} newText | 558 * @param {string} newText |
| 559 * @param {boolean} majorChange | 559 * @param {boolean} majorChange |
| 560 * @param {?function(?Protocol.Error)} userCallback | 560 * @return {!Promise.<?Protocol.Error>} |
| 561 */ | 561 */ |
| 562 setStyleSheetText: function(styleSheetId, newText, majorChange, userCallback ) | 562 setStyleSheetText: function(styleSheetId, newText, majorChange) |
| 563 { | 563 { |
| 564 var header = this._styleSheetIdToHeader.get(styleSheetId); | 564 var header = this._styleSheetIdToHeader.get(styleSheetId); |
| 565 console.assert(header); | 565 console.assert(header); |
| 566 this._pendingCommandsMajorState.push(majorChange); | 566 this._pendingCommandsMajorState.push(majorChange); |
| 567 header.setContent(newText, callback.bind(this)); | 567 return header._setContentPromise(newText).then(callback.bind(this)); |
| 568 | 568 |
| 569 /** | 569 /** |
| 570 * @param {?Protocol.Error} error | 570 * @param {?Protocol.Error} error |
| 571 * @return {?Protocol.Error} | |
| 571 * @this {WebInspector.CSSStyleModel} | 572 * @this {WebInspector.CSSStyleModel} |
| 572 */ | 573 */ |
| 573 function callback(error) | 574 function callback(error) |
| 574 { | 575 { |
| 575 this._pendingCommandsMajorState.pop(); | 576 this._pendingCommandsMajorState.pop(); |
| 576 if (!error && majorChange) | 577 if (!error && majorChange) |
| 577 this._domModel.markUndoableState(); | 578 this._domModel.markUndoableState(); |
| 578 | 579 |
| 579 if (!error && userCallback) | 580 return error; |
| 580 userCallback(error); | |
| 581 } | 581 } |
| 582 }, | 582 }, |
| 583 | 583 |
| 584 _undoRedoRequested: function() | 584 _undoRedoRequested: function() |
| 585 { | 585 { |
| 586 this._pendingCommandsMajorState.push(true); | 586 this._pendingCommandsMajorState.push(true); |
| 587 }, | 587 }, |
| 588 | 588 |
| 589 _undoRedoCompleted: function() | 589 _undoRedoCompleted: function() |
| 590 { | 590 { |
| (...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1800 { | 1800 { |
| 1801 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex)); | 1801 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex)); |
| 1802 } | 1802 } |
| 1803 | 1803 |
| 1804 // searchInContent should call back later. | 1804 // searchInContent should call back later. |
| 1805 this.requestContent(performSearch); | 1805 this.requestContent(performSearch); |
| 1806 }, | 1806 }, |
| 1807 | 1807 |
| 1808 /** | 1808 /** |
| 1809 * @param {string} newText | 1809 * @param {string} newText |
| 1810 * @param {function(?Protocol.Error)} callback | 1810 * @return {!Promise.<?Protocol.Error>} |
| 1811 */ | 1811 */ |
| 1812 setContent: function(newText, callback) | 1812 _setContentPromise: function(newText) |
| 1813 { | 1813 { |
| 1814 newText = this._trimSourceURL(newText); | 1814 newText = this._trimSourceURL(newText); |
| 1815 if (this.hasSourceURL) | 1815 if (this.hasSourceURL) |
| 1816 newText += "\n/*# sourceURL=" + this.sourceURL + " */"; | 1816 newText += "\n/*# sourceURL=" + this.sourceURL + " */"; |
| 1817 this._cssModel._agent.setStyleSheetText(this.id, newText, extractProtoco lError) | 1817 return this._cssModel._agent.setStyleSheetText(this.id, newText, extract ProtocolError); |
| 1818 .then(callback); | |
| 1819 | 1818 |
| 1820 /** | 1819 /** |
| 1821 * @param {?Protocol.Error} error | 1820 * @param {?Protocol.Error} error |
| 1821 * @return {?Protocol.Error} | |
| 1822 */ | 1822 */ |
| 1823 function extractProtocolError(error) | 1823 function extractProtocolError(error) |
| 1824 { | 1824 { |
| 1825 return error || null; | 1825 return error || null; |
| 1826 } | 1826 } |
| 1827 }, | 1827 }, |
| 1828 | 1828 |
| 1829 /** | 1829 /** |
| 1830 * @param {string} newText | |
| 1831 * @param {function(?Protocol.Error)} callback | |
| 1832 */ | |
| 1833 setContent: function(newText, callback) | |
| 1834 { | |
| 1835 this._setContentPromise(newText) | |
|
pfeldman
2015/06/26 09:13:42
Add fixme to remove
lushnikov
2015/06/26 12:33:28
Acknowledged.
| |
| 1836 .catchException(null) | |
| 1837 .then(callback); | |
| 1838 }, | |
| 1839 | |
| 1840 /** | |
| 1830 * @return {boolean} | 1841 * @return {boolean} |
| 1831 */ | 1842 */ |
| 1832 isViaInspector: function() | 1843 isViaInspector: function() |
| 1833 { | 1844 { |
| 1834 return this.origin === "inspector"; | 1845 return this.origin === "inspector"; |
| 1835 } | 1846 } |
| 1836 } | 1847 } |
| 1837 | 1848 |
| 1838 /** | 1849 /** |
| 1839 * @constructor | 1850 * @constructor |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1988 * @constructor | 1999 * @constructor |
| 1989 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle | 2000 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle |
| 1990 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle | 2001 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle |
| 1991 */ | 2002 */ |
| 1992 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS tyle) | 2003 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS tyle) |
| 1993 { | 2004 { |
| 1994 this.inlineStyle = inlineStyle; | 2005 this.inlineStyle = inlineStyle; |
| 1995 this.attributesStyle = attributesStyle; | 2006 this.attributesStyle = attributesStyle; |
| 1996 } | 2007 } |
| 1997 | 2008 |
| OLD | NEW |