Commit graph

154 commits

Author SHA1 Message Date
Oriol Brufau
1beb9880a9 Further changes required by Servo 2023-11-04 08:17:09 +01:00
Jonathan Kew
6ea75b0646 style: Parse errors in individual @font-face src components should cause only the bad component to be dropped, not the entire descriptor
Differential Revision: https://phabricator.services.mozilla.com/D163810
2023-11-04 08:17:09 +01:00
Emilio Cobos Álvarez
efdf518acc style: Remove system font support for various font longhands
We don't use them[1], and these are generally not properties that
authors would be able to set via the font shorthand anyways.

Let's simplify the code. This fixes the font-variant bug and also
unblocks further clean-ups of these properties in the future.

[1]: https://searchfox.org/mozilla-central/rev/59f0bf3c13dd455d9f5415b89178de701ea6b850/widget/LookAndFeelTypes.ipdlh#12-18

Differential Revision: https://phabricator.services.mozilla.com/D160352
2023-11-03 08:59:49 +01:00
Ting-Yu Lin
3da52edffc style: Run "cargo +nightly fmt" for style components in servo
The directories changed:
* servo/components/selectors/
* servo/components/style/
* servo/components/style_derive/
* servo/ports/geckolib/

Per review request, disable rustfmt in `components_to_transform_3d_matrix()` to
preserve the format for a call to `Transform3D::new`.

My mozilla-central is at
https://hg.mozilla.org/mozilla-central/rev/d1ae84015c22f2034435b47194fdced878072035

My nightly rust is 1.66.0-nightly (8b705839c 2022-09-26).

Differential Revision: https://phabricator.services.mozilla.com/D158234
2023-11-03 08:59:49 +01:00
Jonathan Kew
3fa76ff2e8 style: Update font-tech feature-* keywords to features-*, as per editorial fix in the spec
Differential Revision: https://phabricator.services.mozilla.com/D155962
2023-11-03 08:59:49 +01:00
Jonathan Kew
2fb319ede2 style: Implement CSS @supports font-format(...) and font-tech(...) functions
These are gated by the same layout.css.font-tech.enabled pref as the
closely-related `tech()` function for the @font-face src descriptor;
once the spec questions are settled, we should enable them all together.

Differential Revision: https://phabricator.services.mozilla.com/D155359
2023-10-02 14:37:19 +00:00
Oriol Brufau
6f2861e466 Further changes required by Servo 2023-10-02 14:37:19 +00:00
Jonathan Kew
0cdf97c881 style: Put the @font-face src tech() function behind a pref, enabled only on Nightly for now
There are a couple of current issues/discussions that may lead to a change in the set of supported keywords, so we may want to hold back a little on actually shipping this.

- In https://github.com/w3c/IFT/pull/113, the WebFonts WG proposes several new incremental-* keywords (and maybe implies dropping the currently-defined incremental?)

- In https://github.com/w3c/csswg-drafts/issues/7633, I just proposed renaming the feature-* keywords to features-* (plural) for better readability; I'd like to see a decision on that before we ship this to release.

Differential Revision: https://phabricator.services.mozilla.com/D155458
2023-10-02 14:37:19 +00:00
Oriol Brufau
03e84754cc Further changes required by Servo 2023-10-02 14:37:19 +00:00
Jonathan Kew
fa8b5f17e3 style: Add support for the @font-face src descriptor's tech() function
WPT tests to be added in a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D154399
2023-10-02 14:37:19 +00:00
Jonathan Kew
52d1e07ee2 style: Use the style-system format hint directly in gfx, instead of mapping to a separate internal enum
Now that the style system has keywords for this, we don't need to define them in gfx
but can just use the enum directly. (No functional change, just code simplification.)

Depends on D154237

Differential Revision: https://phabricator.services.mozilla.com/D154238
2023-10-02 14:37:19 +00:00
Oriol Brufau
87bee1710c Further changes required by Servo 2023-10-02 14:37:19 +00:00
Jonathan Kew
31b2a54164 style: Accept keywords in addition to strings in the @font-face format() hint function
The CSS Fonts 4 spec requires this, and Safari (at least) has long supported it.

Depends on D154277

Differential Revision: https://phabricator.services.mozilla.com/D154237
2023-10-02 14:37:19 +00:00
Jonathan Kew
65e6e072ea style: Do not allow a list of strings in the @font-face src descriptor's format() function, only a single format string
This aligns with CSS Fonts 4 (rather than Fonts 3) and with behavior in other browsers;
I don't expect any significant breakage, given that specifying multiple format strings
was never supported in other engines AFAIK, and never served any useful purpose.

Depends on D154234

Differential Revision: https://phabricator.services.mozilla.com/D154235
2023-10-02 14:37:19 +00:00
Emilio Cobos Álvarez
dcafbde256 style: Move fixed-point font types to Rust
Now that cbindgen and rust support const generics, it seems more simple.

This centralizes all the relevant font constants etc in rust and avoids
conversions when going from rust to C++ and vice versa.

Differential Revision: https://phabricator.services.mozilla.com/D148847
2023-10-02 14:37:19 +00:00
Oriol Brufau
8a16ba74ec Further changes required by Servo 2023-05-16 22:58:48 +02:00
Oriol Brufau
4b973885a3 style: Add the size-adjust descriptor to the style system
Differential Revision: https://phabricator.services.mozilla.com/D110022
2023-05-16 22:58:04 +02:00
Oriol Brufau
7da6d525ac Further changes required by Servo 2023-05-16 13:04:55 +02:00
Oriol Brufau
1cd257d54f style: Add ascent-, descent- and line-gap-override descriptors to the style system
Differential Revision: https://phabricator.services.mozilla.com/D109287
2023-05-16 13:04:36 +02:00
Oriol Brufau
5ef832b778 style: Convert the font-stretch descriptor to use NonNegativePercentage
Depends on D109285

Differential Revision: https://phabricator.services.mozilla.com/D109286
2023-05-16 13:04:14 +02:00
Lewin Probst
976f5b76bc Updated cssparser dependency to 0.29.
Signed-off-by: Lewin Probst <info@emirror.de>
2021-11-18 16:16:46 +01:00
Emilio Cobos Álvarez
cd7619dbf6 style: Make @font-face and @counter-style serialization closer other browsers and style rules.
Style rules serialize on one line and so should @font-face blocks.

Part of https://github.com/w3c/csswg-drafts/issues/4828.

Differential Revision: https://phabricator.services.mozilla.com/D89302
2021-02-26 16:44:05 +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
Anthony Ramine
785a344e32 Update rand to 0.7 (fixes #24448) 2019-10-23 15:34:48 +02:00
Nicholas Nethercote
bb032c1ddc
style: Use static_prefs::pref!.
It's much nicer.

One nice thing about this is that the new code is subject to the existing
threadedness checking, which identified that several of these should be atomic
because they're accessed off the main thread.

Differential Revision: https://phabricator.services.mozilla.com/D40792
2019-08-15 17:00:37 +02:00
Nicholas Nethercote
323221051f
style: Change StaticPrefs from a class to a namespace.
This doesn't change the way C++ code uses static prefs. But it does slightly
change how Rust code uses static prefs, specifically the name generated by
bindgen is slightly different.

The commit also improves some comments.

Differential Revision: https://phabricator.services.mozilla.com/D35764
2019-07-08 12:42:58 +02:00
Emilio Cobos Álvarez
ccff9b294f style: Use cbindgen for URIs.
This doesn't clean up as much as a whole, but it's a step in the right
direction. In particular, it allows us to start using simple bindings for:

 * Filters
 * Shapes and images, almost. Need to:
   * Get rid of the complex -moz- gradient parsing (let
     layout.css.simple-moz-gradient.enabled get to release).
 * Counters, almost. Need to:
   * Share the Attr representation with Gecko, by not using Option<>.
     * Just another variant should be enough (ContentItem::{Attr,Prefixedattr},
       maybe).

Which in turn allows us to remove a whole lot of bindings in followups to this.

The setup changes a bit. This also removes the double pointer I complained about
while reviewing the shared UA sheet patches. The old setup is:

```
SpecifiedUrl
 * CssUrl
   * Arc<CssUrlData>
     * String
     * UrlExtraData
 * UrlValueSource
   * Arc<CssUrlData>
   * load id
   * resolved uri
   * CORS mode.
   * ...
```

The new one removes the double reference to the url data via URLValue, and looks
like:

```
SpecifiedUrl
 * CssUrl
   * Arc<CssUrlData>
     * String
     * UrlExtraData
     * CorsMode
     * LoadData
       * load id
       * resolved URI
```

The LoadData is the only mutable bit that C++ can change, and is not used from
Rust. Ideally, in the future, we could just use rust-url to resolve the URL
after parsing or something, and make it all immutable. Maybe.

I've verified that this approach still works with the UA sheet patches (via the
LoadDataSource::Lazy).

The reordering of mWillChange is to avoid nsStyleDisplay from going over the
size limit. We want to split it up anyway in bug 1552587, but mBinding gains a
tag member, which means that we were having a bit of extra padding.

One thing I want to explore is to see if we can abuse rustc's non-zero
optimizations to predict the layout from C++, but that's something to explore at
some other point in time and with a lot of care and help from Michael (who sits
next to me and works on rustc ;)).

Differential Revision: https://phabricator.services.mozilla.com/D31742
2019-06-04 01:03:50 -04: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
39df092bce style: fix some rust-nightly warnings about unused doc comments.
Differential Revision: https://phabricator.services.mozilla.com/D24287
2019-03-27 14:29:16 +01:00
Simon Sapin
389e69bafe Upgrade to rustc 1.35.0-nightly (4c27fb19b 2019-03-25) 2019-03-26 15:12:55 +01:00
Simon Sapin
be69f9c3e6 Rustfmt has changed its default style :/ 2018-12-28 13:17:47 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Emilio Cobos Álvarez
bd9c53c5da
style: Manually extinguish multi-line use statements. 2018-11-10 21:42:24 +01:00
Emilio Cobos Álvarez
212b3e1311
style: Revert try -> r#try change.
Since we're in an inconsistent state because mako files weren't updated, and
it's really really ugly.
2018-11-10 21:42:17 +01:00
Simon Sapin
b1822a39fa cargo fix --edition --features gecko 2018-11-10 17:47:28 +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
Pyfisch
cb07debcb6 Format remaining files 2018-11-06 22:30:31 +01:00
Cameron McCormack
5976956e1c
style: Handle reversed ranges in @font-face descriptors.
Differential Revision: https://phabricator.services.mozilla.com/D10327
2018-11-05 12:31:11 +01:00
Emilio Cobos Álvarez
f287691f2e
style: fix tidy issues and update test expectations. 2018-10-09 22:01:38 +02:00
Emilio Cobos Álvarez
d833754183
style: Remove nsCSSValue usage from font code.
Really sorry for the size of the patch.

Differential Revision: https://phabricator.services.mozilla.com/D7753
2018-10-09 19:45:45 +02:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Emilio Cobos Álvarez
3a0c3224b9
style: Move the error reporter into ParserContext.
Summary:
This should make it easier to report errors, and also reduce codesize.

The reason this was so generic is that error reporting was unconditionally
enabled and was super-hot, but now that's no longer the case after bug 1452143,
so we can afford the virtual call in the "error reporting enabled" case.

This opens the possibility of simplifying a lot the error setup as well, though
this patch doesn't do it.

Test Plan: No behavior change, so no new tests.

Reviewers: xidorn

Bug #: 1469957

Differential Revision: https://phabricator.services.mozilla.com/D1734

MozReview-Commit-ID: F3wTdhX9MB5
2018-06-23 20:36:23 +02:00
Boris Zbarsky
3816143a1d
style: Use Atomic<bool> for the staticpref version of layout.css.font-variations.enabled.
Atomic<bool> is implemented in terms of AtomicBase<uint32_t>, because that way
you don't need to depend on atomic 1-byte operations.  That means that the rust
bindgen sees it as a u32, not a bool.

It's a bit concerning that the rust code seems to be doing an unsynchronized
read here, but given this is a RelaxedAtomic, that's probably ok.

Bug: 1467134
Reviewed-by: emilio
2018-06-12 12:15:12 -07:00
Emilio Cobos Álvarez
1f5d90568d
style: Make tidy happy. 2018-04-28 10:26:08 +02:00
Emilio Cobos Álvarez
737501153b
style: Use a generic type in preparation to fix animation.
Apart from a bit more code reuse.

Bug: 1455358
Reviewed-by: xidorn
MozReview-Commit-ID: 2BNOK6v30lX
2018-04-28 10:26:05 +02:00
Emilio Cobos Álvarez
32d4da8a99
style: Update font-style to css-fonts-4.
Bug: 1455358
Reviewed-by: xidorn
MozReview-Commit-ID: 1Nq5DyCjaZe
2018-04-28 10:26:05 +02:00
Emilio Cobos Álvarez
f7636e6662
style: Update font-stretch to css-fonts-4.
These won't "just work", pending changes from bug 1436048 to use a floating
point representation for those.

Bug: 1454883
Reviewed-by: xidorn
MozReview-Commit-ID: Bi5iTdFreMA
2018-04-28 10:26:04 +02:00
Emilio Cobos Álvarez
48de556f8c
style: Fixups for css-fonts-4 font-weight. 2018-04-28 10:26:03 +02:00
Emilio Cobos Álvarez
bc1126ee8c
style: Update font-weight property and descriptor to css-fonts-4.
Bug: 1454596
Reviewed-by: xidorn
MozReview-Commit-ID: 27aS2UrgXjs
2018-04-28 10:25:59 +02:00