Commit graph

131 commits

Author SHA1 Message Date
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
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
Xidorn Quan
ac7467221a Use Servo data to back @font-face rule in Gecko. 2018-04-04 09:33:07 +10:00
Xidorn Quan
0332674909 Implement the correct ToCss for UrlSource. 2018-04-04 08:43:41 +10:00
Nicholas Nethercote
8705fb3783 Convert StylePrefs to StaticPrefs. 2018-04-03 11:41:03 +10:00
Anthony Ramine
ca45695db1 Introduce #[css(skip)] 2018-03-05 15:53:15 +01:00
Jonathan Kew
33ead015b1 style: Make 'font' shorthand reset the 'font-variation-settings' property.
As required by the spec: https://drafts.csswg.org/css-fonts-4/#font-prop

See https://bugzilla.mozilla.org/show_bug.cgi?id=1435983

Basically, make font-variation-settings work in the same way as font-feature-settings
already does.
2018-03-04 12:26:32 +00:00
Xidorn Quan
ea8a952d51 Remove initial values from font-face descriptors
They are not used anyway.
2018-02-14 17:35:57 +11:00
Xidorn Quan
6ffa888dd6 Integrate font-variation-settings descriptor with stylo 2018-02-14 11:15:58 +11:00
bors-servo
dcd13b857c
Auto merge of #19918 - emilio:font-stuff-is-a-mess, r=nox
style: Refactor font-feature-settings and font-variation-settings.

This fixes all known issues with serialization and parsing of these two
properties, and in particular calc handling and such:

  https://bugzilla.mozilla.org/show_bug.cgi?id=1434692
  https://bugzilla.mozilla.org/show_bug.cgi?id=1434724

Also does a fair amount of cleanup and all that, which was needed, this code
was a mess.

There are further cleanups that can be done, like renaming the
font-variation-settings animation stuff.

<!-- 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/19918)
<!-- Reviewable:end -->
2018-02-01 06:45:20 -06:00
Emilio Cobos Álvarez
3b34d734e6
style: Refactor font-feature-settings and font-variation-settings.
This fixes all known issues with serialization and parsing of these two
properties, and in particular calc handling and such:

  https://bugzilla.mozilla.org/show_bug.cgi?id=1434692
  https://bugzilla.mozilla.org/show_bug.cgi?id=1434724

Also does a fair amount of cleanup and all that, which was needed.
2018-02-01 12:54:45 +01:00
Anthony Ramine
3d99a4489c Don't use define_css_keyword_enum in style anymore 2018-02-01 12:43:48 +01:00
Anthony Ramine
cd8f96cc9e Change ToCss to take a CssWriter<W>
This more concrete wrapper type can write a prefix the very first time something
is written to it. This allows removing plenty of useless monomorphisations caused
by the former W/SequenceWriter<W> pair of types.
2018-01-23 10:41:42 +01:00
Bobby Holley
5526947500 Avoid the generic writer parameter for PropertyDeclaration serialization.
MozReview-Commit-ID: JR3IcL1NRHO
2018-01-22 14:58:05 -08:00
CYBAI
a470ebd501 style: Move font-family outside of mako 2017-11-26 00:36:00 +08:00
Matt Brubeck
efc3683cc7 Fix commonmark Markdown warnings in docs, part 1
Fixes warnings from rust-lang/rust#44229 when `--enable-commonmark` is
passed to rustdoc.

This is mostly a global find-and-replace for bare URIs on lines by
themselves in doc comments.
2017-10-17 11:24:57 -07:00
Simon Sapin
46ea99d54b CSS parsing error types: flatten nested enums somewhat 2017-10-10 13:28:30 +02:00
Simon Sapin
c64374bc58 Use the location in the error value when reporting a CSS error 2017-10-10 13:28:29 +02:00
Simon Sapin
c0f8f15f39 Update to cssparser 0.22 (source location in error types) 2017-10-10 13:28:17 +02:00
Simon Sapin
056e599562 Use the current parser location for CSS error
… rather than the start location of the current construct.
This likely places the error just *after* of the unexpected token
whereas before would be best, but that’s likely a much bigger change.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1378861
2017-10-10 13:27:01 +02:00
Corey Farwell
9cd4535364 Implement size_hint for more iterators.
```
implement size hint for
more iterators because why
not we like fast things
```
2017-09-13 20:29:27 -04:00
Xidorn Quan
2bca62045f Parse at-rule without block in two stages 2017-09-01 16:21:22 +10:00
bors-servo
d4ddec8d33 Auto merge of #18209 - jdm:devirtualize, r=mbrubeck
Devirtualize CSS error reporting.

This removes a trait object from the path of reporting a CSS error.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] There are tests for these changes

<!-- 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/18209)
<!-- Reviewable:end -->
2017-08-24 13:19:25 -05:00