stylo: Bug 1390039 - Implement compute_distance for mismatched transform lists.
Implement ComputeSquaredDistance for mismatched transform lists.
In order to do this, we have to convert a transform list into a 3d matrix,
so I move the code from layout module into style module for reusing it.
---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1390039](https://bugzilla.mozilla.org/show_bug.cgi?id=1390039).
- [X] These changes do not require tests because this is a Gecko feature and I add many tests in Gecko already.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18234)
<!-- Reviewable:end -->
style: Avoid scanning the longhand id twice in the fast path of PropertyDeclarationBlock::parse_common
This makes the overhead of this function much lower according to `perf`.
And in general makes sense, removing overhead from the fast path.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18281)
<!-- Reviewable:end -->
style: Remove uninlineable function in PropertyDeclarationIterator.
That literally made no sense, and is probably leftover from where we passed Map
directly there.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18282)
<!-- Reviewable:end -->
This makes the overhead of this function much lower according to `perf`.
And in general makes sense, removing overhead from the fast path.
MozReview-Commit-ID: 4dJRap9dxNG
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
The trait ToAnimatedZero now supports it, and it now applies to things with generics,
avoiding the trait bounds for field types of the variant on which it applies.
Use Parser::skip_whitespace in a few places to make Parser::try rewind less
**Do not merge yet.** This pulls in unrelated cssparser changes which add a dependency to `dota`, and we’d like to resolve https://github.com/dtolnay/dtoa/pull/9 before landing dtoa in mozilla-central. Also, the dependency change may require manually revendoring in mozilla-central.
Gecko’s CSS parsing microbenchmarks before:
```
43.437 ± 0.391 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench
29.244 ± 0.042 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench
281.884 ± 0.028 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench
426.242 ± 0.008 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench
```
After:
```
29.779 ± 0.254 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench
28.841 ± 0.031 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench
296.240 ± 4.744 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench
293.855 ± 4.304 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench
```
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18171)
<!-- Reviewable:end -->
stylo: Implement font feature values lookup
This PR reviewed by emilio and xidorn on bugzilla. That is backed out because of Windows build problems. Fixed and landing it again.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes [Bug 1355721](https://bugzilla.mozilla.org/show_bug.cgi?id=1355721)
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18241)
<!-- Reviewable:end -->
We could use this method to convert a TransformList into a Matrix, and
use this matrix for computing distance for Stylo and rendering the transform
for Servo.
This is an equivalent of nsStyleTransformMatrix::ReadTransforms in Gecko.
Devirtualize CSS error reporting.
This removes a trait object from the path of reporting a CSS error.
---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] There are tests for these changes
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18209)
<!-- Reviewable:end -->
For now, only #[animation(error)] is supported on variants and it makes
both #[derive(Animate)] and #[derive(ComputeSquaredDistance)] ignore
this particular variant.
The implementation of 2d matrix decomposition in Servo matches that in
spec, but its result is really different from that in Gecko, so the
visual results on the main thread and on the compositor thread are
really different and we got many test failures. Therefore, let's write a
different algorithm of decomposition of 2d matrix for Stylo, and keep
the original one for Servo.
The output of new implemented 2d matrix decomposition is a Decomposed3DMatrix,
so we can reuse the interpolation and re-composition code. (Just like
what we do in Gecko.)
This is a temporary step needed to support Gecko's getKeyframes() API
until we implement bug 1391537. It only takes effect when
a ComputedValues object is supplied and only for longhand declarations.
Let's see the example: "rotatex(360deg)" to "none".
While we do interpolation between "rotatex" and "none", the original code
path is:
1. Build an identity transform for none and always use (0, 0, 1) as the
direction vector, i.e. Rotate(0, 0, 1, 0deg).
2. Do interpolation between rotatex (i.e. Rotate(1, 0, 0, 360deg)) and
Rotate(0, 0, 1, 0deg). Because their direction vectors are different,
so we do matrix decomposition/interpolation/recomposition on both
functions. The problem is, matrix decomposition makes the 360deg
disappear, so it looks like "rotatex(0deg)".
3. Obviously, we are trying to interpolate from rotatex(0deg) to none, so
the interpolated matrix is always an identity matrix.
I think rotatex, rotatey, and rotatez are special cases which should
really rotate according to the angle, so we should build the identity
transform for them according to the normalized direction vector, and so we do
interpolation on the angle, instead of converting them into matrix.
Replacing build_identity_transform_list() with
add_weighted_transform_lists(list, list, 0, 0) might be another solution;
However, I didn't do that because build_identity_transform_list() is
much simpler.