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

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

Issue 1609973002: DevTools: promisify ContentProvider.requestContent and all its clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaseline Created 4 years, 11 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
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 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 return text; 1900 return text;
1901 var sourceURLLine = text.substr(sourceURLLineIndex + 1).split("\n", 1)[0 ]; 1901 var sourceURLLine = text.substr(sourceURLLineIndex + 1).split("\n", 1)[0 ];
1902 var sourceURLRegex = /[\040\t]*\/\*# sourceURL=[\040\t]*([^\s]*)[\040\t] *\*\/[\040\t]*$/; 1902 var sourceURLRegex = /[\040\t]*\/\*# sourceURL=[\040\t]*([^\s]*)[\040\t] *\*\/[\040\t]*$/;
1903 if (sourceURLLine.search(sourceURLRegex) === -1) 1903 if (sourceURLLine.search(sourceURLRegex) === -1)
1904 return text; 1904 return text;
1905 return text.substr(0, sourceURLLineIndex) + text.substr(sourceURLLineInd ex + sourceURLLine.length + 1); 1905 return text.substr(0, sourceURLLineIndex) + text.substr(sourceURLLineInd ex + sourceURLLine.length + 1);
1906 }, 1906 },
1907 1907
1908 /** 1908 /**
1909 * @override 1909 * @override
1910 * @param {function(string)} userCallback 1910 * @return {!Promise<?string>}
1911 */ 1911 */
1912 requestContent: function(userCallback) 1912 requestContent: function()
1913 { 1913 {
1914 this._cssModel._agent.getStyleSheetText(this.id, textCallback.bind(this) ) 1914 return this._cssModel._agent.getStyleSheetText(this.id, textCallback.bin d(this))
1915 .catchException("") 1915 .catchException(/** @type {?string} */(""));
1916 .then(userCallback)
1917 1916
1918 /** 1917 /**
1919 * @param {?Protocol.Error} error 1918 * @param {?Protocol.Error} error
1920 * @param {?string} text 1919 * @param {?string} text
1921 * @return {string} 1920 * @return {string}
1922 * @this {WebInspector.CSSStyleSheetHeader} 1921 * @this {WebInspector.CSSStyleSheetHeader}
1923 */ 1922 */
1924 function textCallback(error, text) 1923 function textCallback(error, text)
1925 { 1924 {
1926 if (error || text === null) { 1925 if (error || text === null) {
1927 WebInspector.console.error("Failed to get text for stylesheet " + this.id + ": " + error) 1926 WebInspector.console.error("Failed to get text for stylesheet " + this.id + ": " + error)
1928 text = ""; 1927 text = "";
1929 // Fall through. 1928 // Fall through.
1930 } 1929 }
1931 return this._trimSourceURL(text); 1930 return this._trimSourceURL(text);
1932 } 1931 }
1933 }, 1932 },
1934 1933
1935 /** 1934 /**
1936 * @override 1935 * @override
1937 */ 1936 */
1938 searchInContent: function(query, caseSensitive, isRegex, callback) 1937 searchInContent: function(query, caseSensitive, isRegex, callback)
1939 { 1938 {
1940 function performSearch(content) 1939 function performSearch(content)
1941 { 1940 {
1942 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex)); 1941 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex));
1943 } 1942 }
1944 1943
1945 // searchInContent should call back later. 1944 // searchInContent should call back later.
1946 this.requestContent(performSearch); 1945 this.requestContent().then(performSearch);
1947 }, 1946 },
1948 1947
1949 /** 1948 /**
1950 * @param {string} newText 1949 * @param {string} newText
1951 * @return {!Promise.<?Protocol.Error>} 1950 * @return {!Promise.<?Protocol.Error>}
1952 */ 1951 */
1953 _setContentPromise: function(newText) 1952 _setContentPromise: function(newText)
1954 { 1953 {
1955 newText = this._trimSourceURL(newText); 1954 newText = this._trimSourceURL(newText);
1956 if (this.hasSourceURL) 1955 if (this.hasSourceURL)
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 * @constructor 2420 * @constructor
2422 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle 2421 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle
2423 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle 2422 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle
2424 */ 2423 */
2425 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS tyle) 2424 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS tyle)
2426 { 2425 {
2427 this.inlineStyle = inlineStyle; 2426 this.inlineStyle = inlineStyle;
2428 this.attributesStyle = attributesStyle; 2427 this.attributesStyle = attributesStyle;
2429 } 2428 }
2430 2429
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698