This change is a rework of #22478, originally authored by @vimpunk.
It adds parsing of CSS in parallel with the main script thread. The
big idea here is that when the transfer of stylesheet bytes is
finished, the actual parsing is pushed to a worker thread from the Stylo
thread pool. This also applies for subsequent loads triggered by
`@import` statements.
The design is quite similar to the previous PR with a few significant
changes:
- Error handling works properly. The `CSSErrorReporter` is a crossbeam
`Sender` and a `PipelineId` so it can be trivially cloned and sent to
the worker thread.
- Generation checking is done both before and after parsing, in order
to both remove the race condition and avoid extra work when the
generations do not match.
- The design is reworked a bit to avoid code duplication, dropping added
lines from 345 to 160.
- Now that `process_response_eof` gives up ownership to the
`FetchResponseListener`, this change avoids all extra copies.
Testing: This shouldn't change observable behavior, so is covered
by existing tests.
Fixes: #20721Closes: #22478
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: mandreyel <mandreyel@protonmail.com>
Moves interfaces defined by the CSS spec to the `script/dom/css/` module
from `script/dom/`.
Testing: Just a refactor shouldn't need any testing
Fixes: Partially #38901
Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>