generate-properties-db.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. /*
  6. * This is an xpcshell script that runs to generate a static list of CSS properties
  7. * as known by the platform. It is run from ./mach_commands.py by running
  8. * `mach devtools-css-db`.
  9. */
  10. var {require} = Components.utils.import("resource://devtools/shared/Loader.jsm", {});
  11. var {generateCssProperties} = require("devtools/server/actors/css-properties");
  12. // xpcshell can output extra information, so place some delimiter text between
  13. // the output of the css properties database.
  14. dump("DEVTOOLS_CSS_DB_DELIMITER");
  15. // Output JSON
  16. dump(JSON.stringify({
  17. cssProperties: cssProperties(),
  18. pseudoElements: pseudoElements()
  19. }));
  20. dump("DEVTOOLS_CSS_DB_DELIMITER");
  21. /*
  22. * A list of CSS Properties and their various characteristics. This is used on the
  23. * client-side when the CssPropertiesActor is not found, or when the client and server
  24. * are the same version. A single property takes the form:
  25. *
  26. * "animation": {
  27. * "isInherited": false,
  28. * "supports": [ 7, 9, 10 ]
  29. * }
  30. */
  31. function cssProperties() {
  32. const properties = generateCssProperties();
  33. for (let key in properties) {
  34. // Ignore OS-specific properties
  35. if (key.indexOf("-moz-osx-") !== -1) {
  36. properties[key] = undefined;
  37. }
  38. }
  39. return properties;
  40. }
  41. /**
  42. * The list of all CSS Pseudo Elements.
  43. */
  44. function pseudoElements() {
  45. const {classes: Cc, interfaces: Ci} = Components;
  46. const domUtils = Cc["@mozilla.org/inspector/dom-utils;1"]
  47. .getService(Ci.inIDOMUtils);
  48. return domUtils.getCSSPseudoElementNames();
  49. }