Index: third_party/WebKit/Source/devtools/front_end/sdk/CSSParser.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CSSParser.js b/third_party/WebKit/Source/devtools/front_end/sdk/CSSParser.js |
index da7a3627c1e83697c4cd2ff86c9b69cabbee0b08..7263470987631fd8ec9c98ea6f73a691ae136f6d 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/sdk/CSSParser.js |
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/CSSParser.js |
@@ -3,141 +3,125 @@ |
* Use of this source code is governed by a BSD-style license that can be |
* found in the LICENSE file. |
*/ |
- |
/** |
- * @constructor |
- * @extends {WebInspector.Object} |
+ * @unrestricted |
*/ |
-WebInspector.CSSParser = function() |
-{ |
+WebInspector.CSSParser = class extends WebInspector.Object { |
+ constructor() { |
+ super(); |
this._rules = []; |
this._terminated = false; |
-}; |
- |
-/** @enum {symbol} */ |
-WebInspector.CSSParser.Events = { |
- RulesParsed: Symbol("RulesParsed") |
-}; |
- |
-WebInspector.CSSParser.prototype = { |
- /** |
- * @param {!WebInspector.CSSStyleSheetHeader} styleSheetHeader |
- * @param {function(!Array.<!WebInspector.CSSParser.Rule>)=} callback |
- */ |
- fetchAndParse: function(styleSheetHeader, callback) |
- { |
- this._lock(); |
- this._finishedCallback = callback; |
- styleSheetHeader.requestContent().then(this._innerParse.bind(this)); |
- }, |
+ } |
+ |
+ /** |
+ * @param {!WebInspector.CSSStyleSheetHeader} styleSheetHeader |
+ * @param {function(!Array.<!WebInspector.CSSParser.Rule>)=} callback |
+ */ |
+ fetchAndParse(styleSheetHeader, callback) { |
+ this._lock(); |
+ this._finishedCallback = callback; |
+ styleSheetHeader.requestContent().then(this._innerParse.bind(this)); |
+ } |
+ |
+ /** |
+ * @param {string} text |
+ * @param {function(!Array.<!WebInspector.CSSParser.Rule>)=} callback |
+ */ |
+ parse(text, callback) { |
+ this._lock(); |
+ this._finishedCallback = callback; |
+ this._innerParse(text); |
+ } |
+ |
+ /** |
+ * @param {string} text |
+ * @return {!Promise<!Array.<!WebInspector.CSSParser.Rule>>} |
+ */ |
+ parsePromise(text) { |
+ return new Promise(promiseConstructor.bind(this)); |
/** |
- * @param {string} text |
- * @param {function(!Array.<!WebInspector.CSSParser.Rule>)=} callback |
+ * @param {function()} succ |
+ * @param {function()} fail |
+ * @this {WebInspector.CSSParser} |
*/ |
- parse: function(text, callback) |
- { |
- this._lock(); |
- this._finishedCallback = callback; |
- this._innerParse(text); |
- }, |
- |
- /** |
- * @param {string} text |
- * @return {!Promise<!Array.<!WebInspector.CSSParser.Rule>>} |
- */ |
- parsePromise: function(text) |
- { |
- return new Promise(promiseConstructor.bind(this)); |
- |
- /** |
- * @param {function()} succ |
- * @param {function()} fail |
- * @this {WebInspector.CSSParser} |
- */ |
- function promiseConstructor(succ, fail) |
- { |
- this.parse(text, succ); |
- } |
- }, |
- |
- dispose: function() |
- { |
- if (this._terminated) |
- return; |
- this._terminated = true; |
- this._runFinishedCallback([]); |
- }, |
- |
- /** |
- * @return {!Array.<!WebInspector.CSSParser.Rule>} |
- */ |
- rules: function() |
- { |
- return this._rules; |
- }, |
- |
- _lock: function() |
- { |
- console.assert(!this._parsingStyleSheet, "Received request to parse stylesheet before previous was completed."); |
- this._parsingStyleSheet = true; |
- }, |
- |
- _unlock: function() |
- { |
- delete this._parsingStyleSheet; |
- }, |
- |
- /** |
- * @param {?string} text |
- */ |
- _innerParse: function(text) |
- { |
- this._rules = []; |
- var params = { content: text }; |
- WebInspector.formatterWorkerPool.runChunkedTask("parseCSS", params, this._onRuleChunk.bind(this)); |
- }, |
- |
- /** |
- * @param {?MessageEvent} event |
- */ |
- _onRuleChunk: function(event) |
- { |
- if (this._terminated) |
- return; |
- if (!event) { |
- this._onFinishedParsing(); |
- this.dispatchEventToListeners(WebInspector.CSSParser.Events.RulesParsed); |
- return; |
- } |
- var data = /** @type {!WebInspector.CSSParser.DataChunk} */ (event.data); |
- var chunk = data.chunk; |
- for (var i = 0; i < chunk.length; ++i) |
- this._rules.push(chunk[i]); |
- |
- if (data.isLastChunk) |
- this._onFinishedParsing(); |
- this.dispatchEventToListeners(WebInspector.CSSParser.Events.RulesParsed); |
- }, |
- |
- _onFinishedParsing: function() |
- { |
- this._unlock(); |
- this._runFinishedCallback(this._rules); |
- }, |
+ function promiseConstructor(succ, fail) { |
+ this.parse(text, succ); |
+ } |
+ } |
+ |
+ dispose() { |
+ if (this._terminated) |
+ return; |
+ this._terminated = true; |
+ this._runFinishedCallback([]); |
+ } |
+ |
+ /** |
+ * @return {!Array.<!WebInspector.CSSParser.Rule>} |
+ */ |
+ rules() { |
+ return this._rules; |
+ } |
+ |
+ _lock() { |
+ console.assert(!this._parsingStyleSheet, 'Received request to parse stylesheet before previous was completed.'); |
+ this._parsingStyleSheet = true; |
+ } |
+ |
+ _unlock() { |
+ delete this._parsingStyleSheet; |
+ } |
+ |
+ /** |
+ * @param {?string} text |
+ */ |
+ _innerParse(text) { |
+ this._rules = []; |
+ var params = {content: text}; |
+ WebInspector.formatterWorkerPool.runChunkedTask('parseCSS', params, this._onRuleChunk.bind(this)); |
+ } |
+ |
+ /** |
+ * @param {?MessageEvent} event |
+ */ |
+ _onRuleChunk(event) { |
+ if (this._terminated) |
+ return; |
+ if (!event) { |
+ this._onFinishedParsing(); |
+ this.dispatchEventToListeners(WebInspector.CSSParser.Events.RulesParsed); |
+ return; |
+ } |
+ var data = /** @type {!WebInspector.CSSParser.DataChunk} */ (event.data); |
+ var chunk = data.chunk; |
+ for (var i = 0; i < chunk.length; ++i) |
+ this._rules.push(chunk[i]); |
+ |
+ if (data.isLastChunk) |
+ this._onFinishedParsing(); |
+ this.dispatchEventToListeners(WebInspector.CSSParser.Events.RulesParsed); |
+ } |
+ |
+ _onFinishedParsing() { |
+ this._unlock(); |
+ this._runFinishedCallback(this._rules); |
+ } |
+ |
+ /** |
+ * @param {!Array<!WebInspector.CSSRule>} rules |
+ */ |
+ _runFinishedCallback(rules) { |
+ var callback = this._finishedCallback; |
+ delete this._finishedCallback; |
+ if (callback) |
+ callback.call(null, rules); |
+ } |
+}; |
- /** |
- * @param {!Array<!WebInspector.CSSRule>} rules |
- */ |
- _runFinishedCallback: function(rules) |
- { |
- var callback = this._finishedCallback; |
- delete this._finishedCallback; |
- if (callback) |
- callback.call(null, rules); |
- }, |
- |
- __proto__: WebInspector.Object.prototype, |
+/** @enum {symbol} */ |
+WebInspector.CSSParser.Events = { |
+ RulesParsed: Symbol('RulesParsed') |
}; |
/** |
@@ -146,10 +130,10 @@ WebInspector.CSSParser.prototype = { |
WebInspector.CSSParser.DataChunk; |
/** |
- * @constructor |
+ * @unrestricted |
*/ |
-WebInspector.CSSParser.StyleRule = function() |
-{ |
+WebInspector.CSSParser.StyleRule = class { |
+ constructor() { |
/** @type {string} */ |
this.selectorText; |
/** @type {!WebInspector.CSSParser.Range} */ |
@@ -160,6 +144,7 @@ WebInspector.CSSParser.StyleRule = function() |
this.columnNumber; |
/** @type {!Array.<!WebInspector.CSSParser.Property>} */ |
this.properties; |
+ } |
}; |
/** |
@@ -178,10 +163,10 @@ WebInspector.CSSParser.Rule; |
WebInspector.CSSParser.Range; |
/** |
- * @constructor |
+ * @unrestricted |
*/ |
-WebInspector.CSSParser.Property = function() |
-{ |
+WebInspector.CSSParser.Property = class { |
+ constructor() { |
/** @type {string} */ |
this.name; |
/** @type {!WebInspector.CSSParser.Range} */ |
@@ -194,4 +179,5 @@ WebInspector.CSSParser.Property = function() |
this.range; |
/** @type {(boolean|undefined)} */ |
this.disabled; |
+ } |
}; |