Commit graph

164 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
a7b5ba14c0
style: Use references in the shapes code.
It doesn't make much sense to return const UniquePtr<Foo>& for something that
can't be null, it's just confusing.

Also make more stuff actually const.

Differential Revision: https://phabricator.services.mozilla.com/D10647
2018-11-05 12:31:49 +01:00
Boris Chiou
b81bbb85b4
style: Use alias for StylePathCommand.
So we could drop transmute in svg_path related functions.

Differential Revision: https://phabricator.services.mozilla.com/D10140
2018-11-05 12:30:54 +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
Emilio Cobos Álvarez
05f9f10a1c
style: Fix servo build and tidy lints. 2018-10-28 23:52:13 +01:00
Emilio Cobos Álvarez
0191705e87
style: Use searchfox links instead of dxr links for nsRuleNode.
Searchfox has better blame.

Differential Revision: https://phabricator.services.mozilla.com/D9375
2018-10-28 23:43:45 +01:00
Emilio Cobos Álvarez
42def5a011
style: Always compute angle values to degrees.
This matches the spec, https://drafts.csswg.org/css-values/#angles, which says:

> All <angle> units are compatible, and deg is their canonical unit.

And https://drafts.csswg.org/css-values/#compat, which says:

>When serializing computed values [...], compatible units [...] are converted into a single canonical unit.

And also other implementations (Blink always serializes angles as degrees in
computed style for example).

Also allows us to get rid of quite a bit of code, and makes computed angle value
representation just a number, which is nice.

Differential Revision: https://phabricator.services.mozilla.com/D8619
2018-10-19 00:35:22 +02:00
Cameron McCormack
9865a4194c
style: Merge css::{URLValueData, ImageValue} into css::URLValue.
Differential Revision: https://phabricator.services.mozilla.com/D8061
2018-10-19 00:34:27 +02:00
Emilio Cobos Álvarez
f287691f2e
style: fix tidy issues and update test expectations. 2018-10-09 22:01:38 +02:00
Emilio Cobos Álvarez
7345af613a
style: Serialize a bunch of image properties with Servo.
I had to fix the conversion for BackgroundSize too, hopefully we can
simplify all this using cbindgen in the future instead of CalcValue.

Differential Revision: https://phabricator.services.mozilla.com/D7580
2018-10-09 19:45:35 +02:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Emilio Cobos Álvarez
c0f516f17d
style: Appease tidy. 2018-09-03 12:39:02 +02:00
Boris Chiou
bb65d1fb6d
style: Define path() for clip-path.
For now, |clip-path: path()| is chrome-only, and not for shape-outside,
so we only implement the parser for clip-path. Besides, I didn't put
path() in BasicShape because path() doesn't use the reference box to
resolve the percentage or keywords (i.e. SVG path only accept floating
point or integer number as the css pixel value). Therefore, I add it into
ShapeSource, instead of BasicShape.

Differential Revision: https://phabricator.services.mozilla.com/D3633
2018-09-03 12:32:50 +02:00
Boris Chiou
a92f9c105a
style: Move SVGPathData and its parser into svg_path.rs.
SVGPathData will be used by clip-path and offset-path (and/or more on the
properties which support <basic-shape>). Therefore, let's move
SVGPathData out of motion.rs.

Differential Revision: https://phabricator.services.mozilla.com/D3631
2018-09-03 12:32:43 +02:00
Boris Chiou
e46daa09ea
style: Drop the manually implementation of ToCSS for BasicShape::Polygon.
The implementation of ToCSS for Polygon has some rule, and we could use skip_if
to handle and serialization of fill-rule. However, we should derive ToCSS for
the pair of LengthOrPercentages, so define a new type for it.

Differential Revision: https://phabricator.services.mozilla.com/D4153
2018-09-03 12:32:17 +02:00
Emilio Cobos Álvarez
e338bd3add
style: Serialize clip-path and shape-outside using Servo.
Differential Revision: https://phabricator.services.mozilla.com/D3653
2018-09-03 12:30:57 +02:00
Boris Chiou
dce2e2927f
style: Define offset-path and implement it in style system.
Define OffsetPath & SVGPathData on the servo-side, and StyleMotion &
StyleSVGPath on the gecko-side. We parse the SVG Path string into a
vector of PathCommand. To build the gfx::Path, we will convert it into
gfx::Path later in a different patch.

The basic flow is:
  - Parse SVG Path String into SVGPathData (in Rust).
  - Use cbindgen to make sure the layout of PathCommand and StylePathCommand, and then set the Box[PathCommand] into nsTArray<StylePathCommand>.
  - Try to convert nsTArray<StylePathCommand> into gfx::Path. (This part will be implemented in a different patch.)

Finally, we use the gfx::Path to create a motion path transform.
The layout implementation is in the later patch.

Depends on D2962

Differential Revision: https://phabricator.services.mozilla.com/D2963
2018-09-03 12:30:21 +02:00
Boris Chiou
c87668fcd5
style: Use union to wrap different shape-like types. r=xidorn
1. We will add more shape-like types in the future, so it's better to
   use union to reduce the memory usage.
2. Those shape-like types are mutual exclusive, so we could use union to
   wrap them.

Differential Revision: https://phabricator.services.mozilla.com/D2746
2018-08-18 17:47:24 +02:00
Dan Glastonbury
4d255392f7
style: Change nscolor to StyleComplexColor in nsStyleGradientStop.
Bug: 1467379
Reviewed-by: xidorn
MozReview-Commit-ID: D9KQcv9uQ4S
2018-06-18 19:15:28 +02:00
Xidorn Quan
514aba51ad
style: Use RefPtr::new instead of RefPtr::from_ptr_ref + clone.
Bug: 1461858
Reviewed-by: emilio
2018-05-20 18:58:44 +02:00
Xidorn Quan
ecb2ec63de
style: Rename from_url_value_data to from_url_value and reuse URLValue passed in for ComputedUrl.
Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: LJGm3lUS9mD
2018-05-20 18:58:31 +02:00
Xidorn Quan
5b0903e604
style: Have from_image_request reuse ImageValue from image request directly.
And also remove ComputedImageUrl::from_url_value_data.

Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: 5zifQlU7tOz
2018-05-20 18:58:13 +02:00
Xidorn Quan
dc2aadd43a
style: Make creating CssUrl infallible.
There were a check in CssUrl::parse_from_string for extra data, which
was removed as part of servo/servo#16241, so it never fails now.

CssUrl::from_url_value_data doesn't seem to need Result from the very
beginning. It is unclear why it was made that way.

Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: LXzKlZ6wPYW
2018-05-20 18:57:35 +02:00
Emilio Cobos Álvarez
1314f47da5
style: Distinguish between specified and computed URLs.
This is needed to serialize computed URLs correctly from getComputedStyle.

Bug: 1461288
Reviewed-by: xidorn
MozReview-Commit-ID: 9wakhqNrszb
2018-05-19 10:15:17 +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
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
Emilio Cobos Álvarez
55e2cd5dc3
style: Remove unsound Atom From implementations.
Fixes #20158
2018-03-19 11:06:53 +01:00
Xidorn Quan
a99ca543cd Add SpecifiedImageUrl for <url> used as images. 2018-03-08 23:34:32 +11:00
Xidorn Quan
14b708311b Remove some useless clone() call on SpecifiedUrl::image_value. 2018-03-08 21:35:33 +11:00
Anthony Ramine
09e304adb3 Rename FillRule variants to follow the same rules as other enums 2018-02-01 12:43:29 +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
Nazım Can Altınova
9882d0bae5 style: Move text-align outside of the mako file. 2017-12-18 11:58:06 -06: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
Emilio Cobos Álvarez
4927786d90
style: Implement css(dimension) and derive ToCss for a bunch of stuff.
For css(dimension), it'd be nice to derive(Parse) too, I think...
2017-11-12 16:22:45 +01:00
Ting-Yu Lin
db6acc7de4 style: Change URL value storage in StyleShapeSource.
This is due to Bug 1404243 Part 4.

MozReview-Commit-ID: CFRCdw2Dayy
2017-10-02 11:50:37 +08:00
Ting-Yu Lin
3547a59e28 style: Remove refcount for StyleBasicShape
This is due to Bug 1404243 Part 3.

MozReview-Commit-ID: DKymebmAYLX
2017-10-02 11:50:30 +08:00
Emilio Cobos Álvarez
2ac1327e4b
style: Make border-spacing serialization consistent, and move it to precomputed_type. 2017-09-17 21:33:17 +02: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
Emilio Cobos Álvarez
64ab73eabd
style: Properly use integers on grid properties, and derive ToComputedValue. 2017-09-11 11:29:27 +02:00
bors-servo
8129cf5563 Auto merge of #18206 - ferjm:bug1382369.grid.repeat.function, r=wafflespeanut
stylo: store specified value of grid layout repeat() function

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1382369](https://bugzilla.mozilla.org/show_bug.cgi?id=1382369)

<!-- 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/18206)
<!-- Reviewable:end -->
2017-09-11 02:32:38 -05:00
Boris Zbarsky
26b39241f9 Box gradients and rects in Image. r=xidorn
Gradients and rects are rare, and large.  Image is much smaller with them boxed.

This is part of of the fix for Gecko bug 1397614
<https://bugzilla.mozilla.org/show_bug.cgi?id=1397614>
2017-09-09 10:55:58 -04:00
Fernando Jiménez Moreno
8306946e7f stylo: store specified value of grid layout repeat() function 2017-09-06 12:53:07 +02:00
Anthony Ramine
542a9337a4 Use generics for the vertical-align property 2017-08-30 23:01:12 +02:00
Simon Sapin
35282042bc geckolib: Fix some warnings (treated as error) new in Rust Nigthly 2017-08-17 15:59:33 +02:00
Daisuke Akatsuka
c05baa2327 Implement clone_content method 2017-08-15 15:25:05 +09:00