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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js b/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js
index 1d09b7e5e7921f548a797ed4e7050e4ed96d4738..0e700bb0c2ccaf3a32d7f35247abe4a68b3f688e 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleSheetHeader.js
@@ -1,15 +1,16 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
/**
- * @constructor
* @implements {WebInspector.ContentProvider}
- * @param {!WebInspector.CSSModel} cssModel
- * @param {!CSSAgent.CSSStyleSheetHeader} payload
+ * @unrestricted
*/
-WebInspector.CSSStyleSheetHeader = function(cssModel, payload)
-{
+WebInspector.CSSStyleSheetHeader = class {
+ /**
+ * @param {!WebInspector.CSSModel} cssModel
+ * @param {!CSSAgent.CSSStyleSheetHeader} payload
+ */
+ constructor(cssModel, payload) {
this._cssModel = cssModel;
this.id = payload.styleSheetId;
this.frameId = payload.frameId;
@@ -22,201 +23,186 @@ WebInspector.CSSStyleSheetHeader = function(cssModel, payload)
this.startLine = payload.startLine;
this.startColumn = payload.startColumn;
if (payload.ownerNode)
- this.ownerNode = new WebInspector.DeferredDOMNode(cssModel.target(), payload.ownerNode);
+ this.ownerNode = new WebInspector.DeferredDOMNode(cssModel.target(), payload.ownerNode);
this.setSourceMapURL(payload.sourceMapURL);
-};
-
-WebInspector.CSSStyleSheetHeader.prototype = {
- /**
- * @return {!WebInspector.ContentProvider}
- */
- originalContentProvider: function()
- {
- if (!this._originalContentProvider) {
- var lazyContent = this._cssModel.originalStyleSheetText.bind(this._cssModel, this);
- this._originalContentProvider = new WebInspector.StaticContentProvider(this.contentURL(), this.contentType(), lazyContent);
- }
- return this._originalContentProvider;
- },
-
- /**
- * @param {string=} sourceMapURL
- */
- setSourceMapURL: function(sourceMapURL)
- {
- var completeSourceMapURL = this.sourceURL && sourceMapURL ? WebInspector.ParsedURL.completeURL(this.sourceURL, sourceMapURL) : sourceMapURL;
- this.sourceMapURL = completeSourceMapURL;
- },
-
- /**
- * @return {!WebInspector.Target}
- */
- target: function()
- {
- return this._cssModel.target();
- },
-
- /**
- * @return {!WebInspector.CSSModel}
- */
- cssModel: function()
- {
- return this._cssModel;
- },
-
- /**
- * @return {string}
- */
- resourceURL: function()
- {
- return this.isViaInspector() ? this._viaInspectorResourceURL() : this.sourceURL;
- },
-
- /**
- * @return {string}
- */
- _viaInspectorResourceURL: function()
- {
- var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(this.target());
- var frame = resourceTreeModel.frameForId(this.frameId);
- console.assert(frame);
- var parsedURL = new WebInspector.ParsedURL(frame.url);
- var fakeURL = "inspector://" + parsedURL.host + parsedURL.folderPathComponents;
- if (!fakeURL.endsWith("/"))
- fakeURL += "/";
- fakeURL += "inspector-stylesheet";
- return fakeURL;
- },
-
- /**
- * @param {number} lineNumberInStyleSheet
- * @return {number}
- */
- lineNumberInSource: function(lineNumberInStyleSheet)
- {
- return this.startLine + lineNumberInStyleSheet;
- },
-
- /**
- * @param {number} lineNumberInStyleSheet
- * @param {number} columnNumberInStyleSheet
- * @return {number|undefined}
- */
- columnNumberInSource: function(lineNumberInStyleSheet, columnNumberInStyleSheet)
- {
- return (lineNumberInStyleSheet ? 0 : this.startColumn) + columnNumberInStyleSheet;
- },
-
- /**
- * @override
- * @return {string}
- */
- contentURL: function()
- {
- return this.resourceURL();
- },
-
- /**
- * @override
- * @return {!WebInspector.ResourceType}
- */
- contentType: function()
- {
- return WebInspector.resourceTypes.Stylesheet;
- },
-
- /**
- * @override
- * @return {!Promise<?string>}
- */
- requestContent: function()
- {
- return /** @type {!Promise<?string>} */(this._cssModel.getStyleSheetText(this.id));
- },
-
- /**
- * @override
- * @param {string} query
- * @param {boolean} caseSensitive
- * @param {boolean} isRegex
- * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callback
- */
- searchInContent: function(query, caseSensitive, isRegex, callback)
- {
- function performSearch(content)
- {
- callback(WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex));
- }
+ }
+
+ /**
+ * @return {!WebInspector.ContentProvider}
+ */
+ originalContentProvider() {
+ if (!this._originalContentProvider) {
+ var lazyContent = this._cssModel.originalStyleSheetText.bind(this._cssModel, this);
+ this._originalContentProvider =
+ new WebInspector.StaticContentProvider(this.contentURL(), this.contentType(), lazyContent);
+ }
+ return this._originalContentProvider;
+ }
+
+ /**
+ * @param {string=} sourceMapURL
+ */
+ setSourceMapURL(sourceMapURL) {
+ var completeSourceMapURL = this.sourceURL && sourceMapURL ?
+ WebInspector.ParsedURL.completeURL(this.sourceURL, sourceMapURL) :
+ sourceMapURL;
+ this.sourceMapURL = completeSourceMapURL;
+ }
+
+ /**
+ * @return {!WebInspector.Target}
+ */
+ target() {
+ return this._cssModel.target();
+ }
+
+ /**
+ * @return {!WebInspector.CSSModel}
+ */
+ cssModel() {
+ return this._cssModel;
+ }
+
+ /**
+ * @return {string}
+ */
+ resourceURL() {
+ return this.isViaInspector() ? this._viaInspectorResourceURL() : this.sourceURL;
+ }
+
+ /**
+ * @return {string}
+ */
+ _viaInspectorResourceURL() {
+ var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(this.target());
+ var frame = resourceTreeModel.frameForId(this.frameId);
+ console.assert(frame);
+ var parsedURL = new WebInspector.ParsedURL(frame.url);
+ var fakeURL = 'inspector://' + parsedURL.host + parsedURL.folderPathComponents;
+ if (!fakeURL.endsWith('/'))
+ fakeURL += '/';
+ fakeURL += 'inspector-stylesheet';
+ return fakeURL;
+ }
+
+ /**
+ * @param {number} lineNumberInStyleSheet
+ * @return {number}
+ */
+ lineNumberInSource(lineNumberInStyleSheet) {
+ return this.startLine + lineNumberInStyleSheet;
+ }
+
+ /**
+ * @param {number} lineNumberInStyleSheet
+ * @param {number} columnNumberInStyleSheet
+ * @return {number|undefined}
+ */
+ columnNumberInSource(lineNumberInStyleSheet, columnNumberInStyleSheet) {
+ return (lineNumberInStyleSheet ? 0 : this.startColumn) + columnNumberInStyleSheet;
+ }
+
+ /**
+ * @override
+ * @return {string}
+ */
+ contentURL() {
+ return this.resourceURL();
+ }
+
+ /**
+ * @override
+ * @return {!WebInspector.ResourceType}
+ */
+ contentType() {
+ return WebInspector.resourceTypes.Stylesheet;
+ }
+
+ /**
+ * @override
+ * @return {!Promise<?string>}
+ */
+ requestContent() {
+ return /** @type {!Promise<?string>} */ (this._cssModel.getStyleSheetText(this.id));
+ }
+
+ /**
+ * @override
+ * @param {string} query
+ * @param {boolean} caseSensitive
+ * @param {boolean} isRegex
+ * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callback
+ */
+ searchInContent(query, caseSensitive, isRegex, callback) {
+ function performSearch(content) {
+ callback(WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex));
+ }
- // searchInContent should call back later.
- this.requestContent().then(performSearch);
- },
+ // searchInContent should call back later.
+ this.requestContent().then(performSearch);
+ }
- /**
- * @return {boolean}
- */
- isViaInspector: function()
- {
- return this.origin === "inspector";
- }
+ /**
+ * @return {boolean}
+ */
+ isViaInspector() {
+ return this.origin === 'inspector';
+ }
};
/**
- * @constructor
* @implements {WebInspector.ContentProvider}
- * @param {!WebInspector.CSSStyleSheetHeader} header
+ * @unrestricted
*/
-WebInspector.CSSStyleSheetHeader.OriginalContentProvider = function(header)
-{
+WebInspector.CSSStyleSheetHeader.OriginalContentProvider = class {
+ /**
+ * @param {!WebInspector.CSSStyleSheetHeader} header
+ */
+ constructor(header) {
this._header = header;
-};
-
-WebInspector.CSSStyleSheetHeader.OriginalContentProvider.prototype = {
- /**
- * @override
- * @return {string}
- */
- contentURL: function()
- {
- return this._header.contentURL();
- },
-
- /**
- * @override
- * @return {!WebInspector.ResourceType}
- */
- contentType: function()
- {
- return this._header.contentType();
- },
-
- /**
- * @override
- * @return {!Promise<?string>}
- */
- requestContent: function()
- {
- return /** @type {!Promise<?string>} */(this._header.cssModel().originalStyleSheetText(this._header));
- },
-
- /**
- * @override
- * @param {string} query
- * @param {boolean} caseSensitive
- * @param {boolean} isRegex
- * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callback
- */
- searchInContent: function(query, caseSensitive, isRegex, callback)
- {
- /**
- * @param {?string} content
- */
- function performSearch(content)
- {
- var searchResults = content ? WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex) : [];
- callback(searchResults);
- }
-
- this.requestContent().then(performSearch);
+ }
+
+ /**
+ * @override
+ * @return {string}
+ */
+ contentURL() {
+ return this._header.contentURL();
+ }
+
+ /**
+ * @override
+ * @return {!WebInspector.ResourceType}
+ */
+ contentType() {
+ return this._header.contentType();
+ }
+
+ /**
+ * @override
+ * @return {!Promise<?string>}
+ */
+ requestContent() {
+ return /** @type {!Promise<?string>} */ (this._header.cssModel().originalStyleSheetText(this._header));
+ }
+
+ /**
+ * @override
+ * @param {string} query
+ * @param {boolean} caseSensitive
+ * @param {boolean} isRegex
+ * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callback
+ */
+ searchInContent(query, caseSensitive, isRegex, callback) {
+ /**
+ * @param {?string} content
+ */
+ function performSearch(content) {
+ var searchResults =
+ content ? WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex) : [];
+ callback(searchResults);
}
+
+ this.requestContent().then(performSearch);
+ }
};

Powered by Google App Engine
This is Rietveld 408576698