|
| 1 | +/****************************************************************************** |
| 2 | + * List of CSS syntax patches |
| 3 | + * |
| 4 | + * The list follows a JSON-like structure, represented as a JS object so that |
| 5 | + * comments can be added and so that backticks may be used to split long |
| 6 | + * syntaxes over multiple lines to ease readability. |
| 7 | + * |
| 8 | + * Syntax patches are currently restricted to adding a syntax to CSS constructs |
| 9 | + * for which no syntax could be extracted from the underlying spec. They cannot |
| 10 | + * be used to override the syntax of a CSS construct (a full patch file is |
| 11 | + * needed for that, check the instructions in the README). |
| 12 | + * |
| 13 | + * Also, patches should only be used for situations where the spec cannot |
| 14 | + * easily be updated to make the syntax more explicit, e.g., because defining |
| 15 | + * the syntax in prose is seen as more convenient. |
| 16 | + * |
| 17 | + * The list is an indexed object where keys are the shortnames of the |
| 18 | + * specifications to patch and where values are themselves an indexed object |
| 19 | + * where: |
| 20 | + * - keys are the name of the CSS constructs to patch, for example: |
| 21 | + * `<system-color>` |
| 22 | + * - values define the patch to apply |
| 23 | + * |
| 24 | + * If the CSS construct to target is nested (for example, the descriptor of an |
| 25 | + * at-rule), start with the name of the root constructor, add a `/`, and then |
| 26 | + * the name of the actual construct. For example: `@page/page/<page-size>` to |
| 27 | + * target the `<page-size>` type of the `page` descriptor of the `@page` |
| 28 | + * at-rule. |
| 29 | + * |
| 30 | + * The patch value can either be: |
| 31 | + * - A string, which gets interpreted as the CSS syntax to set. For example: |
| 32 | + * '<custom-ident>' |
| 33 | + * - An object with one or more of the following keys: |
| 34 | + * - `useValues`: a boolean flag. When set, the code builds the syntax of the |
| 35 | + * CSS construct from the list of CSS values that are defined for it in the |
| 36 | + * spec (and that could be extracted). |
| 37 | + * - `newValues`: a string that contains some additional syntax to add on top |
| 38 | + * of existing values. The `useValues` flag must also be set (there is no |
| 39 | + * way to set the syntax of an extended definition for now) |
| 40 | + * - `sameAs`: a reference to another CSS construct in the same spec that |
| 41 | + * provides the syntax to use. Cannot be used with any of the other keys. |
| 42 | + * |
| 43 | + * Trailing spaces in syntaxes will be trimmed, and so will extra spaces. |
| 44 | + * That's to ease patch readability. For example: ` |
| 45 | + * <basic-shape-rect> | |
| 46 | + * <circle()> | <ellipse()> |
| 47 | + * ` |
| 48 | + * ... becomes `<basic-shape-rect> | <circle()> | <ellipse()>` once the patch |
| 49 | + * is applied. |
| 50 | + * |
| 51 | + * It is good practice to start a patch with a comment that links to the |
| 52 | + * the construct definition in the spec. |
| 53 | + * |
| 54 | + * The underlying patching logic is in tools/amend-css-syntaxes.js. |
| 55 | + * |
| 56 | + * Note: the logic could be extended over time as needed to: |
| 57 | + * - Allow overriding an existing syntax. That would allow replacing most |
| 58 | + * patch files in this folder. The underlying PR should be reported in a |
| 59 | + * `pending` key and/or the incorrect syntax should be recorded to make |
| 60 | + * sure we do not miss updates. |
| 61 | + * - Allow dropping an existing syntax. That has never been needed until now. |
| 62 | + * - Allow adding/overriding new values of an extended definition. That could |
| 63 | + * also prove useful. |
| 64 | + *****************************************************************************/ |
| 65 | +export default { |
| 66 | + // https://drafts.csswg.org/css-cascade-6/#scope-syntax |
| 67 | + "css-cascade-6": { |
| 68 | + "<scope-start>": "<selector-list>", |
| 69 | + "<scope-end>": "<selector-list>" |
| 70 | + }, |
| 71 | + |
| 72 | + // https://drafts.csswg.org/css-color-4/#typedef-system-color |
| 73 | + // https://drafts.csswg.org/css-color-4/#typedef-deprecated-color |
| 74 | + // https://drafts.csswg.org/css-color-4/#typedef-named-color |
| 75 | + "css-color-4": { |
| 76 | + "<system-color>": { |
| 77 | + "useValues": true, |
| 78 | + "newValues": "<deprecated-color>" |
| 79 | + }, |
| 80 | + "<deprecated-color>": { |
| 81 | + "useValues": true |
| 82 | + }, |
| 83 | + "<named-color>": { |
| 84 | + "useValues": true, |
| 85 | + "newValues": "transparent" |
| 86 | + } |
| 87 | + }, |
| 88 | + |
| 89 | + // https://drafts.csswg.org/css-counter-styles-3/#typedef-counter-style-name |
| 90 | + "css-counter-styles-3": { |
| 91 | + "<counter-style-name>": "<custom-ident>" |
| 92 | + }, |
| 93 | + |
| 94 | + // https://drafts.csswg.org/css-fonts-4/#typedef-font-palette-palette-identifier |
| 95 | + "css-fonts-4": { |
| 96 | + "font-palette/<palette-identifier>": "<dashed-ident>" |
| 97 | + }, |
| 98 | + |
| 99 | + // https://drafts.csswg.org/css-lists-3/#typedef-counter-name |
| 100 | + "css-lists-3": { |
| 101 | + "<counter-name>": "<custom-ident>" |
| 102 | + }, |
| 103 | + |
| 104 | + // https://drafts.csswg.org/css-overflow-5/#typedef-scroll-button-direction |
| 105 | + "css-overflow-5": { |
| 106 | + "<scroll-button-direction>": { |
| 107 | + "useValues": true |
| 108 | + } |
| 109 | + }, |
| 110 | + |
| 111 | + // https://drafts.csswg.org/css-page-3/#typedef-page-size-page-size |
| 112 | + "css-page-3": { |
| 113 | + "@page/size/<page-size>": { |
| 114 | + "useValues": true |
| 115 | + } |
| 116 | + }, |
| 117 | + |
| 118 | + // https://drafts.csswg.org/css-shapes-1/#supported-basic-shapes |
| 119 | + "css-shapes-1": { |
| 120 | + "<basic-shape>": ` |
| 121 | + <basic-shape-rect> | |
| 122 | + <circle()> | <ellipse()> | <polygon()> | |
| 123 | + <path()> | <shape()> |
| 124 | + ` |
| 125 | + }, |
| 126 | + |
| 127 | + // https://drafts.csswg.org/css-syntax-3/#the-anb-type |
| 128 | + "css-syntax-3": { |
| 129 | + "<n-dimension>": "<dimension-token>", |
| 130 | + "<ndash-dimension>": "<dimension-token>", |
| 131 | + "<ndashdigit-dimension>": "<dimension-token>", |
| 132 | + "<ndashdigit-ident>": "<ident-token>", |
| 133 | + "<dashndashdigit-ident>": "<ident-token>", |
| 134 | + "<signed-integer>": "<number-token>", |
| 135 | + "<signless-integer>": "<number-token>" |
| 136 | + }, |
| 137 | + |
| 138 | + // https://drafts.csswg.org/css-transforms-2/#transform-functions |
| 139 | + "css-transforms-2": { |
| 140 | + "<transform-function>": ` |
| 141 | + <scale()> | <scaleX()> | <scaleY()> | <scaleZ()> | |
| 142 | + <translate3d()> | <translate()> | <translateX()> | <translateY()> | <translateZ()> | |
| 143 | + <rotate3d()> <rotate()> | <rotateX()> | <rotateY()> | <rotateZ()> | |
| 144 | + <skew()> | <skewX()> | <skewY()> | |
| 145 | + <matrix3d()> | <matrix()> | <perspective()> |
| 146 | + `, |
| 147 | + }, |
| 148 | + |
| 149 | + // https://drafts.csswg.org/css-ui-4/#propdef--webkit-user-select |
| 150 | + // https://drafts.csswg.org/css-ui-4/#typedef-outline-line-style |
| 151 | + "css-ui-4": { |
| 152 | + "-webkit-user-select": { |
| 153 | + "sameAs": "user-select" |
| 154 | + }, |
| 155 | + // Same as <line-style> but "auto" replaces "hidden" |
| 156 | + "<outline-line-style>": ` |
| 157 | + none | auto | dotted | dashed | solid | double | |
| 158 | + groove | ridge | inset | outset |
| 159 | + ` |
| 160 | + }, |
| 161 | + |
| 162 | + // https://drafts.csswg.org/css-values-4/#integers |
| 163 | + "css-values-4": { |
| 164 | + "<integer>": "<number-token>" |
| 165 | + }, |
| 166 | + |
| 167 | + // https://drafts.csswg.org/css2/#value-def-absolute-size |
| 168 | + // https://drafts.csswg.org/css2/#value-def-relative-size |
| 169 | + // https://drafts.csswg.org/css2/#value-def-shape |
| 170 | + "CSS2": { |
| 171 | + "<absolute-size>": ` |
| 172 | + xx-small | x-small | small | medium | |
| 173 | + large | x-large | xx-large |
| 174 | + `, |
| 175 | + "<relative-size>": "larger | smaller", |
| 176 | + "<shape>": "rect(<top>, <right>, <bottom>, <left>)" |
| 177 | + }, |
| 178 | + |
| 179 | + // https://svgwg.org/svg2-draft/pservers.html#StopColorProperty |
| 180 | + // https://svgwg.org/svg2-draft/pservers.html#StopOpacityProperty |
| 181 | + "SVG2": { |
| 182 | + "stop-color": `<'color'>`, |
| 183 | + "stop-opacity": `<'opacity'>` |
| 184 | + } |
| 185 | +}; |
0 commit comments