Commit graph

410 commits

Author SHA1 Message Date
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
Boris Chiou
b89286e8e7 Use CSSPixelLength in LengthOrPercentage{*}.
Replace Au with CSSPixelLength in LengthOrPercentage,
LengthOrPercentageOrAuto, and LengthOrPercentageOrNone.
2017-09-13 18:10:46 +08:00
Boris Chiou
535c1e3c6f Replace Au with CSSPixelLength in CalcLengthOrPercentage.
We replace Au with CSSPixelLength for the length part of
computed::CalcLengthOrPercentage. Therefore, it would be easier to use
CSSPixelLength for all other LengthOrPercentage{*} types.
2017-09-13 18:10:39 +08:00
Boris Chiou
a949e2a057 Introduce CSSPixelLength and update NonNegativeLength.
First, we define computed::CSSPixelLength which contains a CSSFloat, a
pixel value, and then we replace computed::Length with CSSPixelLength.
Therefore, the |ComputedValue| of NoCalcLength, AbsoluteLength,
FontRelativeLength, ViewportPercentageLength, CharacterWidth, and
PhysicalLength is CSSPixelLength.

Besides, we drop NonNegativeAu, and replace computed::NonNegativeLength
with NonNegative<computed::Length>. (i.e. NonNegative<CSSPixelLength>)
2017-09-13 18:05:14 +08:00
Anthony Ramine
7c31202dda Implement ToComputedValue for Box<T> 2017-09-12 14:34:16 +02:00
Nicholas Nethercote
32548e5312 Overhaul MallocSizeOf and related things.
This patch makes the MallocSizeOf stuff in Stylo work more like the HeapSizeOf
stuff already in Servo, except better. In particular, it adds deriving support
for MallocSizeOf, which will make it easier to improve coverage.

The patch does the following.

- Combines servo/components/style/stylesheets/memory.rs and the heapsize crate
  into a new crate, malloc_size_of.

- Forks the heapsize_derive crate, calling it malloc_size_of, so that
  MallocSizeOf can be derived.

- Both the new crates have MIT/Apache licenses, like heapsize, in case they are
  incorporated into heapsize in the future.

- Renames the methods within MallocSizeOf and the related traits so they are
  more concise.

- Removes MallocSizeOfWithGuard.

- Adds `derive(MallocSizeOf)` to a lot of types, in some cases replacing an
  equivalent or almost-equivalent hand-written implementation.

- Adds stuff so that Rc/Arc can be handled properly.
2017-09-12 12:37:51 +10:00
Emilio Cobos Álvarez
b94dd4885d
style: Derive ToComputedValue for TransitionProperty. 2017-09-11 11:22:22 +02:00
Hiroyuki Ikezoe
42873abe84 Simplify transition-property parser. 2017-09-09 09:00:22 +09:00
Daisuke Akatsuka
653bced7a5 Implement Animate for FontSettings 2017-09-05 16:12:20 +09:00
Manish Goregaokar
5cd296a264
stylo: Replace all hashtable collections with ones from style::hash 2017-08-31 16:28:30 -07:00
bors-servo
174c37fddd Auto merge of #18301 - servo:derive-all-the-things, r=emilio
Use generics for the vertical-align property

<!-- 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/18301)
<!-- Reviewable:end -->
2017-08-31 09:41:50 -05:00
bors-servo
5624c0e3f1 Auto merge of #18210 - mantaroh:clip-interpolation-fix, r=nox
Skip adding/accumulating ClipRect values which corresponding rect offset is auto.

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

This patch will skip adding/accumulating the values which corresponding rect offset is auto, and  make Servo_AnimationValues_ComputeDistance return negative value instead of 0.0 when the function fails to distinguish its failure.

---
<!-- 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=1390352.

<!-- 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-30 23:21:49 -05:00
Anthony Ramine
542a9337a4 Use generics for the vertical-align property 2017-08-30 23:01:12 +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
Emilio Cobos Álvarez
36ff89bd28
style: Remove HasViewportPercentage.
It's not needed since #18268
2017-08-29 23:51:21 +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