Commit graph

7437 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
94686df11b style: Use rust lengths for the SVG lengths.
As it turns out we need this to avoid losing precision both during painting and
during serialization.

This patch also changes to serialize `context-value` if it's the computed value.

I could keep the previous behavior, but it makes no sense to serialize the
initial value. We're the only ones to support this value anyway, and I couldn't
find a definition or spec for this.

Also update tests and expectations for:

 * New unexpected passes.
 * Always serializing the unit in getComputedStyle.
 * Calc and interpolation support.

Chrome also always serializes the unit in getComputedStyle, so I'm pretty sure
this is compatible with them. Chrome is inconsistent and keeps numbers in
specified style, but that's inconsistent with itself and with other quirky
lengths, so I updated the tests instead.

Differential Revision: https://phabricator.services.mozilla.com/D21819
2019-03-13 15:08:17 +01:00
Emilio Cobos Álvarez
f1b5d5c06a style: Cleanup and fix interpolation of SVG lengths.
Instead of storing them as LengthPercentage | Number, always store as
LengthPercentage, and use the unitless length quirk to parse numbers instead.

Further cleanups to use the rust representation can happen as a followup, which
will also get rid of the boolean argument (since we can poke at the rust length
itself). That's why I didn't bother to convert it to an enum class yet.

Differential Revision: https://phabricator.services.mozilla.com/D21804
2019-03-13 15:08:15 +01:00
Emilio Cobos Álvarez
9e0d38a64f style: Make word-break: break-word behave like word-break: normal; overflow-wrap: anywhere.
Differential Revision: https://phabricator.services.mozilla.com/D21398
2019-03-13 15:08:14 +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
4496411edc style: Fix computed value clamping.
Differential Revision: https://phabricator.services.mozilla.com/D21268
2019-03-13 15:08:13 +01:00
Hiroyuki Ikezoe
52db71c0bf style: Explicitly specify animation_value_type for scroll-padding.
Otherwise the Trait for clamping negative animation value isn't generated thus
negative animating results are exposed in computed values.

Differential Revision: https://phabricator.services.mozilla.com/D21153
2019-03-13 15:08:12 +01:00
Emilio Cobos Álvarez
197065f6bc style: Use rust lengths for border corners.
The test in https://github.com/web-platform-tests/wpt/pull/15423 hasn't been
synced over yet, but it passes with this patch of course.

Differential Revision: https://phabricator.services.mozilla.com/D20960
2019-03-13 15:08:12 +01:00
Emilio Cobos Álvarez
aad4dac5b4 style: Make the generic size not use euclid under the hood.
The euclid size is not really used for anything. Also rename it to Size2D to
avoid cbindgen conflicts with values::length::Size.

Differential Revision: https://phabricator.services.mozilla.com/D20959
2019-03-13 15:08:11 +01:00
Emilio Cobos Álvarez
ebeb7b228f style: Simplify border-radius serialization.
Differential Revision: https://phabricator.services.mozilla.com/D20958
2019-03-13 15:08:10 +01:00
Simon Sapin
4464354e2e Reformat 2019-02-26 08:18:33 +01:00
Emilio Cobos Álvarez
3a1539ccde style: Appease tidy. 2019-02-23 21:05:34 -08:00
Emilio Cobos Álvarez
f6b6465ec6 style: Remove unnecessary derive. 2019-02-23 21:05:33 -08: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
74d7d5bc42 style: Use Rust types for perspective and z-index.
Differential Revision: https://phabricator.services.mozilla.com/D20381
2019-02-23 21:05:17 -08:00
Asfiya
6428ed726d style: Convert NS_STYLE_FLEX_DIRECTION to an enum class in nsStyleConsts.h
Converted the #define variable NS_STYLE_FLEX_DIRECTION to an enum class in nsStyleConsts.h and made changes in other files that access it

Differential Revision: https://phabricator.services.mozilla.com/D20291
2019-02-23 21:05:07 -08:00
scharing
85718c3b5a style: Convert NS_STYLE_MASK_MODE_* to enum class.
Differential Revision: https://phabricator.services.mozilla.com/D20063
2019-02-23 21:05:00 -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
6118e4d993 style: Use Rust types for some misc properties.
-moz-tab-size, border-image-outset and border-image-slice.

This is not a particularly interesting patch, just removes some code. We can
remove way more code when a few related properties are also ported.

Differential Revision: https://phabricator.services.mozilla.com/D19825
2019-02-23 21:04:33 -08:00
Emilio Cobos Álvarez
eefd440656 style: Remove nsFont::featureValueLookup.
It's a global object, it doesn't have to be stored in nsFont. Pass it from the
caller like the user font set and co.

Depends on D20141

Differential Revision: https://phabricator.services.mozilla.com/D20142
2019-02-23 21:04:26 -08:00
Emilio Cobos Álvarez
dcfe30ff18 style: Remove a couple trivial dependencies on nsPresContext.
Differential Revision: https://phabricator.services.mozilla.com/D20141
2019-02-23 21:04:19 -08:00
Emilio Cobos Álvarez
3231714758 style: Include anon boxes in CSSPseudoElementType, to remove ComputedStyle::mPseudoTag.
This is more consistent with what the Rust bits of the style system do, and
removes a pointer from ComputedStyle which is always nice.

This also aligns the Rust bits with the C++ bits re. not treating xul pseudos as
anonymous boxes. See the comment in nsTreeStyleCache.cpp regarding those.

Can't wait for XUL trees to die.

Differential Revision: https://phabricator.services.mozilla.com/D19002
2019-02-23 21:04:03 -08:00
Hiroyuki Ikezoe
22e12a0f52 style: Implement scroll-snap-align parser and serializer.
https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-align

Differential Revision: https://phabricator.services.mozilla.com/D20205
2019-02-23 21:03:55 -08:00
Hiroyuki Ikezoe
7cbaaf6734 style: Implement scroll-padding parser and serializer.
Differential Revision: https://phabricator.services.mozilla.com/D20103
2019-02-23 21:03:47 -08:00
Hiroyuki Ikezoe
79a5e97c13 style: Implement scroll-margin parser and serializer.
The reason why we use  RelaxedAtomBool is that
ScrollSnapUtils::GetSnapPointForDestination() is called both from the main and
the compositor threads, and the function will have a branch depending on the
pref value.

Differential Revision: https://phabricator.services.mozilla.com/D20101
2019-02-23 21:03:29 -08:00
Jonathan Kingston
d6750de0c3 style: Add support for CSS prefers-color-scheme media feature.
Bug: 1494034
Reviewed-by: emilio
2019-02-23 21:03:07 -08:00
Brian Birtles
71d9fe5d60 style: Don't share styles when an element has animations applied to it.
We already avoid putting styles in the shared style cache for an element that
has animations[1] but if we are doing the initial style of two siblings where
the _second_ has animations applied, there is nothing to stop us from trying to
share with the first (un-animated) element. This patch adds a check to prevent
sharing in that case since sharing style between animated elements is unsound
for the reasons described in [1].

A number of tests including:

  testing/web-platform/tests/web-animations/animation-model/animation-types/visibility.html

will fail without this fix once we remove the style flush from
KeyframeEffect::SetKeyframes later in this patch series.

[1] https://searchfox.org/mozilla-central/rev/6e3cc153566f5f288ae768a2172385b8436d61dd/servo/components/style/sharing/mod.rs#597

Differential Revision: https://phabricator.services.mozilla.com/D18913
2019-02-23 21:02:53 -08:00
Emilio Cobos Álvarez
07cb325402 style: Use rust types for background-size.
Hopefully straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D19625
2019-02-23 21:02:46 -08:00
Emilio Cobos Álvarez
1e6338e1ee style: Use Rust types for Position.
This one should be much easier to review / much more pleasant to see :-)

Differential Revision: https://phabricator.services.mozilla.com/D19563
2019-02-23 21:02:36 -08:00
Emilio Cobos Álvarez
d4ad12bee4 style: Preserve calc() rounding behavior.
See the comment. I don't really this is ideal, I filed bug 1528114 to
investigate changing that.

Differential Revision: https://phabricator.services.mozilla.com/D19584
2019-02-23 21:02:27 -08:00
Emilio Cobos Álvarez
f7a59bf0ee style: Use Rust sizes for flex-basis, width, height, and their min/max properties.
Really sorry for the size of the patch :(

Only intentional behavior change is in the uses of HasLengthAndPercentage(),
where it's easier to do the right thing. The checks that used to check for
(IsCalcUnit() && CalcHasPercentage()) are wrong since bug 957915.

Differential Revision: https://phabricator.services.mozilla.com/D19553
2019-02-23 21:02:18 -08:00
Emilio Cobos Álvarez
c2819365f0 style: Rename MozLength to Size, and MaxLength to MaxSize.
MozLength is not a very descriptive name. If we're going to use it in both Gecko
and Servo we may as well name it something more accurate.

I would've chosen `ContentSize` per CSS2[1][2] if it wasn't a lie in presence
of box-sizing. I don't have better ideas than `Size`, given that.

[1]: https://drafts.csswg.org/css2/visudet.html#propdef-width
[2]: https://drafts.csswg.org/css2/box.html#content-width

Differential Revision: https://phabricator.services.mozilla.com/D19280
2019-02-12 02:28:00 +01:00
Emilio Cobos Álvarez
1cb235c81a style: Call things by their name. 2019-02-10 07:11:47 +01:00
Emilio Cobos Álvarez
a68bc29b96 style: Derive more length stuff, and shrink MaxLength / MozLength's repr(C) representation.
This patch:

 * Makes LengthPercentageOrAuto generic, and removes a bunch of code fo
   LengthPercentageOrNone, which was used only for servo and now can use the
   normal MaxLength (with a cfg() guard for the ExtremumLength variant).

 * Shrinks MaxLength / MozLength's repr(C) reperesentation by reducing enum
   nesting. The shrinking is in preparation for using them from C++ too, though
   that'd be a different bug.

 * Moves NonNegative usage to the proper places so that stuff for them can be
   derived.

I did this on top of bug 1523071 to prove both that it could be possible and
that stuff wasn't too messy. It got a bit messy, but just because of a bug I
had fixed in bindgen long time ago already, so this updates bindgen's patch
version to grab a fix instead of ugly workarounds :)

Differential Revision: https://phabricator.services.mozilla.com/D17762
2019-02-10 07:11:46 +01:00
Emilio Cobos Álvarez
8dad956513 style: Use Rust lengths for margin / padding / inset.
Also for the intersection observer root margin, since it was easier to fix it
up and clean it up than not doing it.

This is the first big step to get rid of nscoord. It duplicates a bit of logic
in nsLayoutUtils since for now max/min-width/height are still represented with
nsStyleCoord, but I think I prefer to land this incrementally.

I didn't add helpers for the physical accessors of the style rect sides that
nsStyleSides has (top/bottom/left/right) since I think we generally should
encourage the logical versions, but let me know if you want me to do that.

Differential Revision: https://phabricator.services.mozilla.com/D17739
2019-02-10 05:12:19 +01:00
Emilio Cobos Álvarez
13e12d23f3 style: Use the style system's LengthPercentage for shape-margin.
This also makes us pass a few WPTs because we stop losing precision when
serializing the computed value.

Differential Revision: https://phabricator.services.mozilla.com/D17738
2019-02-10 05:12:11 +01:00
Emilio Cobos Álvarez
15f503d000 style: Add bindings for LengthPercentage, and use it for text-indent.
Which is the only property that uses LengthPercentage alone.

Differential Revision: https://phabricator.services.mozilla.com/D17737
2019-02-10 05:12:00 +01:00
Emilio Cobos Álvarez
207ff730c2 style: Cleanup a bit after bug 1525371.
Differential Revision: https://phabricator.services.mozilla.com/D19001
2019-02-10 05:11:49 +01:00
Emilio Cobos Álvarez
258217a369 style: Generate combined transform just once.
Differential Revision: https://phabricator.services.mozilla.com/D18567
2019-02-10 05:11:43 +01:00
Emilio Cobos Álvarez
eef9e24e96 style: Make -moz-binding chrome / UA only.
But enable it in all tests because a lot of them rely on using it in the
style="" attribute for example, or in inline stylesheets, which will no longer
parse this (even in chrome documents), and we don't want to rewrite all the XUL
and XBL tests.

Differential Revision: https://phabricator.services.mozilla.com/D18027
2019-02-10 05:11:33 +01:00
Alan Jeffrey
386c0f80ed Implemented fullscreen top layer 2019-02-06 13:23:52 -06:00
Emilio Cobos Álvarez
9909816c76 style: sort extern crates and fix servo build. 2019-01-29 03:17:24 +01:00
Emilio Cobos Álvarez
4d24dd2847 style: Rustfmt recent changes. 2019-01-29 02:53:55 +01:00
Emilio Cobos Álvarez
76ea22d50c style: Simplify some conversion code used for mapped attributes.
These days for the types we share computed value representation we don't really
need any special code.

Differential Revision: https://phabricator.services.mozilla.com/D17763
2019-01-29 02:39:26 +01:00
Emilio Cobos Álvarez
45a416b996 style: Cleanup a few shorthand properties.
Differential Revision: https://phabricator.services.mozilla.com/D17082
2019-01-29 02:39:19 +01:00
Bobby Holley
af1bbd7b06 style: Derive more.
Differential Revision: https://phabricator.services.mozilla.com/D17029
2019-01-29 02:39:13 +01:00
Bobby Holley
137e735d9d style: Add a dependency on derive_more.
Differential Revision: https://phabricator.services.mozilla.com/D17028
2019-01-29 02:39:05 +01:00
Emilio Cobos Álvarez
624db3a0eb style: Remove layout.css.overflow.moz-scrollbars.enabled.
We've been shipping it for a few releases already, see bug 1481125.

Differential Revision: https://phabricator.services.mozilla.com/D17081
2019-01-29 02:38:58 +01:00
Emilio Cobos Álvarez
0488a3d3d3 style: Implement the inset shorthand.
Differential Revision: https://phabricator.services.mozilla.com/D16704
2019-01-29 02:38:46 +01:00
Emilio Cobos Álvarez
289d9b033c style: Make tidy happy. 2019-01-20 17:50:18 +01:00