Commit graph

1953 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
c69f769285
Revert "Rewrite CounterStyleOrNone::from_gecko_value to use fewer binding functions"
This reverts commit 65c2047df2.
2017-08-30 14:21:13 +02:00
bors-servo
3fa5d83ab7 Auto merge of #18234 - BorisChiou:stylo/transform/distance_mismatch, r=birtles,nox
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 -->
2017-08-30 06:03:32 -05:00
bors-servo
5dee83d54d Auto merge of #18300 - emilio:die-hvp-die, r=nox
style: Remove HasViewportPercentage.

It's not needed since #18268, let's kill it.

<!-- 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/18300)
<!-- Reviewable:end -->
2017-08-30 04:31:11 -05:00
Boris Chiou
5c5a72c1d8 Return Err(()) if determinant is not 1 or -1 while decomposing the 2d matrix.
This may happen in some cases, and we shouldn't panic in debug mode,
so let's return Err(()) for it to fall back to discrete animation.
2017-08-30 13:58:33 +08:00
Xidorn Quan
65c2047df2 Rewrite CounterStyleOrNone::from_gecko_value to use fewer binding functions 2017-08-30 13:52:19 +10:00
Emilio Cobos Álvarez
36ff89bd28
style: Remove HasViewportPercentage.
It's not needed since #18268
2017-08-29 23:51:21 +02:00
bors-servo
473934c989 Auto merge of #18268 - emilio:dirty-viewport-followup, r=SimonSapin
style: Recascade the document instead of using the dirty_on_viewport_size_change bit

This allows us to simplify a lot of code.

On top of #18267.

<!-- 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/18268)
<!-- Reviewable:end -->
2017-08-29 14:18:58 -05:00
bors-servo
bd9cf3ce98 Auto merge of #18281 - emilio:more-parse-dumbness, r=jdm
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 -->
2017-08-29 02:48:09 -05:00
bors-servo
441ae08d24 Auto merge of #18280 - emilio:parse-dumbness, r=jdm
style: Avoid dropping a parse error on the floor when checking whether a prop is enabled.

<!-- 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/18280)
<!-- Reviewable:end -->
2017-08-29 01:34:57 -05:00
bors-servo
9e2f243b4d Auto merge of #18282 - emilio:moar-parsing, r=jdm
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 -->
2017-08-28 19:18:37 -05:00
Emilio Cobos Álvarez
f6e4c5547c
style: Remove uninlineable function in PropertyDeclarationIterator.
That literally made no sense, and is probably leftover from where we passed Map
directly there.
2017-08-28 21:25:25 +02:00
Emilio Cobos Álvarez
344d53bd29
style: Avoid scanning the longhand id twice in the fast path of PropertyDeclarationBlock::push_common.
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>
2017-08-28 21:20:46 +02:00
Emilio Cobos Álvarez
8a0a690384
style: Avoid dropping a parse error on the floor when checking whether a prop is enabled. 2017-08-28 21:05:06 +02:00
Josh Matthews
4a949e112d Prioritize parsing non-custom property names. 2017-08-28 11:20:24 -07:00
bors-servo
a266e96d28 Auto merge of #18239 - servo:derive-all-the-things, r=emilio
Refactor how we handle trait bounds in style_derive

<!-- 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/18239)
<!-- Reviewable:end -->
2017-08-28 10:13:13 -05:00
Emilio Cobos Álvarez
2291ce4767
style: Remove CascadeInfo. 2017-08-28 14:40:47 +02:00
Anthony Ramine
318d8696e5 Derive Animate and ComputeSquaredDistance for computed font-size-adjust 2017-08-28 12:26:37 +02:00
Anthony Ramine
4a4bf89575 Implement #[animate(fallback)] for #[derive(Animate)]
This allows us to derive the Animate trait, providing a fallback function
for when the 2 values aren't similar.
2017-08-28 12:26:36 +02:00
Anthony Ramine
3751fe9fdc Derive ToComputedValue for TrackBreadth<L> 2017-08-28 12:26:35 +02:00
Anthony Ramine
405e34aa74 Derive a bunch of animation traits for some SVG types 2017-08-28 10:39:17 +02:00
Hiroyuki Ikezoe
21db77eb4e Don't fallback to discrete animations within animate(). 2017-08-28 14:16:34 +09:00
Anthony Ramine
af560a8fab Support #[animation(error)] in more cases
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.
2017-08-27 23:31:17 +02:00
bors-servo
8812422bfa Auto merge of #18171 - servo:skip_whitespace, r=emilio
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 -->
2017-08-25 20:24:58 -05:00
Simon Sapin
dc5dfafbba Use Parser::skip_whitespace in a few places to make Parser::try rewind less.
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
```
2017-08-26 01:44:45 +02:00
bors-servo
2136dd2bb7 Auto merge of #18244 - kahsieh:master, r=Manishearth
stylo: Update CSS fallback font when lang changes

r=manishearth in BugZilla.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1367860](https://bugzilla.mozilla.org/show_bug.cgi?id=1367860).

<!-- 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/18244)
<!-- Reviewable:end -->
2017-08-25 17:30:22 -05:00
Kevin Hsieh
cfa98a3ab6 Update CSS fallback font when lang changes 2017-08-25 14:12:34 -07:00
bors-servo
dc8f26432f Auto merge of #18241 - canaltinova:font-feature-values-lookup, r=emilio,xidorn
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 -->
2017-08-25 15:45:03 -05:00
Nazım Can Altınova
81be90cce2 Implement font feature values lookup for stylo 2017-08-25 12:03:38 -07:00
Boris Chiou
4580b530a8 Use DirectionVector as an alias of euclid::Vector3D<f32>.
Therefore, we can reuse the methods of Vector3D, instead of implementing
similar ones.
2017-08-25 18:25:15 +08:00
Boris Chiou
5c2d8507be Implement to_transform_3d_matrix for computing distance of mismatched transform lists.
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.
2017-08-25 18:25:14 +08:00
Emilio Cobos Álvarez
ff700aba75
style: Only store applicable ::before / ::after pseudo styles during the traversal. 2017-08-25 08:46:22 +02:00
Gecko Backout
12b02ce9d5 Backed out changeset 01348a3860f7 for build bustage
CLOSED TREE

Backs out https://github.com/servo/servo/pull/18222
2017-08-25 03:45:31 +00:00
Nazım Can Altınova
6d7a1903b8 Implement font feature values lookup for stylo 2017-08-24 12:41:36 -07:00
bors-servo
d4ddec8d33 Auto merge of #18209 - jdm:devirtualize, r=mbrubeck
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 -->
2017-08-24 13:19:25 -05:00
Josh Matthews
1297c0ff51 Devirtualize CSS error reporting. 2017-08-24 10:41:06 -07:00
Anthony Ramine
ff67fc751d Introduce #[animation]
For now, only #[animation(error)] is supported on variants and it makes
both #[derive(Animate)] and #[derive(ComputeSquaredDistance)] ignore
this particular variant.
2017-08-24 11:04:19 +02:00
Anthony Ramine
49a5ceca9b Derive ToAnimatedZero for Either<A, B> 2017-08-24 01:28:34 +02:00
Clément DAVID
c5fe235112 order derivable traits lists
Ignoring :
 - **generated**.rs
 - python/tidy/servo_tidy_tests/rust_tidy.rs
2017-08-23 21:38:44 +02:00
Boris Chiou
172b4aadda Use rewritten decomposition of 2d matrix to compute distance.
So we can align the result with interpolation.
2017-08-23 17:10:29 +08:00
Boris Chiou
9b76cd9d1c Rewrite decomposition of 2d matrix.
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.)
2017-08-23 14:39:00 +08:00
Anthony Ramine
7ee124b1ed Derive the most trivial Animate impls 2017-08-22 19:12:47 +02:00
Anthony Ramine
faaf31411a Derive the most trivial ToAnimatedZero impls 2017-08-22 19:12:42 +02:00
Anthony Ramine
aea0cd7ec7 Introduce values::animated::Animate
This replaces the Animatable trait and merges its three former methods into a single one.
2017-08-22 09:41:01 +02:00
Anthony Ramine
0cceeb9d5c Simplify add_weighted_with_initial_val 2017-08-21 23:48:59 +02:00
Anthony Ramine
54dc3e1670 Clean up filter animations 2017-08-21 23:48:58 +02:00
Anthony Ramine
baf3597477 Clean up transform animations 2017-08-21 23:48:58 +02:00
bors-servo
6a1b0d0526 Auto merge of #18159 - upsuper:write-to-css, r=nox
Replace write! with to_css and write_str in some ToCss impls

Some of this is necessary for fixing things like [bug 1370779](https://bugzilla.mozilla.org/show_bug.cgi?id=1370779) because otherwise we would still not be using the new numeric serialization algorithm from cssparser crate.

<!-- 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/18159)
<!-- Reviewable:end -->
2017-08-21 04:14:08 -05:00
Brian Birtles
4f53ca2e39 Expand var() references in single_value_to_css
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.
2017-08-21 12:59:53 +09:00
Xidorn Quan
7e92c15e00 Replace write! with to_css and write_str in some ToCss impls 2017-08-20 17:21:08 +10:00
Boris Chiou
4ed1a6be20 Fix the identity transform of rotatex and rotatey.
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.
2017-08-20 02:26:18 +08:00