Commit graph

264 commits

Author SHA1 Message Date
Mantaroh Yoshinaga
c71abc0c28 Make font-stretch animatable. 2017-05-19 09:06:00 +09:00
Anthony Ramine
307dd74ecf Introduce CalcLengthOrPercentage::unclamped_length
This is necessary for some operations, notably converting this to something
suitable for gecko.
2017-05-18 19:27:31 +02:00
Anthony Ramine
bcf1a6c5e5 Avoid unwrap in LengthOrPercentageOrAuto::compute_squared_distance 2017-05-18 19:10:40 +02:00
Anthony Ramine
d0b9bd9c64 Refactor how calc() clamping is done on computed values (fixes #15296) 2017-05-18 10:14:59 +02:00
Brian Birtles
49bc7b9e69 Add add() method to Animatable interface 2017-05-15 12:53:14 +09:00
Brian Birtles
2f07b29296 Rewrite interpolate() in terms of a more general add_weighted() function
Generalizing the procedure like this will allow us to re-use it for addition of
most types.
2017-05-15 12:26:21 +09:00
Anthony Ramine
70ec61cf01 Refactor Position
A specified position is now a struct made of two values of different types,
the first one being PositionComponent<X>, and the second one PositionComponent<Y>.

A position component is represented by the new enum PositionComponent<Side>,
with the three values Center, Length(LengthOrPercentage), and
Side(Side, Option<LengthOrPercentage>).

Side keywords are represented by the X and Y enums, which don't include a value
for the center keyword anymore. They are accompanied by the Side trait, which
allows us to determine whether a side keyword is "left" or "top".

This refactor simplified the parsing and serialisation code and exposed bugs in it,
where it would reject valid <position> values followed by arbitrary tokens,
and where it would fail to prefer "left" to "right" when serialising positions
in basic shapes.
2017-05-10 16:56:01 +02:00
Brian Birtles
6dfc1d1aa8 Merge ComputeDistance trait into Animatable trait 2017-05-10 14:41:26 +09:00
Brian Birtles
4d25e87ac6 Rename the Interpolate trait to Animatable 2017-05-10 13:38:06 +09:00
Jeremy Chen
729b4f7901 Bug 1360144 - make stroke-{*} animatable for stylo. r=boris
This part includes making stroke-linecap, stroke-linejoin, stroke-miterlimit,
stroke-opacity, and stroke-dasharray animatable.

For properties that already implemented Interpolate trait and clone() for
glue code, we can just make them animatable by replacing the animation_value_type
with proper type name. So, set animation_value_type to 'discrete' for
stroke-linecap and stroke-linejoin. Set animation_value_type to 'ComputedValue'
for stroke-miterlimit and stroke-opacity.

As to stroke-dasharray, we need to implement Interpolate trait and glue codes
for it.
2017-05-04 14:31:38 +08:00
Hiroyuki Ikezoe
83a4935b60 Pass AnimationValueMap raw pointer instead of Arc to Gecko_GetAnimationRule() 2017-05-01 19:23:34 +09:00
Emilio Cobos Álvarez
0c5681140a
style: Use SmallVec in the computed value representation of most stuff. 2017-04-30 23:32:32 +02:00
bors-servo
ad87d36a69 Auto merge of #16623 - aacunningham:issue-16604-define-keyword-type-modification, r=Wafflespeanut
Move impl's into macro for macro-generated keyword types

Three keyword types are created through a macro but have some of their
impl's handled elsewhere. Since all impl's are the same, this commit
moves them into the macro to have them auto generated, for more concise
code.

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #16604 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because this doesn't add any new features, just alters `impl` locations

<!-- 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/16623)
<!-- Reviewable:end -->
2017-04-28 08:09:13 -05:00
Anthony Ramine
f68e2fded9 Propagate quirks mode all the way to ParserContext
The quirks mode is still not properly propagated in geckolib.
2017-04-27 10:41:55 +02:00
Aaron Cunningham
f6d09a39f8 Move impl's into macro for macro-generated keyword types
Three keyword types are created through a macro but have some of their
impl's handled elsewhere. Since all impl's are the same, this commit
moves them into the macro to have them auto generated, for more concise
code.
2017-04-26 12:38:21 -07:00
Boris Chiou
02fc1789e8 Bug 1357357 - Make the parser of transition-property match the spec.
1. We add a new arm to TransitionProperty, TransitionProperty::Unsupported,
   which contains an Atom, so it's better to remove the Copy trait from
   TransitionProperty.
2. TransitionProperty::Unsupported(Atom) represents any non-animatable, custom,
   or unrecognized property, and we use Atom to store the ident string for
   serialization.
2017-04-26 21:35:05 +08:00
Ravi Shankar
61a17993eb Cleanup position and make use of generic Position for its users 2017-04-25 17:32:45 +05:30
Ravi Shankar
0249270f61 Create a module for generics and make BorderRadiusSize generic 2017-04-25 17:13:41 +05:30
bors-servo
46bb635c4c Auto merge of #16587 - hiikezoe:intermediate-rgba, r=birtles,boris
Introduce intermediate rgba

<!-- Please describe your changes on the following line: -->
This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1356941
---
<!-- 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: -->
- [X] These changes do not require tests because it's for stylo.

<!-- 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/16587)
<!-- Reviewable:end -->
2017-04-24 07:22:39 -05:00
Hiroyuki Ikezoe
0ec5a64a71 ComputedDistance for IntermediateTextShadow. 2017-04-24 15:40:30 +09:00
Hiroyuki Ikezoe
46e567e688 Use IntermediateColor for text-shadow. 2017-04-24 15:40:29 +09:00
Hiroyuki Ikezoe
1e9c118f7f ComputedDistance for IntermediateBoxShadow. 2017-04-24 15:40:28 +09:00
Hiroyuki Ikezoe
424e4f9d35 Use IntermediateColor for box-shadow. 2017-04-24 15:40:26 +09:00
Hiroyuki Ikezoe
2d808bf162 Introduce a macro to implement Interpolate trait for box-shadow and text-shadow.
This macro will be used for implementation of intermediate type shadows
as well.  In the case of intermediate types transparent_color will be
IntermediateRGB::transparent().
2017-04-24 15:40:25 +09:00
Hiroyuki Ikezoe
09e728b43d ComputedDistance for IntermediateColor. 2017-04-24 15:40:24 +09:00
Hiroyuki Ikezoe
486578fe74 Use IntermediateColor for caret-color. 2017-04-24 15:40:23 +09:00
Hiroyuki Ikezoe
5834577157 Introduce IntermediateColor to store currentcolor or IntermeditateRGBA. 2017-04-24 15:40:22 +09:00
Hiroyuki Ikezoe
8de605f0dd ComputedDistance for IntermediateRGBA. 2017-04-24 15:40:21 +09:00
Hiroyuki Ikezoe
d70e4aa229 Use IntermediateRGBA to store overflowed RGBA components during interpolation. 2017-04-24 15:40:20 +09:00
Hiroyuki Ikezoe
ce51ff3a9a Check animation_value_type is not 'discrete' instead of 'normal' for ComputeDistance.
We will introduce various new animation_value_type in subsequent patches,
so we should just check 'discrete' type for properties that we can't compute
distance.
2017-04-24 15:23:48 +09:00
Simon Sapin
7fe57ecaea Rename StdoutErrorReporter to RustLogReporter. 2017-04-24 08:23:41 +02:00
Hiroyuki Ikezoe
94fb839fdd Rename animation_type to animation_value_type. 2017-04-24 15:23:39 +09:00
Hiroyuki Ikezoe
1da31f5cf3 Introduce IntermediateRGBA type.
We need to store color values that each components exceeds its normal range
(i.e. [0, 1]) during animation operations (e.g. interpolation). We clamp it
right before we insert animated values into the cascade.
2017-04-24 15:13:59 +09:00
Manish Goregaokar
8bfcc6992e tidy and test fixes 2017-04-21 14:53:27 -07:00
Manish Goregaokar
b0dcb72722 stylo: System font support for keyword font longhands 2017-04-21 14:53:18 -07:00
Manish Goregaokar
c1c4c8fa59 stylo: Add basic system font support, use for font-size and font-family 2017-04-21 14:53:09 -07:00
Boris Chiou
57f87007f2 Bug 1332633 - Part 1: Implement ComputeDistance trait.
Introduce ComputeDistance trait, which implement compute_distance and
compute_squared_distance.

For vector, compute_squared_distance is necessary because we use Euclidean
distance as the distance between two values. The easier way to implement
compute_squared_distance is to square the result from compute_distance, but
for some property values, they may have many components, e.g. (v1, v2, v3).
If we just square the result from compute_distance, the computation is
(sqrt(v1^2 + v2^2 + v3^2))^2. There are two redundant operators:
"square-root" and then "square". In order to avoid this, we should
implement compute_squared_distance separately for these types.

MozReview-Commit-ID: LmmrUXYlDb6
2017-04-21 11:37:57 +08:00
Nazım Can Altınova
f9225d84aa
Implement moz-transform property 2017-04-19 22:11:54 +03:00
Boris Chiou
43f9f8ca95 Bug 1353628 - Part 3: Create PropertyAnimation for shorthands.
Therefore, we can start transitions on shorthand properties properly.

MozReview-Commit-ID: Ev2u2tEalnK
2017-04-19 17:42:44 +08:00
Boris Chiou
a06ce4a6aa Bug 1353628 - Part 1: Add shorthand properties into TransitionProperty.
In order to make TransitionProperty::parse() also work on shorthands, we
should add shorthands into TransitionProperty, and add the arms in other
functions which match TransitionProperty.

MozReview-Commit-ID: KFd26KcQf3N
2017-04-19 17:42:24 +08:00
bors-servo
4d8c9c10cb Auto merge of #16496 - BorisChiou:stylo/transition/trigger, r=heycam
stylo: Bug 1341372 - Detect new transitions and let it run.

These are interdependent patches of Bug 1341372. We let animation-only restyle also work for RESTYLE_CSS_TRANSITIONS, and check if we need to update transitions by each transition property. If it is necessary to create/replace/cancel transitions, we create a SequentialTask for CSS_TRANSITIONS.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix Bug 1341372
- [X] These changes do not require tests because there are 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/16496)
<!-- Reviewable:end -->
2017-04-17 05:07:23 -05:00
Boris Chiou
2399cde504 Bug 1341372 - Part 5: Add TransitionProperty::any.
TransitionProperty::any returns true if one of its closure returns true.

MozReview-Commit-ID: 4YsKkHaWCYq
2017-04-17 17:06:37 +08:00
Mantaroh Yoshinaga
48ab03ec91 Make column-count/column-gap/column-width animatable. 2017-04-17 16:26:53 +09:00
Boris Chiou
51ad646c96 Bug 1343753 - Add Servo_Property_IsAnimatable.
MozReview-Commit-ID: 343Md43bpij
2017-04-12 18:32:53 +08:00
Boris Chiou
28db6788b1 Bug 1343753 - Add Servo_Property_IsDiscreteAnimatable.
MozReview-Commit-ID: 5pMw7Wynv2q
2017-04-12 18:32:50 +08:00
Hiroyuki Ikezoe
4ff5a1ef70 Add a tweak to avoid calling interpolate() if animation_type is discrete.
For discrete type of animations, we just need to return 'from' value if
progress is less than 0.5 and otherwise return 'to' value.

https://w3c.github.io/web-animations/#discrete-animation-type
2017-04-07 10:38:33 +09:00
Hiroyuki Ikezoe
97aacb242e Add an FFI function that returns an AnimationValue for a given nsCSSPropertyID from computed values.
When we compose style for a given nsCSSPropertyID in the case where
we have no specified values in target keyframe, we use this AnimationValue
for composition as if it's specified.
2017-04-06 10:30:28 +09:00
Hiroyuki Ikezoe
4516d25889 Make TransitionProperty::from_declaration() convert PropertyDeclaration::{CSSWideKeyword,WithVariables} as well. 2017-04-06 10:08:43 +09:00
Hiroyuki Ikezoe
ec40d1db91 Make AnimationValue::from_declaration return computed CSS variable.
In Gecko, we resolve CSS variables when we generate keyframes for each
animations (i.e. when we create script animations, when we create/update CSS
animations). AnimationValue::from_declaration is only called in both cases.
2017-04-05 09:09:13 +09:00
Emilio Cobos Álvarez
fc72f096a0
style: Properly track whether <angle> or <time> values came from calc() expressions. 2017-03-27 12:42:22 +02:00