Commit graph

7310 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
aa5ea337da style: Try to bring some more sanity into our font code.
It's not very easy to understand on its current state, and it causes subtle bugs
like bug 1533654.

It could be simpler if we centralized where the interactions between properties
are handled. This patch does this.

This patch also changes how MathML script sizes are tracked when scriptlevel
changes and they have relative fonts in between.

With this patch, any explicitly specified font-size is treated the same (being a
scriptlevel boundary), regardless of whether it's either an absolute size, a
relative size, or a wide keyword.

Relative lengths always resolve relative to the constrained size, which allows
us to avoid the double font-size computation, and not give up on sanity with
keyword font-sizes.

I think given no other browser supports scriptlevel it seems like the right
trade-off.

Differential Revision: https://phabricator.services.mozilla.com/D23070
2019-03-27 14:29:07 +01:00
Emilio Cobos Álvarez
77a75596bb style: Don't call PrefillDefaultForGeneric when inheriting font-family.
This is the low-risk fix for this issue, that we should get into 67.

What's going on here is that font-family is tracked via the font list, from the
POV of the style system the font list is generally just the
RefPtr<SharedFontList>, but in Gecko there's also mDefaultGenericId.

The way we end up with the right mDefaultGenericId is fishy at best, bogus at
worst. I left various fixmes over time related to a bunch of this code.

After my patch, we end up with a mDefaultGenericId of serif, rather than the
right one (none).

The parent font always has none because nsLayoutUtils::ComputeSystemFont always
sets it to none if the font is known.

Before my patch, PrefillDefaultForGeneric with aGenericId of none (from the
parent), which makes it the default generic id for the current language, serif
in this case.

Before my optimization, apply_declaration_ignoring_phase called
copy_font_family_from, which resets both the font list _and_ the default
generic.

This patch achieves the same effect by not having the first mutation in the
first place.

This code is still terribly fishy in any case, all the _skip_font_family stuff
is just ridiculous. I'll try to clean up a bit after this, but for 68.

Differential Revision: https://phabricator.services.mozilla.com/D23026
2019-03-27 14:29:07 +01:00
Emilio Cobos Álvarez
9f4643ac24 style: Avoid crashing when calling insertRule("@import ...") on a detached sheet.
This should unblock the fuzzers for now, though it's not the ideal solution.

It's the only reasonably easy solution to unblock them though, I think.

We should probably always keep track of the document a stylesheet was associated
with. We'll need that for constructible stylesheets anyway.

That requires some though on how to get the cycle-collection and such right,
though, and I wouldn't be able to write or land that ASAP.

Differential Revision: https://phabricator.services.mozilla.com/D23584
2019-03-27 14:29:06 +01:00
Emilio Cobos Álvarez
95ee1a5adf style: Use a single RestyleHint representation.
Differential Revision: https://phabricator.services.mozilla.com/D22828
2019-03-27 14:29:05 +01:00
Emilio Cobos Álvarez
8dbf9b1da9 Bug 1535084 - Cleanup contain property. r=dholbert
Now that cbindgen supports bitflags, this is trivial.

Differential Revision: https://phabricator.services.mozilla.com/D23371
2019-03-27 14:29:05 +01:00
Simon Sapin
389e69bafe Upgrade to rustc 1.35.0-nightly (4c27fb19b 2019-03-25) 2019-03-26 15:12:55 +01:00
Peter Hall
8bfd4dc1e2 #8539 Config preferences backend restructure 2019-03-20 15:01:26 +00:00
Emilio Cobos Álvarez
a65925cb85 style: Fix servo build. 2019-03-13 15:08:39 +01:00
Emilio Cobos Álvarez
5aeab7adb1 style: Reformat recent changes. 2019-03-13 15:08:38 +01:00
violet
9a8cee2800 style: Change stroke-miterlimit restriction from GreaterThanOrEqualToOneNumber to NonNegativeNumber. 2019-03-13 15:08:37 +01:00
Emilio Cobos Álvarez
4a1f390788 style: Optimize cascading of other wide keywords if possible.
The way the copy-on-write stuff works, and the way that we have to apply
properties from most specific to less specific guarantees that always that we're
going to inherit an inherited property, or reset a reset property, we have
already the right value on the style.

Revert relies on that, so there doesn't seem to be a reason to not use that fact
more often and skip useless work earlier.

Font-size is still special of course... I think I have a way to move the
specialness outside of the style, but piece by piece.

Differential Revision: https://phabricator.services.mozilla.com/D21882
2019-03-13 15:08:36 +01:00
Emilio Cobos Álvarez
6fd17ccb35 style: Implement CSS revert keyword.
The only fishy bit is the animation stuff. In particular, there are two places
where we just mint the revert behavior:

 * When serializing web-animations keyframes (the custom properties stuff in
   declaration_block.rs). That codepath is already not sound and I wanted to
   get rid of it in bug 1501530, but what do I know.

 * When getting an animation value from a property declaration. At that point
   we no longer have the CSS rules that apply to the element to compute the
   right revert value handy. It'd also use the wrong style anyway, I think,
   given the way StyleBuilder::for_animation works.

   We _could_ probably get them out of somewhere, but it seems like a whole lot
   of code reinventing the wheel which is probably not useful, and that Blink
   and WebKit just cannot implement either since they don't have a rule tree,
   so it just doesn't seem worth the churn.

The custom properties code looks a bit different in order to minimize hash
lookups in the common case. FWIW, `revert` for custom properties doesn't seem
very useful either, but oh well.

Differential Revision: https://phabricator.services.mozilla.com/D21877
2019-03-13 15:08:35 +01:00
Emilio Cobos Álvarez
80ed070639 style: fix a typo. 2019-03-13 15:08:35 +01:00
Emilio Cobos Álvarez
18a0c9b033 style: followup: Add a comment as requested on Phabricator. 2019-03-13 15:08:34 +01:00
Emilio Cobos Álvarez
14e6875ef9 style: Use more cbindgen features.
We can get back the fancy flag syntax as soon as we get C++17 inline variables,
which I sent an email to dev-platform@ about, with no reply.

Differential Revision: https://phabricator.services.mozilla.com/D22382
2019-03-13 15:08:33 +01:00
Emilio Cobos Álvarez
e0b3e5f691 style: Derive more stuff for clip rects.
I feel a bit weird for using LenghtPercentageOrAuto to implement LengthOrAuto,
but I don't think much other code will use it so it seemed a bit better to me.

Differential Revision: https://phabricator.services.mozilla.com/D21863
2019-03-13 15:08:32 +01:00
Emilio Cobos Álvarez
e723a5b7d6 style: Make the pres context optional in the style system.
Differential Revision: https://phabricator.services.mozilla.com/D21239
2019-03-13 15:08:32 +01:00
Emilio Cobos Álvarez
4e3e4c106a style: Refactor preference stylesheet prefs to not require a pres context.
We really only have two sets of prefs, one for chrome-like documents
(stuff in chrome docshells + chrome-origin images), and one for the rest.

Differential Revision: https://phabricator.services.mozilla.com/D20946
2019-03-13 15:08:31 +01:00
Daniel Holbert
33814a9afe style: Drop css parser support for 'contain:style'.
We're not sure we're going to ship support for this value, and it's been marked
as 'at-risk' in the spec, so let's stop pretending we support it in the parser.

Spec issue:
https://github.com/w3c/csswg-drafts/issues/3280

Differential Revision: https://phabricator.services.mozilla.com/D22203
2019-03-13 15:08:29 +01:00
Emilio Cobos Álvarez
b96981f88e style: Make word-spacing, letter-spacing, and line-height use Rust lengths.
This also adopts the resolution from [1] while at it, making letter-spacing
compute to a length, serializing 0 to normal rather than keeping normal in the
computed value, which matches every other engine.

This removes the SMIL tests for percentages from letter-spacing since
letter-spacing does in fact not support percentages, so they were passing just
by chance.

[1]: https://github.com/w3c/csswg-drafts/issues/1484

Differential Revision: https://phabricator.services.mozilla.com/D21850
2019-03-13 15:08:28 +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
1418ddc685 style: Use contextual_skip_if for background-size.
Also drive-by cleanup.

Differential Revision: https://phabricator.services.mozilla.com/D21861
2019-03-13 15:08:24 +01:00
Emilio Cobos Álvarez
93d3004c17 style: Use skip_if for translate serialization.
Trivial drive-by cleanup.

Differential Revision: https://phabricator.services.mozilla.com/D21860
2019-03-13 15:08:22 +01:00
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