Add packages to optimize svgs dynamically
These packages will be used to dynamically optimize SVG images
during the build.
R=jacktfranklin@chromium.org
Bug: 1216402
Change-Id: I04e95aa7d79c9d67beaf8a7861182c52b16b7d0f
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2939992
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
diff --git a/node_modules/css-tree/lib/utils/clone.js b/node_modules/css-tree/lib/utils/clone.js
new file mode 100644
index 0000000..927294b
--- /dev/null
+++ b/node_modules/css-tree/lib/utils/clone.js
@@ -0,0 +1,21 @@
+var List = require('../common/List');
+
+module.exports = function clone(node) {
+ var result = {};
+
+ for (var key in node) {
+ var value = node[key];
+
+ if (value) {
+ if (Array.isArray(value) || value instanceof List) {
+ value = value.map(clone);
+ } else if (value.constructor === Object) {
+ value = clone(value);
+ }
+ }
+
+ result[key] = value;
+ }
+
+ return result;
+};
diff --git a/node_modules/css-tree/lib/utils/createCustomError.js b/node_modules/css-tree/lib/utils/createCustomError.js
new file mode 100644
index 0000000..59285d8
--- /dev/null
+++ b/node_modules/css-tree/lib/utils/createCustomError.js
@@ -0,0 +1,17 @@
+module.exports = function createCustomError(name, message) {
+ // use Object.create(), because some VMs prevent setting line/column otherwise
+ // (iOS Safari 10 even throws an exception)
+ var error = Object.create(SyntaxError.prototype);
+ var errorStack = new Error();
+
+ error.name = name;
+ error.message = message;
+
+ Object.defineProperty(error, 'stack', {
+ get: function() {
+ return (errorStack.stack || '').replace(/^(.+\n){1,3}/, name + ': ' + message + '\n');
+ }
+ });
+
+ return error;
+};
diff --git a/node_modules/css-tree/lib/utils/names.js b/node_modules/css-tree/lib/utils/names.js
new file mode 100644
index 0000000..fdc3f1f
--- /dev/null
+++ b/node_modules/css-tree/lib/utils/names.js
@@ -0,0 +1,104 @@
+var hasOwnProperty = Object.prototype.hasOwnProperty;
+var keywords = Object.create(null);
+var properties = Object.create(null);
+var HYPHENMINUS = 45; // '-'.charCodeAt()
+
+function isCustomProperty(str, offset) {
+ offset = offset || 0;
+
+ return str.length - offset >= 2 &&
+ str.charCodeAt(offset) === HYPHENMINUS &&
+ str.charCodeAt(offset + 1) === HYPHENMINUS;
+}
+
+function getVendorPrefix(str, offset) {
+ offset = offset || 0;
+
+ // verdor prefix should be at least 3 chars length
+ if (str.length - offset >= 3) {
+ // vendor prefix starts with hyper minus following non-hyper minus
+ if (str.charCodeAt(offset) === HYPHENMINUS &&
+ str.charCodeAt(offset + 1) !== HYPHENMINUS) {
+ // vendor prefix should contain a hyper minus at the ending
+ var secondDashIndex = str.indexOf('-', offset + 2);
+
+ if (secondDashIndex !== -1) {
+ return str.substring(offset, secondDashIndex + 1);
+ }
+ }
+ }
+
+ return '';
+}
+
+function getKeywordDescriptor(keyword) {
+ if (hasOwnProperty.call(keywords, keyword)) {
+ return keywords[keyword];
+ }
+
+ var name = keyword.toLowerCase();
+
+ if (hasOwnProperty.call(keywords, name)) {
+ return keywords[keyword] = keywords[name];
+ }
+
+ var custom = isCustomProperty(name, 0);
+ var vendor = !custom ? getVendorPrefix(name, 0) : '';
+
+ return keywords[keyword] = Object.freeze({
+ basename: name.substr(vendor.length),
+ name: name,
+ vendor: vendor,
+ prefix: vendor,
+ custom: custom
+ });
+}
+
+function getPropertyDescriptor(property) {
+ if (hasOwnProperty.call(properties, property)) {
+ return properties[property];
+ }
+
+ var name = property;
+ var hack = property[0];
+
+ if (hack === '/') {
+ hack = property[1] === '/' ? '//' : '/';
+ } else if (hack !== '_' &&
+ hack !== '*' &&
+ hack !== '$' &&
+ hack !== '#' &&
+ hack !== '+' &&
+ hack !== '&') {
+ hack = '';
+ }
+
+ var custom = isCustomProperty(name, hack.length);
+
+ // re-use result when possible (the same as for lower case)
+ if (!custom) {
+ name = name.toLowerCase();
+ if (hasOwnProperty.call(properties, name)) {
+ return properties[property] = properties[name];
+ }
+ }
+
+ var vendor = !custom ? getVendorPrefix(name, hack.length) : '';
+ var prefix = name.substr(0, hack.length + vendor.length);
+
+ return properties[property] = Object.freeze({
+ basename: name.substr(prefix.length),
+ name: name.substr(hack.length),
+ hack: hack,
+ vendor: vendor,
+ prefix: prefix,
+ custom: custom
+ });
+}
+
+module.exports = {
+ keyword: getKeywordDescriptor,
+ property: getPropertyDescriptor,
+ isCustomProperty: isCustomProperty,
+ vendorPrefix: getVendorPrefix
+};