Commit graph

590 commits

Author SHA1 Message Date
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
Emilio Cobos Álvarez
36ff89bd28
style: Remove HasViewportPercentage.
It's not needed since #18268
2017-08-29 23:51:21 +02:00
bors-servo
1c4d0d2d5d Auto merge of #18292 - emilio:animate-nan, r=nox
style: Prevent Animate to generate NaN float values.

This should fix the assertions in https://bugzilla.mozilla.org/show_bug.cgi?id=1394558.

<!-- 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/18292)
<!-- Reviewable:end -->
2017-08-29 05:18:33 -05:00
Emilio Cobos Álvarez
a7210fd082
style: Prevent Animate to generate NaN float values. 2017-08-29 11:57:50 +02:00
Anthony Ramine
ef9d614349 Fix impl of ToComputedValue for TrackSize<T> 2017-08-28 22:48:08 +02: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
Anthony Ramine
ba4136b5a8 Document how style traits can be derived 2017-08-28 12:26:43 +02:00
Anthony Ramine
41c3be54ea Implement #[distance(fallback)] for #[derive(ComputeSquaredDistance)] 2017-08-28 12:26:42 +02:00
Anthony Ramine
4faadb489f Implement #[css(derive_debug)]
This makes #[derive(ToCss)] derive Debug with a simple call to the to_css method.
2017-08-28 12:26:40 +02:00
Anthony Ramine
1ace6d4c7f Derive Animate for computed::Angle 2017-08-28 12:26:39 +02:00
Anthony Ramine
b543b17cf0 Derive Animate for BackgroundSize<L> 2017-08-28 12:26:38 +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
Emilio Cobos Álvarez
15e71c5670
style: Don't look for viewport units in stylesheets.
Use whether we've computed any viewport unit instead.

This is more accurate (we avoid restyling unnecessarily if we've found anything
ever on the stylesheet, but that hasn't matched).

This has the benefit of also matching Gecko, and simplify some code and
fishyness around, and also hopefully speeding up stylesheet parsing.
2017-08-28 12:05:22 +02:00
Anthony Ramine
735e093de7 Implement #[compute(clone)] for #[derive(ToComputedValue)] 2017-08-28 10:39:53 +02:00
Anthony Ramine
efc852f6e3 Improve handling of trait bounds when deriving fmap-like traits 2017-08-28 10:39:50 +02:00
Anthony Ramine
8101887d31 Support #[animation(constant)] when deriving ToAnimatedZero 2017-08-28 10:39:32 +02:00
Anthony Ramine
405e34aa74 Derive a bunch of animation traits for some SVG types 2017-08-28 10:39:17 +02:00
Anthony Ramine
eaf2f1ec33 Introduce #[animation(constant)] for the Animate trait
This allows us to handle fields that should be the same during animations.
2017-08-28 10:39:10 +02:00
Anthony Ramine
e49dbc4dfa Derive Animate for ShapeRadius<L> 2017-08-27 23:31:17 +02: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
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
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
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
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
181f41ed37 Auto merge of #18168 - mantaroh:stroke-distance, r=nox
Add ComputeSquaredDistance trait for SvgLengthOrPercentageOrNumber

<!-- Please describe your changes on the following line: -->
This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1387986

This patch will add ComputeSquaredDistance trait for SvgLengthOrPercentageOrNumber in order to calculating distance between LengthOrPercentage and Number.

---
<!-- 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

<!-- Either: -->
There are already these tests in dom/smil/tests of gecko, this PR will enable these tests.
For detail, see https://bugzilla.mozilla.org/show_bug.cgi?id=1387986.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/17288)
<!-- Reviewable:end -->
2017-08-21 14:35:09 -05:00
Mantaroh Yoshinaga
d5cfa1395b Add ComputeSquaredDistance trait for SvgLengthOrPercentageOrNumber.
Currently, Servo uses ComputeSquaredDistance derive for
SvgLengthOrPercentageOrNumber, so servo can't calculate between
LengthOrPercentage and Number.
This PR will allow calculating these value.
2017-08-22 04:20:12 +09:00
Xidorn Quan
afc9323b7c Add whitespace before line number in grid line 2017-08-21 22:21:51 +10:00
Xidorn Quan
7e92c15e00 Replace write! with to_css and write_str in some ToCss impls 2017-08-20 17:21:08 +10:00
bors-servo
0b45a4f651 Auto merge of #18136 - upsuper:shadow-color, r=emilio
Use Option<RGBA> for color in shadow

This fixes [bug 1390697](https://bugzilla.mozilla.org/show_bug.cgi?id=1390697) by downgrading the support of currentcolor in shadow to what Gecko currently supports.

<!-- 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/18136)
<!-- Reviewable:end -->
2017-08-19 05:45:53 -05:00
bors-servo
9bf70d4865 Auto merge of #18144 - canaltinova:legacy-position-x, r=emilio
Handle single X keyword value in LegacyPosition

This is reviewed by emilio in bugzilla.

---
<!-- 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 fix [Bug 1391432](https://bugzilla.mozilla.org/show_bug.cgi?id=1391432)

<!-- 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/18144)
<!-- Reviewable:end -->
2017-08-18 15:28:37 -05:00
Nazım Can Altınova
692d009e32 Handle single X keyword value in LegacyPosition 2017-08-18 11:06:58 -07:00
Xidorn Quan
4e0b1071e7 Use Option<RGBA> for color in shadow 2017-08-19 00:20:24 +10:00
bors-servo
92176d1152 Auto merge of #18131 - emilio:calc-serialization, r=canaltinova
style: Multiple calc serialization fixes.

This puts us in line with the spec as written, except for caveat in https://github.com/w3c/csswg-drafts/issues/1731.

Need to fix computed calc() too, I'm less confident that we won't need to change test expectations.

<!-- 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/18131)
<!-- Reviewable:end -->
2017-08-18 04:42:12 -05:00
Emilio Cobos Álvarez
6df597b0b8
style: Use Au::abs. 2017-08-18 11:06:39 +02:00
Emilio Cobos Álvarez
22d6a73436
style: Make computed serialization of calc() match the spec too. 2017-08-18 11:06:36 +02:00
Emilio Cobos Álvarez
1d54a8e857
style: Add a note about weirdness in serialization of computed calc(). 2017-08-18 11:06:34 +02:00
Emilio Cobos Álvarez
e05c673df3
style: Serialize percentages first in specified calc() expressions. 2017-08-18 11:06:32 +02:00
Emilio Cobos Álvarez
f8a6eccda2
style: Update calc() serialization to the spec. 2017-08-18 11:06:31 +02:00
bors-servo
494dcd7e52 Auto merge of #18086 - BorisChiou:stylo/transform/distance, r=nox,birtles
stylo: Bug 1362896 - Implement ComputeSquaredDistance for TransformList

We implement ComputeSquaredDistance for TransformList.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1362896](https://bugzilla.mozilla.org/show_bug.cgi?id=1362896).
- [X] These changes do not require tests because Gecko has related tests.

<!-- 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/18086)
<!-- Reviewable:end -->
2017-08-18 02:24:33 -05:00
Mantaroh Yoshinaga
1c574cf93b Add SVGLengthOrPercentageOrNumber for stroke-*.
We need to use enum instead of Either since we can't interpolate stroke-* between
unitless length and unit length(e.g. '5' -> '10px').

This coomit make following:

 * Introduce SVGLengthOrPercentageOrNumber on computed and specified values.
 * Make SVGLengthOrPercentageOrNumber animatable.
 * Make stroke-dasharray not-accumulate.
2017-08-18 10:28:11 +09:00
Boris Chiou
a5433ad68a Tweak CalcLengthOrPercentage to use pixel value.
We compute the distance for eCSSUnit_Calc by pixel value in Gecko,
so let's follow the same rules.
2017-08-17 13:53:07 +08:00
bors-servo
575bcf3989 Auto merge of #18117 - servo:we-are-leaving-babylon, r=emilio
Move more CSS values to their own submodules

<!-- 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/18117)
<!-- Reviewable:end -->
2017-08-16 20:26:22 -05:00
Anthony Ramine
4ebeaa599b Move specified and computed time values to submodules 2017-08-17 00:05:59 +02:00
Anthony Ramine
1bd12bf91a Move specified and computed angles to submodules 2017-08-17 00:01:23 +02:00