Commit graph

257 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
85b7a60a69 style: Reduce code size of shorthand serialization
Differential Revision: https://phabricator.services.mozilla.com/D118835
2023-05-24 18:32:37 +02:00
Oriol Brufau
743f213c25 style: Move moz-control-character-visibility out of mako, and remove support for gecko_pref_controlled_initial_value
No behavior change, just cleanup. Actually seem this technically _adds_ some code even
though it's a cleanup, but that's mostly because of the wrapping of the
derive list.  The resulting code is simpler (more in-line with our usual
things, so I think it's an improvement).

Differential Revision: https://phabricator.services.mozilla.com/D111551
2023-05-16 23:17:16 +02:00
Oriol Brufau
b40f4b6fec style: Clean up text-justify, and make distribute a parse-time alias
Since it's simpler, as discussed in the CSSWG issue.

Differential Revision: https://phabricator.services.mozilla.com/D111346
2023-05-16 23:14:19 +02:00
Oriol Brufau
4d2ccaf445 style: Use a single system font definition rather than two
Follow the pattern we use for system colors.

Differential Revision: https://phabricator.services.mozilla.com/D108822
2023-05-16 13:16:53 +02:00
Emilio Cobos Álvarez
31e8e418ea Miscellaneous build / tidy fixes. 2021-02-26 17:53:55 +01:00
Emilio Cobos Álvarez
490db1e2bd style: Reduce the amount of code generated by UnparsedValues::substitute_variables.
This reduces the amount of assembly instructions generated by this
function from 18k+ to ~800.

This should make reasoning about its stack space usage sane, and should
fix the ASAN stack overflows, but also we should take this regardless,
because it's saner and makes reading it simpler.

I also think that the writing_mode shenanigans is fixing a bug (I think
before this, we'd pick the first physical value which mapped to any of
the properties, which is wrong), but I haven't bothered looking for a
test-case that fails before my patch. The relevant WPTs
(css/css-logical/animation*) still pass.

Differential Revision: https://phabricator.services.mozilla.com/D105342
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
20f5e14bf8 style: Remove the need for needs_context in the mako glue.
It's only used to disambiguate between the one-argument and the trait
version of Keyword::parse. Instead, just explicitly use the trait
version, so that we don't need to specify it.

Differential Revision: https://phabricator.services.mozilla.com/D104328
2021-02-26 16:44:05 +01:00
Simon Sapin
a0d9f97c8e Fix warnings introduced in newer Rust Nightly
This does not (yet) upgrade ./rust-toolchain

The warnings:

* dead_code "field is never read"
* redundant_semicolons "unnecessary trailing semicolon"
* non_fmt_panic "panic message is not a string literal, this is no longer accepted in Rust 2021"
* unstable_name_collisions "a method with this name may be added to the standard library in the future"
* legacy_derive_helpers "derive helper attribute is used before it is introduced" https://github.com/rust-lang/rust/issues/79202
2021-02-25 15:36:03 +01: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
Mike Hommey
7ec0e56848 style: Build mako-generated stylo rust sources deterministically.
Differential Revision: https://phabricator.services.mozilla.com/D70633
2020-04-16 16:35:07 +02:00
Mike Hommey
07c1b39637 style: Convert GenerateServoCSSPropList.py to py3.
Differential Revision: https://phabricator.services.mozilla.com/D70308
2020-04-16 16:35:07 +02:00
Cameron McCormack
53f7e45285 style: Add support for pref-controlled initial values.
Differential Revision: https://phabricator.services.mozilla.com/D67931
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
3991ab9999
style: Make direction use an enum class.
Differential Revision: https://phabricator.services.mozilla.com/D60857
2020-02-12 02:43:15 +01:00
Simon Sapin
5eb1472a33 2020: paint borders 2019-10-24 15:06:20 +02:00
Simon Sapin
ddb4e369dd Stylo: replace product={gecko,servo} with engine={gecko,servo-2013,servo-2020}
Renaming the variable helped make sure I looked at every use.
2019-07-29 17:37:03 +02:00
violet
c7c1fed95c
style: Implement overflow-block and overflow-inline properties
Differential Revision: https://phabricator.services.mozilla.com/D34738
2019-06-25 13:11:30 +02:00
Emilio Cobos Álvarez
4671ef5243 style: Fix servo build. 2019-05-29 16:14:34 +02:00
Emilio Cobos Álvarez
e3e826d4fb style: Appease tidy. 2019-05-29 16:14:31 +02:00
violet
d552969ca1 style: Support AllowQuirks::Always option in helpers.mako.rs
Differential Revision: https://phabricator.services.mozilla.com/D29936
2019-05-29 16:14:21 +02:00
Emilio Cobos Álvarez
5f6c8d9060 style: Add bindings for box shadows, and remove nsCSSShadowArray and friends.
Differential Revision: https://phabricator.services.mozilla.com/D30547
2019-05-29 16:14:11 +02:00
Emilio Cobos Álvarez
2bc4c42d45 style: Use an ArcSlice as the computed value representation of inherited list properties.
This adds a bit of complexity, which I think will pay off in the end. Removals
incoming.

Differential Revision: https://phabricator.services.mozilla.com/D30544
2019-05-29 16:14:09 +02:00
Emilio Cobos Álvarez
ab8776a144 style: Use OwnedSlice in the specified and computed values of most vector properties.
This is just a refactor in the right direction. Eventual goal is:

 * All inherited properties use ArcSlice<>.
 * All reset properties use OwnedSlice<> (or ThinVec<>).

No conversion happens at all, so we can remove all that glue, and also
compute_iter and co.

Of course there's work to do, but this is a step towards that.

Differential Revision: https://phabricator.services.mozilla.com/D30127
2019-05-29 16:14:07 +02:00
Emilio Cobos Álvarez
0a84073767 style: Use rust lengths for row-gap / column-gap.
Differential Revision: https://phabricator.services.mozilla.com/D26915
2019-04-12 12:20:11 +02:00
Emilio Cobos Álvarez
a47dcb5707 style: Derive ToResolvedValue.
Differential Revision: https://phabricator.services.mozilla.com/D26783
2019-04-12 12:20:09 +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
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
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
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
45a416b996 style: Cleanup a few shorthand properties.
Differential Revision: https://phabricator.services.mozilla.com/D17082
2019-01-29 02:39:19 +01:00
Emilio Cobos Álvarez
289d9b033c style: Make tidy happy. 2019-01-20 17:50:18 +01:00
Mats Palmgren
beb4ad91af style: Add plumbing for handling physical/logical corner values.
Bug: 1520684
Reviewed-by: emilio
2019-01-20 14:32:26 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Simon Sapin
e1fcffb336 Use 2018-style paths in code generated by Mako 2018-11-10 17:47:28 +01:00
Emilio Cobos Álvarez
5cafac5d10
style: Remove DeclaredValue.
I think it used to be the case that all PropertyDeclaration variants had a
DeclaredValueOwned<T> inside. But that's no longer the case, so this abstraction
seems less useful now.

Differential Revision: https://phabricator.services.mozilla.com/D5978
2018-09-18 11:39:31 +02:00
Emilio Cobos Álvarez
4cd0f492f4
style: Deindent the non-css-wide-keyword-related code from cascade_property.
There's no good reason we construct a DeclaredValue as an intermediate step.

Differential Revision: https://phabricator.services.mozilla.com/D5977
2018-09-18 11:39:25 +02:00
Emilio Cobos Álvarez
c155efe7a5
style: Remove DeclaredValue::WithVariables.
We never construct it.

Differential Revision: https://phabricator.services.mozilla.com/D5976
2018-09-18 11:39:17 +02:00
Emilio Cobos Álvarez
65953fb158
style: Rename offset-* logical properties to inset-*.
Bug: 1464782
Reviewed-by: xidorn
MozReview-Commit-ID: BW44sru99RF
2018-07-01 00:08:09 +02:00
Emilio Cobos Álvarez
2c0a19e517
style: Move some parsing-only attributes to use #[parse(..)] instead of #[css(..)].
I need to admit I'm ambivalent about this one :).

Bug: 1466609
Reviewed-by: xidorn
MozReview-Commit-ID: F1jlfnQKXwo
2018-06-12 12:15:10 -07:00
Emilio Cobos Álvarez
0f1b79327f
style: Minor indentation cleanup.
MozReview-Commit-ID: JmilaCX3rNy
2018-06-12 12:15:07 -07:00
Emilio Cobos Álvarez
5fc6b47d74
followup: Add a comment regarding why a type is generic.
Bug: 1462829
Rubber-stamped-by: xidorn
MozReview-Commit-ID: 5DE8W2n1NP
2018-05-28 15:38:04 +02:00
Emilio Cobos Álvarez
32c6d5b7c6
style: Refactor vector types.
This fixes clamping of mask-size and moves it out of mako while at it.

Bug: 1462829
Reviewed-by: hiro,xidorn
MozReview-Commit-ID: 9hiTe63odna
2018-05-28 15:37:28 +02:00
Xidorn Quan
4ab0e85ed5
style: Consistently use top-right-bottom-left order for physical sides.
Bug: 1454591
Reviewed-by: heycam
MozReview-Commit-ID: 6pLRSO8YNDI
2018-05-19 10:15:17 +02:00
Xidorn Quan
185e4ce61d
style: Allow shorthands to specify their own impl of SpecifiedValueInfo and manual impl it for font and border.
Bug: 1434130
Reviewed-by: emilio
MozReview-Commit-ID: 3B9OfkWU0Eq
2018-04-29 03:28:43 +02:00
Xidorn Quan
3b9c40dd14
style: Skip system font variant for ToCss in font subproperties.
System font keywords are not a valid value for those properties.

The newly-added #[css(skip)] would be reused by deriving algorithm of
SpecifiedValueInfo to skip them as well.

Bug: 1434130
Reviewed-by: emilio
MozReview-Commit-ID: EmnhkaA9RR5
2018-04-29 03:28:39 +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
Xidorn Quan
1599357cff Make nscssproperty a method of longhand/shorthand/alias class. 2018-04-11 15:55:11 +10:00
Anthony Ramine
90b23963b7 Introduce #[css(if_empty = "…", iterable)] 2018-03-07 13:07:13 +01:00
Anthony Ramine
85950a801f Move #[css(iterable)] on fields rather than variants 2018-03-06 11:08:19 +01:00
Anthony Ramine
247bcbbbd6 Derive ToCss for all vector longhands that cannot be empty
We don't need to check for emptiness and write `none` for them.
2018-03-05 12:02:31 +01:00