Repository navigation
Commit 21172f7
authored
fix(html): minify a merged <style> run as the one sheet it prints (#22302)
* fix(html): minify a merged <style> run as the one sheet it prints
mergeStyles joined each sheet as minified on its own, so a second pass
over the joined element folded rules across them (`a{color:red}` and
`b{color:red}` became `a,b{color:red}` only then), and a blank sheet
joined to a rule kept its whitespace. The joined run is now rendered
again as one sheet; on the async path processAsync asks for what a
reprint offers that no earlier print did, a bounded number of times.
Also covers the branches #22290 left untested and drops a whitespace
skip in the CSS end-of-input closer that no input can reach.
* perf(html): join a <style> run's sources and minify it once
A sheet whose source ends at a rule (a `}` or an at-rule's `;`, outside
every string, comment and block) is appended to as written, so a run
is offered to the CSS minifier once: no per-sheet renders, and no
second print on the async path. Only a sheet the input left open is
still joined on its answer, which is the one case processAsync has to
print again for.
* fix(html): stop a <style> run at a sheet the input left open
Nothing is appended to a sheet whose source does not end at a rule, so
a run is decided on its sources alone and processAsync goes back to one
reprint with no reprint loop. A second pass reads such a sheet closed
and joins it; the two fixtures carrying one record that as expected in
the HTML sweep.
* fix(html): close a sheet the input left open before joining the next
A <style> the input left inside a string, comment or block, or with a
statement unfinished, is closed as its own end of input closed it (the
quote, comment end and closers, then `{}` or `;`) and the next sheet is
appended to that, so every run joins again and is minified once, with no
reprint. Only a sheet ending on a lone backslash is not joined, and none
is joined printed as written, where the closing would stay in a custom
property's value.
A syntax-equivalence test holds each such run to the separate sheets'
computed styles in the real browser the job runs.
* fix(html): read a lone @ as a delimiter when closing a sheet to join
A lone @ opens an ordinary rule's prelude, which only {} ends, so closing it with ; let the next sheet's first rule be swallowed. Found by cutting every test and corpus stylesheet and comparing the joined sheet with the two apart in Chromium.
* fix(html): read an unquoted url as one token when closing a sheet to join
An unquoted url( is a single token, and a bad one runs to the first ) its remnants reach, so a ( inside it opens nothing. Counting it as a block added a ) that broke the declaration after it. Found by the same Chromium comparison over every cut of every test and corpus stylesheet.
* fix(css,html): keep a custom property's value the input ran out in open
A browser stores such a value as written, open, so the minifier prints it
that way instead of closing it, and a <style> run is not joined after one.
Cover the url scanner's remaining branches.
* fix(html): stop a <style> run at a sheet declaring a namespace
A namespace applies to the whole sheet declaring it, so a sheet joined after
one read its selectors in it. An escaped at-rule name now stops a run too,
and a linear scan replaces the backtracking custom-property regexp.
* test(css): retire two WebKit value defects the open custom property fixed
A custom property's value the input ran out in is now printed open as written,
so WebKit reads the paint() probe the same through var() and both entries
stopped matching.1 parent 4873285 commit 21172f7
17 files changed
Lines changed: 863 additions & 160 deletions
File tree
- .changeset
- lib
- css
- html
- util
- test
- configCases/html
- minimize-end-of-input
- __snapshots__
- minimize-merge-styles
- __snapshots__
- specCases
- unitCases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1978 | 1978 | | |
1979 | 1979 | | |
1980 | 1980 | | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
1981 | 1984 | | |
1982 | 1985 | | |
1983 | 1986 | | |
| |||
7263 | 7266 | | |
7264 | 7267 | | |
7265 | 7268 | | |
| 7269 | + | |
| 7270 | + | |
| 7271 | + | |
| 7272 | + | |
| 7273 | + | |
| 7274 | + | |
7266 | 7275 | | |
7267 | 7276 | | |
7268 | 7277 | | |
| |||
7275 | 7284 | | |
7276 | 7285 | | |
7277 | 7286 | | |
| 7287 | + | |
7278 | 7288 | | |
7279 | 7289 | | |
7280 | 7290 | | |
| |||
11081 | 11091 | | |
11082 | 11092 | | |
11083 | 11093 | | |
| 11094 | + | |
| 11095 | + | |
| 11096 | + | |
| 11097 | + | |
| 11098 | + | |
| 11099 | + | |
| 11100 | + | |
| 11101 | + | |
| 11102 | + | |
| 11103 | + | |
| 11104 | + | |
| 11105 | + | |
11084 | 11106 | | |
11085 | 11107 | | |
11086 | 11108 | | |
11087 | 11109 | | |
11088 | 11110 | | |
| 11111 | + | |
| 11112 | + | |
| 11113 | + | |
11089 | 11114 | | |
11090 | 11115 | | |
11091 | 11116 | | |
| |||
11121 | 11146 | | |
11122 | 11147 | | |
11123 | 11148 | | |
11124 | | - | |
| 11149 | + | |
| 11150 | + | |
| 11151 | + | |
| 11152 | + | |
| 11153 | + | |
| 11154 | + | |
| 11155 | + | |
| 11156 | + | |
11125 | 11157 | | |
11126 | 11158 | | |
11127 | 11159 | | |
| |||
11137 | 11169 | | |
11138 | 11170 | | |
11139 | 11171 | | |
11140 | | - | |
11141 | | - | |
| 11172 | + | |
| 11173 | + | |
11142 | 11174 | | |
11143 | 11175 | | |
11144 | 11176 | | |
11145 | 11177 | | |
11146 | 11178 | | |
11147 | | - | |
| 11179 | + | |
| 11180 | + | |
| 11181 | + | |
| 11182 | + | |
| 11183 | + | |
| 11184 | + | |
| 11185 | + | |
| 11186 | + | |
| 11187 | + | |
11148 | 11188 | | |
11149 | 11189 | | |
11150 | 11190 | | |
11151 | 11191 | | |
11152 | 11192 | | |
11153 | 11193 | | |
11154 | 11194 | | |
11155 | | - | |
| 11195 | + | |
11156 | 11196 | | |
11157 | 11197 | | |
| 11198 | + | |
| 11199 | + | |
| 11200 | + | |
| 11201 | + | |
| 11202 | + | |
| 11203 | + | |
| 11204 | + | |
| 11205 | + | |
| 11206 | + | |
| 11207 | + | |
| 11208 | + | |
| 11209 | + | |
| 11210 | + | |
11158 | 11211 | | |
11159 | 11212 | | |
11160 | 11213 | | |
| |||
13489 | 13542 | | |
13490 | 13543 | | |
13491 | 13544 | | |
13492 | | - | |
| 13545 | + | |
| 13546 | + | |
13493 | 13547 | | |
13494 | 13548 | | |
13495 | | - | |
13496 | 13549 | | |
13497 | 13550 | | |
13498 | 13551 | | |
| |||
14910 | 14963 | | |
14911 | 14964 | | |
14912 | 14965 | | |
| 14966 | + | |
| 14967 | + | |
| 14968 | + | |
| 14969 | + | |
| 14970 | + | |
| 14971 | + | |
14913 | 14972 | | |
14914 | 14973 | | |
14915 | 14974 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4437 | 4437 | | |
4438 | 4438 | | |
4439 | 4439 | | |
| 4440 | + | |
| 4441 | + | |
| 4442 | + | |
| 4443 | + | |
| 4444 | + | |
| 4445 | + | |
| 4446 | + | |
| 4447 | + | |
| 4448 | + | |
| 4449 | + | |
| 4450 | + | |
| 4451 | + | |
| 4452 | + | |
| 4453 | + | |
4440 | 4454 | | |
4441 | 4455 | | |
4442 | 4456 | | |
| |||
0 commit comments