Commit graph

61 commits

Author SHA1 Message Date
Nicolas Silva
239f2da9d9
style: Update to euclid 0.20.
Differential Revision: https://phabricator.services.mozilla.com/D38530
2019-07-23 22:54:08 +02:00
Emilio Cobos Álvarez
8c8ef22e6b style: Remove some more individual-transform dead code.
Differential Revision: https://phabricator.services.mozilla.com/D31705
2019-05-29 16:14:15 +02:00
Emilio Cobos Álvarez
3034d66eef style: Use cbindgen to back CSS transforms.
This avoids the expensive conversion, and cleans up a bunch.

Further cleanup is possible, just not done yet to avoid growing the patch even
more.

Differential Revision: https://phabricator.services.mozilla.com/D30748
2019-05-29 16:14:12 +02:00
Emilio Cobos Álvarez
5aeab7adb1 style: Reformat recent changes. 2019-03-13 15:08:38 +01:00
Emilio Cobos Álvarez
c16e88d229 style: Remove Options from TransformOperation.
This may or may not be part of the plan to get rid of nsCSSValue ;)

Option is not usable via FFI, and they should not be needed (we should be
following the shortest serialization principle instead). These patches also do
that, which matches the other transform properties. I think that slight change
is fine, if we can make it work, and consistent with other properties.

Alternative is adding more TransformOperation variants or such, which I rather
not do.

Differential Revision: https://phabricator.services.mozilla.com/D21862
2019-03-13 15:08:26 +01:00
Emilio Cobos Álvarez
7d01114cbf style: Add a Zero trait that doesn't require Add, and use it in place of num_traits and IsZeroLength.
Use it to be consistent in InsetRect serialization and storage between Servo and
Gecko.

Differential Revision: https://phabricator.services.mozilla.com/D21493
2019-03-13 15:08:14 +01:00
Emilio Cobos Álvarez
be616c31e8 style: Rustfmt recent changes. 2019-02-23 21:05:32 -08:00
Emilio Cobos Álvarez
71daec59eb style: Use Rust types from transform-origin / perspective-origin.
Differential Revision: https://phabricator.services.mozilla.com/D20382
2019-02-23 21:05:23 -08:00
Emilio Cobos Álvarez
daf1f02feb style: Rename LengthOrPercentage to LengthPercentage.
It does not represent `<length> | <percentage>`, but `<length-percentage>`, so
`LengthOrPercentage` is not the right name.

This patch is totally autogenerated using:

rg 'LengthOrPercentage' servo | cut -d : -f 1 | sort | uniq > files
for file in $(cat files); do sed -i "s#LengthOrPercentage#LengthPercentage#g" $file; done

Differential Revision: https://phabricator.services.mozilla.com/D15812
2019-01-08 12:00:48 +01:00
Emilio Cobos Álvarez
ca503b4908 style: Simplify computed::LengthOrPercentage and friends.
This is a first step to share LengthOrPercentage representation between Rust and
Gecko.

We need to preserve whether the value came from a calc() expression, for now at
least, since we do different things depending on whether we're calc or not right
now. See https://github.com/w3c/csswg-drafts/issues/3482 and dependent bugs for
example.

That means that the gecko conversion code needs to handle calc() in a bit of an
awkward way until I change it to not be needed (patches for that incoming in the
next few weeks I hope).

I need to add a hack to exclude other things from the PartialEq implementation
because the new conversion code is less lossy than the old one, and we relied on
the lousiness in AnimationValue comparison (in order to start transitions and
such, in [1] for example).

I expect to remove that manual PartialEq implementation as soon as I'm done with
the conversion.

The less lossy conversion does fix a few serialization bugs for animation values
though, like not loosing 0% values in calc() when interpolating lengths and
percentages, see the two modified tests:

 * property-types.js
 * test_animation_properties.html

Differential Revision: https://phabricator.services.mozilla.com/D15793
2019-01-07 17:05:40 +01:00
Emilio Cobos Álvarez
6722e71aba Fix formatting of inverse transform matrix. 2018-12-02 14:17:31 -05:00
Boris Chiou
c81e1d82d5 style: Expand the mako code of Matrix3D and move them into transform.rs.
Although the methods of Matrix3D in animated_properties.mako.rs could be
simplified by mako, it's a little bit hard to read because they are far
from the usage and definition. Therefore, we move them to the definition of
computed::Matrix3D and expand the mako.

Differential Revision: https://phabricator.services.mozilla.com/D11961
2018-12-02 14:17:18 -05:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Boris Chiou
c6ead1dc0e
style: Percentage values of translate are serialized as percent for computed values.
Basically, we rewrite the type of generics::transform::Translate and its
ToCss to match the spec. Besides, we always serialize Translate by servo,
so we could drop a lot of duplicated code.

Differential Revision: https://phabricator.services.mozilla.com/D11206
2018-11-10 21:11:36 +01:00
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01:00
Emilio Cobos Álvarez
175e594652
style: Format recent patches. 2018-11-08 15:22:29 +01:00
Boris Chiou
23f2e99e99
style: Fix the default behavior of scale:<number>{1}.
The current spec says: "If only the X value is given, the Y value
defaults to the same value.", so we should update the behavior.

Besides, we also update the serialization, so we serialization both
specified and computed value by servo. We enable the preference
for all the css-transforms, so some of them are passed now.

Differential Revision: https://phabricator.services.mozilla.com/D10638
2018-11-08 15:22:28 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
Boris Chiou
a20b6a5166
style: Split TimingFunction into a separate file to match spec.
TimingFunction is defined in a separate spec (i.e. css-easing), instead
of transform, so we move it into a different file.

Depends on D9310

Differential Revision: https://phabricator.services.mozilla.com/D9311
2018-10-28 23:44:26 +01:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Emilio Cobos Álvarez
6dcf9b7630
style: Use decomposition to interpolate matched perspective transform operations.
Looks like this produces sensible results for interpolation with 0, though I'm
not really convinced about the results from, let's say, 1px to 2000px in the
attached test-case, I would've expected a linear interpolation from that to go
through normal length interpolation.

css-transforms-1 says:

  > Two transform functions with the same name and the same number of arguments
  > are interpolated numerically without a former conversion. The calculated
  > value will be of the same transform function type with the same number of
  > arguments.
  >
  > Special rules apply to <matrix()>.

Which is what we do... I was going to file a spec issue but turns out that it's
already addressed in css-transforms-2:

  https://drafts.csswg.org/css-transforms-2/#interpolation-of-transform-functions

Which says:

  > The transform functions <matrix()>, matrix3d() and perspective() get
  > converted into 4x4 matrices first and interpolated as defined in section
  > Interpolation of Matrices afterwards.

Differential Revision: https://phabricator.services.mozilla.com/D4942
2018-09-05 19:11:26 +02:00
Emilio Cobos Álvarez
2e500d70ef
style: Match rotate ops.
Per bug 1322189 we really should. I've copied the setup we have already for
translate / scale, but we should really clean this up a bit more I'd think.

In any case, probably skew should be matched as well...

Bug: 1464615
Reviewed-by: hiro
MozReview-Commit-ID: Jky5k8HVfuH
2018-05-28 16:02:31 +02:00
Emilio Cobos Álvarez
0ef70d52f2
style: Fix perspective interpolation.
It's not sound to insert random matrices in random positions in the transform
operation list.

I cannot make any sense of what the old code was trying to do.

Bug: 1458715
Reviewed-by: hiro
MozReview-Commit-ID: 5BtCiueEPlR
2018-05-05 16:22:47 +02:00
Bobby Holley
c99bcdd4b8 Run rustfmt on selectors, servo_arc, and style.
This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
2018-04-10 17:35:15 -07:00
Bobby Holley
f7ae1a37e3 Manual fixups so that the rustfmt output won't trigger tidy. 2018-04-10 17:33:25 -07:00
Emilio Cobos Álvarez
7473796aba
style: Unship the legacy syntax for -moz-transform.
Intent to unship link:

  https://groups.google.com/d/msg/mozilla.dev.platform/T3PGm97MPNU/59XUavMlCgAJ

Reviewed-by: xidorn
Bug: 1438297
MozReview-Commit-ID: 6ybGBasPAWU
2018-02-19 10:46:14 +01:00
Anthony Ramine
1f8777bb0b Move TransformStyle out of Mako files 2018-02-01 12:40:36 +01:00
CJ Ku
174f5f7128 Implement scale property styling 2018-01-31 22:12:34 +00:00
CJ Ku
de3e8c9a8b Implement translate property styling 2018-01-31 22:12:33 +00:00
CJ Ku
62c0c6feee Implement rotate property styling 2018-01-31 22:12:26 +00: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
1c12e0ebc6
Rustfmt the new files 2017-11-02 14:30:16 -07:00
Manish Goregaokar
6415294fd5
Fix unit tests 2017-11-02 14:30:15 -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
Manish Goregaokar
5ce2966bda
Add utilities for converting Transform to euclid types 2017-11-02 14:30:03 -07:00
Manish Goregaokar
2de3464374
Add ToAnimatedZero implementation 2017-11-02 14:30:02 -07:00
Manish Goregaokar
d6525e030a
Add specified and computed variants of Transform/TransformOperation 2017-11-02 14:29:59 -07: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
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
Manish Goregaokar
83e3394904 stylo: Preserve the variant of translate() values in computed transforms 2017-09-13 15:21:26 -07:00
Boris Chiou
ce9f1ed143 Fix extremely small pixel value for transform on Servo.
Sometimes, we want to use extremely small pixel value in transform, e.g.
translate(calc(0.001px)), which should be rendered correctly together
with scale(100000). This patch only fixes this case for Servo because
Stylo still uses Au on the Gecko side, even if we pass pixel value into
FFI directly in the previous patch.
2017-09-13 18:10:47 +08: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
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