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

Unified Diff: third_party/WebKit/Source/devtools/front_end/audits/AuditFormatters.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/audits/AuditFormatters.js
diff --git a/third_party/WebKit/Source/devtools/front_end/audits/AuditFormatters.js b/third_party/WebKit/Source/devtools/front_end/audits/AuditFormatters.js
index cdcaa97fe8136ab44baef0f87fde0f6d5422518f..c89625b65dc38c7aa0c008cf4c6bfd8b1267daa1 100644
--- a/third_party/WebKit/Source/devtools/front_end/audits/AuditFormatters.js
+++ b/third_party/WebKit/Source/devtools/front_end/audits/AuditFormatters.js
@@ -27,120 +27,108 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
/**
- * @constructor
+ * @unrestricted
*/
-WebInspector.AuditFormatters = function()
-{
-};
-
-WebInspector.AuditFormatters.Registry = {
-
- /**
- * @param {string} text
- * @return {!Text}
- */
- text: function(text)
- {
- return createTextNode(text);
- },
+WebInspector.AuditFormatters = class {
+ /**
+ * @param {string|boolean|number|!Object} value
+ * @return {!Node}
+ */
+ apply(value) {
+ var formatter;
+ var type = typeof value;
+ var args;
- /**
- * @param {string} snippetText
- * @return {!Element}
- */
- snippet: function(snippetText)
- {
- var div = createElement("div");
- div.textContent = snippetText;
- div.className = "source-code";
- return div;
- },
+ switch (type) {
+ case 'string':
+ case 'boolean':
+ case 'number':
+ formatter = WebInspector.AuditFormatters.Registry.text;
+ args = [value.toString()];
+ break;
- /**
- * @return {!Element}
- */
- concat: function()
- {
- var parent = createElement("span");
- for (var arg = 0; arg < arguments.length; ++arg)
- parent.appendChild(WebInspector.auditFormatters.apply(arguments[arg]));
- return parent;
- },
+ case 'object':
+ if (value instanceof Node)
+ return value;
+ if (Array.isArray(value)) {
+ formatter = WebInspector.AuditFormatters.Registry.concat;
+ args = value;
+ } else if (value.type && value.arguments) {
+ formatter = WebInspector.AuditFormatters.Registry[value.type];
+ args = value.arguments;
+ }
+ }
+ if (!formatter)
+ throw 'Invalid value or formatter: ' + type + JSON.stringify(value);
- /**
- * @param {string} url
- * @param {string=} displayText
- * @return {!Element}
- */
- url: function(url, displayText)
- {
- return WebInspector.linkifyURLAsNode(url, displayText, undefined, true);
- },
+ return formatter.apply(null, args);
+ }
- /**
- * @param {string} url
- * @param {number=} line
- * @return {!Element}
- */
- resourceLink: function(url, line)
- {
- // FIXME: use WebInspector.Linkifier
- return WebInspector.linkifyResourceAsNode(url, line, undefined, "resource-url webkit-html-resource-link");
- }
+ /**
+ * @param {!Object} formatters
+ * @param {?Object} thisArgument
+ * @param {string|boolean|number|!Object} value
+ * @return {*}
+ */
+ partiallyApply(formatters, thisArgument, value) {
+ if (Array.isArray(value))
+ return value.map(this.partiallyApply.bind(this, formatters, thisArgument));
+ if (typeof value === 'object' && typeof formatters[value.type] === 'function' && value.arguments)
+ return formatters[value.type].apply(thisArgument, value.arguments);
+ return value;
+ }
};
-WebInspector.AuditFormatters.prototype = {
- /**
- * @param {string|boolean|number|!Object} value
- * @return {!Node}
- */
- apply: function(value)
- {
- var formatter;
- var type = typeof value;
- var args;
+WebInspector.AuditFormatters.Registry = {
+
+ /**
+ * @param {string} text
+ * @return {!Text}
+ */
+ text: function(text) {
+ return createTextNode(text);
+ },
- switch (type) {
- case "string":
- case "boolean":
- case "number":
- formatter = WebInspector.AuditFormatters.Registry.text;
- args = [value.toString()];
- break;
+ /**
+ * @param {string} snippetText
+ * @return {!Element}
+ */
+ snippet: function(snippetText) {
+ var div = createElement('div');
+ div.textContent = snippetText;
+ div.className = 'source-code';
+ return div;
+ },
- case "object":
- if (value instanceof Node)
- return value;
- if (Array.isArray(value)) {
- formatter = WebInspector.AuditFormatters.Registry.concat;
- args = value;
- } else if (value.type && value.arguments) {
- formatter = WebInspector.AuditFormatters.Registry[value.type];
- args = value.arguments;
- }
- }
- if (!formatter)
- throw "Invalid value or formatter: " + type + JSON.stringify(value);
+ /**
+ * @return {!Element}
+ */
+ concat: function() {
+ var parent = createElement('span');
+ for (var arg = 0; arg < arguments.length; ++arg)
+ parent.appendChild(WebInspector.auditFormatters.apply(arguments[arg]));
+ return parent;
+ },
- return formatter.apply(null, args);
- },
+ /**
+ * @param {string} url
+ * @param {string=} displayText
+ * @return {!Element}
+ */
+ url: function(url, displayText) {
+ return WebInspector.linkifyURLAsNode(url, displayText, undefined, true);
+ },
- /**
- * @param {!Object} formatters
- * @param {?Object} thisArgument
- * @param {string|boolean|number|!Object} value
- * @return {*}
- */
- partiallyApply: function(formatters, thisArgument, value)
- {
- if (Array.isArray(value))
- return value.map(this.partiallyApply.bind(this, formatters, thisArgument));
- if (typeof value === "object" && typeof formatters[value.type] === "function" && value.arguments)
- return formatters[value.type].apply(thisArgument, value.arguments);
- return value;
- }
+ /**
+ * @param {string} url
+ * @param {number=} line
+ * @return {!Element}
+ */
+ resourceLink: function(url, line) {
+ // FIXME: use WebInspector.Linkifier
+ return WebInspector.linkifyResourceAsNode(url, line, undefined, 'resource-url webkit-html-resource-link');
+ }
};
WebInspector.auditFormatters = new WebInspector.AuditFormatters();

Powered by Google App Engine
This is Rietveld 408576698