Commit graph

67 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
fa840e1666 style: Implement transform: perspective(none)
Differential Revision: https://phabricator.services.mozilla.com/D123350
2023-05-24 18:32:43 +02:00
Emilio Cobos Álvarez
685e749cfc
style: Switch all callsites of try() to try_parse() in the style crate.
Fully automated via:

  $ rg -l '\.try\(' | xargs sed -i 's/\.try(/.try_parse(/g'
  $ cd servo/components/style && cargo +nightly fmt

Differential Revision: https://phabricator.services.mozilla.com/D80099
2020-06-18 23:51:14 +02:00
Emilio Cobos Álvarez
006417e40a
style: Rustfmt recent changes. 2019-11-30 20:45:07 +01:00
enordin
001c511f9c
style: Have scale function and scale property accept percentage value.
Differential Revision: https://phabricator.services.mozilla.com/D55012
2019-11-30 20:45:06 +01:00
Boris Chiou
b420293a57
style: Treat 3d translate/scale as 2d if the value can be expressed as 2d.
For the individual transform properties if they spec a value that can be
expressed as 2d we treat as 2d and serialize accordingly.

We drop Translate::Translate and Scale::Scale, and then rename
Translate::Translate3D as Translate::Translate, Scale::Scale3D as
Scale::Scale. So now we use Translate::Translate to represent 2d and 3d
translation, and Scale::Scale to represent 2d and 3d scale. There is no
difference between 2d and 3d translate/scale in Gecko because we always
convert them into 3d format to layers (on the compositor thread), so this
change makes things simpler.

Differential Revision: https://phabricator.services.mozilla.com/D52931
2019-11-30 20:45:00 +01:00
Emilio Cobos Álvarez
854c480177 style: Experiment with implementing zoom as a transform + transform-origin shorthand.
This is a gross hack, of course, but has the advantage of not breaking sites
that use both zoom and -moz-transform / -moz-transform-origin.

There should be no behavior change when the pref is off, of course, and the
webcompat team wanted to experiment with this.

Differential Revision: https://phabricator.services.mozilla.com/D49792
2019-11-04 13:36:32 +01:00
Emilio Cobos Álvarez
ed2e9ce482
Rustfmt and fix tidy on recent changes. 2019-06-25 13:11:31 +02:00
Emilio Cobos Álvarez
a4690ce158
style: Use cbindgen for gradients.
Differential Revision: https://phabricator.services.mozilla.com/D33901
2019-06-25 13:11:27 +02:00
Emilio Cobos Álvarez
81f40a57e4 style: Reformat recent style system changes. 2019-05-29 16:14:30 +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
Cameron McCormack
40248ae5fd style: Add derived ToShmem implementations.
Differential Revision: https://phabricator.services.mozilla.com/D17197
2019-04-12 12:19:52 +02: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
3a1539ccde style: Appease tidy. 2019-02-23 21:05:34 -08:00
Emilio Cobos Álvarez
73d5b82f9f style: Improve #[derive(Parse)].
I want to do this so that I can get rid of Either<>. The reasons for getting rid
of either are multiple:

 * It doesn't generate as nice C++ code using cbindgen.
 * It isn't that nice to use either from Rust.
 * cbindgen has bugs with zero-sized types.

I started using this for ColorOrAuto and a few others, for now.

Differential Revision: https://phabricator.services.mozilla.com/D19844
2019-02-23 21:04:44 -08:00
Emilio Cobos Álvarez
80651fde47 style: Manually rename some variables.
lop is not an acceptable variable name for LengthPercentage.

Differential Revision: https://phabricator.services.mozilla.com/D15813
2019-01-08 12:00:48 +01: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
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Emilio Cobos Álvarez
06fe0a1fc0
style: Fix formatting. 2018-11-17 09:56:05 +01:00
Boris Chiou
41d2f7f3a2
style: Support keywords [x|y|z] on rotate.
Update the parser and the serialization to support the keywords, [x|y|z].

Differential Revision: https://phabricator.services.mozilla.com/D11531
2018-11-17 09:56:01 +01:00
Boris Chiou
d8bd29292e
style: Parse any order of number and angle for Rotate.
Rotate accepts rotate axis and angle in any order
(i.e. <number>{3} <angle> or <angle> <number>{3}), so we rewrite the
parser.

Differential Revision: https://phabricator.services.mozilla.com/D11417
2018-11-17 09:56:00 +01:00
Emilio Cobos Álvarez
212b3e1311
style: Revert try -> r#try change.
Since we're in an inconsistent state because mako files weren't updated, and
it's really really ugly.
2018-11-10 21:42:17 +01:00
Emilio Cobos Álvarez
155caba595
style: Cargo fix + ./mach fmt. 2018-11-10 21:11:47 +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
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
Boris Chiou
3a536f463c
style: Drop frames() timing function.
frames() timing function was removed from the spec, so we drop it.
Besides, some devtool tests are removed because they use frame(). I will
add them back by using new step function later.

Differential Revision: https://phabricator.services.mozilla.com/D9309
2018-10-28 23:44:16 +01:00
Xidorn Quan
0f7f9eebc0
style: Add some attributes for SpecifiedValueInfo to help deriving more from types.
Bug: 1434130
Reviewed-by: emilio
MozReview-Commit-ID: IyohSTbUO31
2018-04-29 03:28:48 +02:00
Xidorn Quan
7fe7b2ffb1
style: Add a ValueInfo trait for exposing types needed by devtools.
Most of types just derive it using proc_macro directly. Some of value
types need manual impl.

In my current plan, this new trait will be used in bug 1434130 to expose
values as well.

Bug: 1455576
Reviewed-by: emilio
MozReview-Commit-ID: LI7fy45VkRw
2018-04-29 03:28:34 +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
Nicholas Nethercote
8705fb3783 Convert StylePrefs to StaticPrefs. 2018-04-03 11:41:03 +10: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
bors-servo
e4dba3abef Auto merge of #19462 - emilio:angle-parsing, r=nox
style: Cleanup Angle parsing.

This PR also contains a functional change, allowing to parse unitless zero angles in hue-rotate().

See the links and the comments for why.

<!-- 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/19462)
<!-- Reviewable:end -->
2017-12-03 09:14:59 -06:00
Emilio Cobos Álvarez
93fc9ab63a
style: Remove free parsing functions, use Integer::parse and Number::parse instead. 2017-12-02 16:15:11 +01:00
Emilio Cobos Álvarez
3631b1e197
style: Deduplicate Angle parsing code. 2017-12-02 15:39:06 +01:00
Xidorn Quan
8b9bbfea75 Use helpers.predefined_type for transform property. 2017-11-12 10:59:53 -08:00
Gecko Backout
2c1b041fc6 Backed out changeset d77275db6419 (bug 1374178) for failure reftests/transform-3d/translatez-1a.html r=backout a=backout on a CLOSED TREE
Backs out https://github.com/servo/servo/pull/19106
2017-11-07 06:49:27 +00:00
Xidorn Quan
79fb584eac Use helpers.predefined_type for transform property. 2017-11-06 11:49:50 -08:00
Manish Goregaokar
1c12e0ebc6
Rustfmt the new files 2017-11-02 14:30:16 -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
6631594e28
Replace old transform code with new generic code 2017-11-02 14:30:04 -07:00
Manish Goregaokar
5031d14d1b
Use a generic Matrix3D type 2017-11-02 14:30:01 -07:00