Commit graph

46 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
239302b1ed style: Split clip-path and shape-outside values.
We don't actually share _that_ much code across them. This makes callers clearer
and code less confusing, IMHO.

This also has the benefit of not autocompleting path from devtools for
shape-outside.

Differential Revision: https://phabricator.services.mozilla.com/D62373
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
4dadcf71a5 style: Some preparation to start using cbindgen for shape-outside and clip-path.
Tweak the ShapeSourceRepresentation so that it doesn't store Option<>s.

Some renames so that GeometryBox doesn't conflict with the Gecko type, and some
other usual bits / re-exports to deal with cbindgen and generics.

Also, drive-by derive parsing of GeometryBox as it's trivial.

Doing this unfortunately is not possible without removing nsStyleImage first, so
let's do that before.

This makes us serialize in the shortest form for shape-outside, but that's what
we should do anyway.

(aside: the shapes code is a bit too generic, maybe we should unify
ClippingShape and FloatAreaShape...)

Differential Revision: https://phabricator.services.mozilla.com/D62163
2020-04-16 16:35:07 +02:00
violet
e1e82dbe5f
style: Should not serialize default radius of circle.
Should not serialize default shape-outside circle() function radius.

The ToCss impl of Circle and Ellipse turn out to be identical in specified and computed value, thus move them to generics.

Differential Revision: https://phabricator.services.mozilla.com/D35183
2019-06-25 13:11:30 +02:00
Emilio Cobos Álvarez
559235edad style: Use the owned slice type for basic shape polygon coordinates.
This enables destructors for tagged unions in cbindgen, implemented in:

 * https://github.com/eqrion/cbindgen/pull/333

Which allow us to properly generate a destructor for the cbindgen-generated
StyleBasicShape (which now contains an OwnedSlice).

For now, we still use the glue code to go from Box<BasicShape> to
UniquePtr<BasicShape>. But that will change in the future when we generate even
more stuff and remove all the glue.

I could add support for copy-constructor generation to cbindgen for tagged
enums, but I'm not sure if it'll end up being needed, and copy-constructing
unions in C++ is always very tricky.

Differential Revision: https://phabricator.services.mozilla.com/D29769
2019-05-10 12:43:03 +02:00
Emilio Cobos Álvarez
2a6cdaa30a Rustfmt recent changes. 2019-01-08 12:01:28 +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
Boris Chiou
f0f3eb3194 style: Clamp to non-negative value after doing interpolation for circle(), ellipse(), and inset().
Replace LengthOrPercentage with NonNegativeLengthOrPercentage on
ShapeRadius, Circle, Ellipse. And derive ToAnimatedValue for ShapeSource and
its related types, so we clamp its interpolated results into non-negative
values. (i.e. The radius of circle()/ellipse() and the border-radius of
inset().)

Note: We may get negative values when using a negative easing function, so the
clamp is necessary to avoid the incorrect result or any undefined behavior.

Differential Revision: https://phabricator.services.mozilla.com/D14654
2019-01-07 00:32:49 +01:00
Emilio Cobos Álvarez
ca1ad003bd style: Use NonNegative more in the border code.
This ended up not being so small of a patch as I'd have thought, since it
propagated a bit. But most of it is mechanical. Interesting part is
NonNegativeNumberOrPercentage and the actual uses of the NonNegative stuff and
during parsing.

This looks like it'd fix a few correctness issues during interpolation for all
the types except for BorderRadius and co (which handled it manually).

I should write tests for those in a different patch.

Differential Revision: https://phabricator.services.mozilla.com/D14673
2019-01-07 00:03:41 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
Boris Chiou
c7027e2676
style: Use alias for StyleFillRule.
This needs to update the "fill-rule" and "clip-rule" to use
predefined_type to avoid some compilation errors.

Differential Revision: https://phabricator.services.mozilla.com/D10142
2018-11-05 12:30:46 +01: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
Fausto Núñez Alberro
cc838f54e5
Implement a URL-generic type for list-style-image
This should fix the following two "expected to fail" tests:

- getComputedStyle(elem) for url() listStyleImage uses the resolved URL
  and elem.style uses the original URL

- getComputedStyle(elem) for url() listStyle uses the resolved URL
  and elem.style uses the original URL
2018-04-03 22:01:26 +02: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
Ting-Yu Lin
923ffcf2cc style: Support shape-image: <image>
MozReview-Commit-ID: GSCZIMEpCS2
2017-11-29 11:27:31 +08:00
Gecko Backout
9651a5572e Backed out changeset 1fdcd69d2524 for Build Bustage. r=backout on a CLOSED TREE
Backs out https://github.com/servo/servo/pull/19376
2017-11-26 11:00:42 +00:00
Ting-Yu Lin
f3dbaad222 style: Support shape-image: <image>
MozReview-Commit-ID: GSCZIMEpCS2
2017-11-26 17:07:52 +08:00
Ting-Yu Lin
107a9b2c81 style: Use ComputedUrl instead of SpecifiedUrl in conversion.rs
In stylo, ComputedUrl and SpecifiedUrl happen to be the same. However, using
ComputedUrl can make code clearer that conversion.rs is for converting
computed values between gecko and servo types.
2017-11-21 15:08:44 +08:00
Fausto Núñez Alberro
14c5a1b8d3 Introduce ComputedUrl
Add web platform tests for computed URL styles

Mark url with no original or resolved unreachable

Update the WPT manifest for new url tests
2017-08-09 13:55:39 +02:00
Anthony Ramine
5704e02529 Fix serialisation of computed circle() shapes 2017-06-07 23:47:03 +02:00
Anthony Ramine
af3ede418b Refactor BorderRadius and move it to the border modules
BorderRadius now parses itself reusing Rect<T>.
2017-05-28 14:36:37 +02:00
Anthony Ramine
66aa38e1a1 Fix serialisation of computed circles 2017-05-22 14:03:14 +02:00
Anthony Ramine
a65c874ec8 Refactor basic shapes 2017-05-22 14:03:12 +02:00
Ravi Shankar
d56aec4109 Make ShapeSource generic 2017-04-25 17:42:02 +05:30
Ravi Shankar
24226af794 Make InsetRect generic 2017-04-25 17:40:41 +05:30
Ravi Shankar
f4b18643c2 Cleanup Polygon and make it generic 2017-04-25 17:13:45 +05:30
Ravi Shankar
a36bf9efc4 Make ShapeRadius generic 2017-04-25 17:13:44 +05:30
Ravi Shankar
b2b3f99427 Make BorderRadius generic 2017-04-25 17:13:42 +05:30
Ravi Shankar
26fda04888 Separate serialization function for BorderRadius 2017-04-13 11:03:39 +05:30
Emilio Cobos Álvarez
f37aa12927
style: Prevent more missing docs in the values module. 2016-12-31 12:17:02 +01:00
Emilio Cobos Álvarez
5f2e7af864
style: Centralize specified url value handling, and refcount urls. 2016-11-10 13:15:21 +01:00
Ravi Shankar
6061985898 Prefer Servo-specific ToCss for all types 2016-11-07 09:14:22 +05:30
UK992
93a103ba73 Reorder use statements 2016-09-09 04:55:19 +02:00
bors-servo
609d47b44f Auto merge of #12878 - Manishearth:clip-path, r=heycam
stylo: Support clip-path

Todo:

 - [x] `set_clip_path` (probably needs a bunch of gecko bindings for running constructors/destructors)
 - [ ] Ensure that I've ordered the coordinates correctly
 - [ ] Check that it works
 - [x] Might want to convert NS_STYLE_FILL_RULE and NS_RADIUS to enum classes

Depends on:

 - https://github.com/servo/rust-bindgen/pull/29
 - https://github.com/Manishearth/gecko-dev/compare/servo:stylo...Manishearth:clip-path

<!-- 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/12878)
<!-- Reviewable:end -->
2016-08-19 14:24:08 -05:00
Manish Goregaokar
3895b7118e
Handle clip-path in stylo 2016-08-19 23:36:37 +05:30
Manish Goregaokar
254900bd1a
Add ShapeSource to basic-shape values 2016-08-18 11:38:33 +05:30
David Raifaizen
3831c0650c Adding support for correct shorthand serialization 2016-08-16 22:28:51 -04:00
Manish Goregaokar
234219cd84 Address review comments 2016-08-05 16:58:38 +05:30
Manish Goregaokar
1e7973263f
Fix tidy 2016-08-02 15:57:30 +05:30
Manish Goregaokar
eb82cc25ef
Add Polygon to basic_shape.rs 2016-08-02 15:57:28 +05:30
Manish Goregaokar
78ce65d5a8
Add Ellipse to basic_shape.rs 2016-08-02 15:57:27 +05:30
Manish Goregaokar
77f345476f
Add Circle to basic_shape.rs 2016-08-02 15:57:25 +05:30
Manish Goregaokar
88c1a67d89
Add ShapeRadius to basic_shape.rs 2016-08-02 15:57:22 +05:30
Manish Goregaokar
2580c1dc6e
Add InsetRect, move BorderRadius to basic_shape.rs 2016-08-02 15:57:20 +05:30