Commit graph

327 commits

Author SHA1 Message Date
Anthony Ramine
b9505ae72b Merge similar arms in AnimationValue::compute_squared_distance 🐉🐲
This uses the same trick as in PropertyDeclaration::eq.
2018-02-10 16:31:50 +01:00
Anthony Ramine
fc24cf34c5 Merge similar arms in AnimationValue::animate 🐉🐲
This uses the same trick as in PropertyDeclaration::eq and removes
roughly 10KB off of libxul.
2018-02-10 16:31:49 +01:00
Anthony Ramine
38520af970 Merge similar arms in AnimationValue::uncompute 🐉🐲
This uses the same kind of trick as PropertyDeclaration::clone and
removes 15KB off of libxul according to bloaty.
2018-02-10 16:31:48 +01:00
Anthony Ramine
aa7cc261f8 Determine animated types from specified types 2018-02-10 16:31:48 +01:00
Anthony Ramine
57daf06c71 Make PropertyDeclaration::id and AnimationValue::id inline 2018-02-10 16:31:46 +01:00
Anthony Ramine
921d1aeeba Make AnimationValue::id be just a pointer cast 🐉🐲
Now that PropertyDeclaration and AnimationValue have the same discriminants,
that means the trick found in PropertyDeclaration::id can be done in
AnimationValue::id.
2018-02-10 16:31:45 +01:00
Anthony Ramine
79775541f2 Make AnimationValue have the same variants as PropertyDeclaration
By making AnimationValue have the same representation as PropertyDeclaration
and Void variants for non-animatable properties, we know by constructions
that all properties have the same discriminant in both.
2018-02-10 12:37:30 +01:00
Anthony Ramine
f017743a55 Derive ComputeSquaredDistance for animated filters 2018-02-08 03:14:23 +01:00
Anthony Ramine
5195eb38f2 Make all PropertyDeclaration variants have only one field 2018-02-06 13:45:18 +01:00
Emilio Cobos Álvarez
3b34d734e6
style: Refactor font-feature-settings and font-variation-settings.
This fixes all known issues with serialization and parsing of these two
properties, and in particular calc handling and such:

  https://bugzilla.mozilla.org/show_bug.cgi?id=1434692
  https://bugzilla.mozilla.org/show_bug.cgi?id=1434724

Also does a fair amount of cleanup and all that, which was needed.
2018-02-01 12:54:45 +01:00
Emilio Cobos Álvarez
09398d42af
style: Move a bunch of font stuff living under generics to the proper module.
FontSettingsTagInt and such shouldn't be in the generic module, I know...

But that will change in a bit.
2018-02-01 02:35:33 +01:00
Emilio Cobos Álvarez
1380f1a14f
style: Remove the stupid space serialization on font-settings. 2018-02-01 02:35:32 +01:00
CJ Ku
8a4661b829 Implement Animate trait for individual transforms 2018-01-31 22:15:31 +00:00
CJ Ku
9a62c0bf02 Implement interpolation of Quaternions
So that we can reuse the code in ComputedRotate.
2018-01-31 22:12:35 +00:00
Anthony Ramine
cd8f96cc9e Change ToCss to take a CssWriter<W>
This more concrete wrapper type can write a prefix the very first time something
is written to it. This allows removing plenty of useless monomorphisations caused
by the former W/SequenceWriter<W> pair of types.
2018-01-23 10:41:42 +01:00
Bobby Holley
f858ce91e8 Avoid entraining various Debug impls in release builds.
MozReview-Commit-ID: Lp9i9EI5qdU
2018-01-13 09:51:46 -08:00
Manish Goregaokar
82e024913b stylo: Correctly handle interpolation where optional second argument for translate(), skew(), scale() exists in one but not the other
MozReview-Commit-ID: 59rNRAXBEN9
2017-12-18 18:45:25 -08:00
Brian Birtles
150db42ef6 Update references to Web Animations spec 2017-12-15 16:21:26 -06:00
Emilio Cobos Álvarez
af879523ea
style: Make all keywords CamelCase for consistency.
This prevents confusion and paves the ground for derive(Parse) of them.
2017-12-06 02:35:10 +01:00
Boris Chiou
3a38e815ec Implement Servo_ParseTransformIntoMatrix.
DOMMatrix needs to convert a specified transform list into a matrix, so
we could rewrite to_transform_3d_matrix by generics for both specified
and computed transform lists.

Besides, we have to update the test case because we use Transform3D<f64> to
compute the matrix, instead of Transform3D<f32>, so the result will be
the same as that in Gecko. Using 0.3 may cause floating point issue
because (0.3f32 as f64) is not equal to 0.3 (i.e. floating point precision
issue), so using 0.25 instead.
2017-11-28 10:08:12 +08:00
Manish Goregaokar
cb9645cd17
Comments and minor fixes 2017-11-02 14:37:54 -07:00
Manish Goregaokar
5098948c0d
Handle distance calculation of new variants 2017-11-02 14:30:14 -07:00
Manish Goregaokar
ca02785e02
Handle case of empty transform lists 2017-11-02 14:30:12 -07:00
Manish Goregaokar
9c9a181f35
Allow cross interpolation between differing translate/scale functions
See ToPrimitive() in StyleAnimationValue.cpp
2017-11-02 14:30:11 -07:00
Manish Goregaokar
f699b8cfb2
Handle animating 2D matrices 2017-11-02 14:30:10 -07:00
Manish Goregaokar
aba00be52d
Add more operations to animation 2017-11-02 14:30:09 -07:00
Manish Goregaokar
6631594e28
Replace old transform code with new generic code 2017-11-02 14:30:04 -07:00
Jeremy Chen
d7a5f22408 stylo: Avoid using InterpolateMatrix as a fallback for matched transform function pair.
In the current implementation, if there is any interpolation error in a matched
transform function pair, we fall-back to use InterpolateMatrix unconditionally.
However, the error could be caused by:

1. mismatched transform function pair
2. matched transform function pair within at least one undecomposable matrix.

Using InterpolateMatrix for case 1 makes sense, however, using InterpolateMatrix
for case 2 does not. According to the spec, we should just report error for
case 2, and let the caller do the fallback procedure. Using InterpolateMatrix
for case 2 will go through more unnecessary code path, and produce more memory
usage and calculation cost, which should be avoidable.

In this patch, we add an extra pass to check if a transform function pair have
matched operations in advance. With this information, we can easily tell whether
the interpolation error in a equal-length transform function pair is caused by
case 1 or case 2. So, we can avoid the unnecessary cost.

Gecko bug: Bug 1399049
2017-10-20 15:04:43 +08:00
Nicholas Nethercote
4506f0d30c Replace all uses of the heapsize crate with malloc_size_of.
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`.
`malloc_size_of` is better -- it handles various cases that `heapsize` does not
-- so this patch changes Servo to use `malloc_size_of`.

This patch makes the following changes to the `malloc_size_of` crate.

- Adds `MallocSizeOf` trait implementations for numerous types, some built-in
  (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`).

- Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't
  support that operation.

- For `HashSet`/`HashMap`, falls back to a computed estimate when
  `enclosing_size_of_op` isn't available.

- Adds an extern "C" `malloc_size_of` function that does the actual heap
  measurement; this is based on the same functions from the `heapsize` crate.

This patch makes the following changes elsewhere.

- Converts all the uses of `heapsize` to instead use `malloc_size_of`.

- Disables the "heapsize"/"heap_size" feature for the external crates that
  provide it.

- Removes the `HeapSizeOf` implementation from `hashglobe`.

- Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of`
  doesn't derive those types, unlike `heapsize`.
2017-10-18 22:20:37 +11:00
Matt Brubeck
efc3683cc7 Fix commonmark Markdown warnings in docs, part 1
Fixes warnings from rust-lang/rust#44229 when `--enable-commonmark` is
passed to rustdoc.

This is mostly a global find-and-replace for bare URIs on lines by
themselves in doc comments.
2017-10-17 11:24:57 -07:00
Simon Sapin
c0f8f15f39 Update to cssparser 0.22 (source location in error types) 2017-10-10 13:28:17 +02:00
Boris Chiou
df07ebde99 Use default Debug trait for AnimationValue.
We use AnimationValue for animation backend to do interpolation,
accumulation, or computing distance. While debugging it, dumping the
property name is not enough. We need to dump the detailed value contained
in it.
2017-10-09 14:06:06 +08:00
Josh Matthews
01c35f99cd Remove 5k from AnimationValue::compute_squared_distance. 2017-10-03 13:22:32 +02:00
Josh Matthews
799014755e Remove 10k from AnimationValue::animate. 2017-10-03 13:22:32 +02:00
Josh Matthews
13df088201 Remove 10k from AnimationValue::from_declaration. 2017-10-03 13:22:31 +02:00
Emilio Cobos Álvarez
2adfd84636
style: Avoid being so Arc-happy in the custom properties code. 2017-10-01 13:27:15 +02:00
Emilio Cobos Álvarez
3215e36b5b
style: Cleanup the animated value setup.
We have three different enums to represent slightly different things. Reuse them
properly, and kill some code in the animated_properties module while at it.

MozReview-Commit-ID: 5ZAly8f4lWy
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-09-29 13:20:50 +02:00
Hiroyuki Ikezoe
1b39041a8c Factor custom properties in keyframes into compute values in each keyframe 2017-09-27 18:27:55 +09:00
J. Ryan Stinnett
c5c604b9c4 Update inherited prop state for animation
`AnimationValue` has its own path for conversion to computed values, so we need
to update `for_non_inherited_property` in the context to match the property
being converted.

I didn't notice any other generic conversions, so hopefully this is the only
missing path.

MozReview-Commit-ID: HskrpMctmYE
2017-09-21 15:52:35 -05:00
Jeremy Chen
21148c7e51 stylo: do not handle the fallback discrete animation inside the Animate trait.
At present, we do the fallback discrete animation for non-invertible matrices in
ComputedMatrix.animate(). However, according to the spec, we should fallback to
discrete animation for cases like:

1. animation between transform with single non-invertible matrix
2. animation between transform with matched transform functions that have at least
   one non-invertible matrix
2. animation between transform with mismatched transform functions that have at
   least one non-invertible matrix.

The current implementation only handles the first case.

Moreover, we already have fallback discrete animation procedures in CSS Animation
and Web Animation, so we should be able to not doing any fallback inside the
Animate trait.

In this patch, we let the animation between non-invertible matrices to return Err().
So, we can propagate the Err() to the callers, and let the fallback discrete
animation procedure stay at the Servo_MatrixTransform_Operate, which is ouside
the Animate trait.
2017-09-21 15:30:18 +08:00
Emilio Cobos Álvarez
7d91b30172
style: Depend less on animated_value_type.
It's just redundant, and I plan to do autogenerate all this stuff, and I don't
want redundant stuff in the manifest.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-09-17 04:31:15 +02:00
Gecko Backout
1aa0b20e09 Backed out changeset 616bd23b9896 (bug 1391145) for frequently failing mochitests layout/style/test/test_animations.html and layout/style/test/test_animations_omta.html on Linux x64. r=backout
Backs out https://github.com/servo/servo/pull/18492
2017-09-16 13:48:06 +00:00
bors-servo
90689b7916 Auto merge of #18492 - Manishearth:stylo-translate, r=hiikezoe
stylo: Preserve variants of 2d translate/rotate/scale functions in computed transform

Necessary for the animation inspector to show the right thing.

r=hiikezoe https://bugzilla.mozilla.org/show_bug.cgi?id=1391145

fixes bug 1391145

<!-- 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/18492)
<!-- Reviewable:end -->
2017-09-16 03:33:44 -05:00
Manish Goregaokar
a7a5adb71a stylo: Fix TransformOperation.animate() implementation 2017-09-15 14:36:28 -07:00
Manish Goregaokar
06300999e9 stylo: Preserve the variant of rotate() values in computed transforms
MozReview-Commit-ID: Dmw7P21I6FN
2017-09-15 14:36:27 -07:00
Manish Goregaokar
e74d04c040 stylo: Preserve the variant of scale() values in computed transforms 2017-09-15 14:36:25 -07:00
Josh Matthews
d41baf7f5f Share more strings between Debug implementations for property-based types. 2017-09-14 11:52:46 -04:00
Josh Matthews
ecd8abb178 Reduce code duplication in TransitionProperty::from. 2017-09-14 11:52:00 -04:00
Nicholas Nethercote
c5aa2cb986 Measure PropertyDeclaration more thoroughly.
This patch replaces the handwritten MallocSizeOf implementation for
PropertyDeclaration with a derived one, which gives much more thorough
measurement.

This requires (a) deriving MallocSizeOf for a *lot* of additional types (most
of which already have `derive(HeapSizeOf)` in Servo builds), and (b)
implementing MallocSizeOf for a few more types in the `malloc_size_of` crate.

These changes would significantly improve the reporting coverage for gmail if
it weren't for the fact that SpecifiedUrl isn't measured due to a lack of
clarity about its fields; that can be fixed as a follow-up once bug 1397971 has
landed.
2017-09-14 13:18:03 +10:00
Manish Goregaokar
83e3394904 stylo: Preserve the variant of translate() values in computed transforms 2017-09-13 15:21:26 -07:00