Commit graph

71 commits

Author SHA1 Message Date
Martin Robinson
2f4c47bfe7 Start the transition to workspace dependencies
This will ultimately make it simpler to update crate dependencies and
reduce duplicate when specifying requirements. Generally, this change
does not touch dependencies that are only used by a single crate. We
could consider moving them to workspace dependencies in the future.
2023-05-17 11:59:35 +02:00
bors-servo
fbe102fe6c
Auto merge of #29364 - delan:selectors-servo_arc, r=jdm
Release selectors 0.24.0 and servo_arc 0.2.0

This patch extends #29361, bumping selectors to 0.24.0 and servo_arc to 0.2.0.

We’ll need to publish them too, in order to close #29105.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #29105 (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because there are no functional changes
2023-02-20 16:53:35 +01:00
sagudev
9c2cc05a8e Upgrade remaining components to edition 2018 2023-02-18 09:42:37 +01:00
Delan Azabani
6ee10ca762 Release selectors 0.24.0 and servo_arc 0.2.0 2023-02-15 14:07:12 +08:00
bors-servo
73b066e1b5
Auto merge of #28967 - servo:jdm-patch-52, r=jdm
Add missing license files for servo_arc.

Fixes #28966.
2022-11-20 11:42:39 -05:00
Alex Touchet
9822075277 Use SPDX license format 2022-10-10 15:48:05 -07:00
Josh Matthews
b7ab8ccef2
Add MIT license to servo_arc. 2022-09-06 09:12:24 -04:00
Josh Matthews
a610adce87
Add apache license to servo_arc. 2022-09-06 09:11:48 -04:00
Teymour Aldridge
3e5cd8815d Fix some Clippy lints. 2022-08-04 00:13:36 +08:00
atouchet
77f7fa552d More Cargo.toml updates 2020-05-30 18:18:57 -07:00
Emilio Cobos Álvarez
cceb0bcb73
style: Simplify code for keeping alive shared memory until all sheets go away.
The existing code wasn't sound, as CSSOM objects also needed to go away before
the shared memory goes away (as they keep references to them).

This is sound assuming no presence of reference cycles introduced by CSSOM.

We may want to live with this and rely on chrome code not writing cycles like
this with UA stylesheet DOM objects.

We could explicitly drop all potentially-static objects... That seems pretty
error prone though.

Or we could also just leak the shared memory buffer, is there any reason why we
may not want to do that?

Differential Revision: https://phabricator.services.mozilla.com/D51870
2019-11-30 20:44:56 +01:00
Emilio Cobos Álvarez
62907afe1c
style: Properly refcount-log UniqueArcs created with new_uninitialized(). 2019-07-24 14:52:53 +02:00
Emilio Cobos Álvarez
32bf5ca1bb
Don't insta-free in UniqueArc::assume_init. 2019-07-24 12:29:14 +02:00
Simon Sapin
17ec774a49 Stylo: replace uses of mem::uninitialized with MaybeUninit
MozReview-Commit-ID: KGhYL6DJRaR
2019-07-16 08:03:54 +02:00
Simon Sapin
00b3fb49c4 Add UniqueArc::new_uninit, UniqueArc::assume_init
MozReview-Commit-ID: DoNcSsKpRn
2019-07-16 08:03:54 +02:00
Emilio Cobos Álvarez
55966412af
style: Rustfmt recent changes. 2019-07-08 12:56:47 +02:00
Emilio Cobos Álvarez
248b2ac829
style: Generate top-level function and constant declarations for the style crate.
This needs https://github.com/eqrion/cbindgen/pull/362, but I expect it to be
uncontroversial. I'll add a patch to this bug when it's merged to update it.

cbindgen historically didn't include these, but it turns out to be pretty useful
to generate constants for the style crate (since the binding crate is
`servo/ports/geckolib`).

An alternative is to get a completely different cbindgen-generated header for
these, but that seems a bit wasteful. This generates the constants with the
Style prefix (so we'll get `StyleMAX_GRID_LINE` for example), which is very
ugly. But we probably want to eventually stop using the Style prefix and use a
namespace instead, plus it's trivial to do `auto kMaxLine = StyleMAX_GRID_LINE`,
for example, so it's probably not a huge deal.

Another alternative would be to use associated consts, which _are_ generated by
cbindgen. Something like:

```
struct GridConstants([u8; 0]);
impl GridConstants {
    const MAX_GRID_LINE: i32 = 10000;
}
```

Which would yield something like:

```
static const int32 StyleGridConstants_MAX_GRID_LINE = 10000;
```

I'm not sure if you find it preferrable, but I'm also happy to change it in a
follow-up to use this.

We need to fix a few manual C++ function signature definitions to match the C++
declaration.

Differential Revision: https://phabricator.services.mozilla.com/D35197
2019-07-08 12:43:19 +02:00
Emilio Cobos Álvarez
665db79274 style: Rustfmt recent changes. 2019-06-04 01:03:59 -04:00
Emilio Cobos Álvarez
f623a6c045 style: Use a RwLock'd HashMap instead of a lock-free linked list for rule node children.
I need to profile this a bit more, but talos was pretty happy about this, and it
solves the known performance issues here such as the test-case from bug 1483963
for example. This also gets rid of a bunch of unsafe code which is nice.

This still keeps the same GC scheme, removing the key from the hashmap when
needed. I kept those as release assertions, but should probably be turned into
debug-only assertions.

Differential Revision: https://phabricator.services.mozilla.com/D6801
2019-06-04 01:03:55 -04:00
Emilio Cobos Álvarez
3652a0f1e1 style: Rejigger a bit rust features so that rusttests still link.
We cannot compile with just feature(gecko + debug_assertions), since that's how
debug rusttests get compiled and they don't have the refcount logging stuff.

We were getting away with it for the pre-existing usage of the style crate,
because it wasn't used during any test and presumably the linker didn't
complain. But servo_arc is definitely used in tests.

Differential Revision: https://phabricator.services.mozilla.com/D32691
2019-06-04 01:03:54 -04:00
Emilio Cobos Álvarez
9a9a4e12d5 style: Add refcount logging to servo_arc.
Differential Revision: https://phabricator.services.mozilla.com/D32173
2019-06-04 01:03:53 -04: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
Emilio Cobos Álvarez
5e4fdf647d style: Implement ArcSlice::default().
Share a singleton to avoid allocating for empty lists.

Differential Revision: https://phabricator.services.mozilla.com/D30543
2019-05-29 16:14:08 +02:00
Emilio Cobos Álvarez
db2f6aa8ca style: Rustfmt + build fix. 2019-05-10 12:43:06 +02:00
Emilio Cobos Álvarez
f429c28f23 style: Add bindings for ArcSlice and ThinArc, and use them to reduce copies of SVG path data.
As I said over bug 1549593, the eventual goal is to use ArcSlice in all
inherited properties. But this seemed like a good first candidate that doesn't
require me to move around a lot more code, since we were already using cbindgen
for the path commands.

Differential Revision: https://phabricator.services.mozilla.com/D30134
2019-05-10 12:43:05 +02:00
Emilio Cobos Álvarez
0d5c4481b8 style: Introduce ArcSlice, a small wrapper over ThinArc but without an explicit header.
We could make the header PhantomData or something, but then we wouldn't be able
to bind to C++, since C++ doesn't have ZSTs. So add a canary instead to add a
runtime check of stuff being sane.

Differential Revision: https://phabricator.services.mozilla.com/D30133
2019-05-10 12:43:04 +02:00
Emilio Cobos Álvarez
81e706469d style: Fix an assertion that doesn't account for alignment padding.
I'm hitting this when trying to add bindings for box shadows, which are 32-bit
aligned.

Differential Revision: https://phabricator.services.mozilla.com/D30353
2019-05-10 12:42:59 +02:00
Emilio Cobos Álvarez
99b97737fe style: Don't panic when creating empty ThinArcs.
The change from [T; 1] to [T; 0] shouldn't change behavior since they have the
right alignment and we never poke at that particular array, but feels more
correct to avoid creating types that point to uninitialized data or outside of
their allocation, now that we allow empty slices.

Differential Revision: https://phabricator.services.mozilla.com/D30352
2019-05-10 12:42:58 +02:00
Emilio Cobos Álvarez
29cecf65b8 style: Use PhantomData<T> in servo_arc.
See https://github.com/rust-lang/rust/pull/60594#issuecomment-489966933

Differential Revision: https://phabricator.services.mozilla.com/D30169
2019-05-10 12:42:55 +02:00
Emilio Cobos Álvarez
1fba297bbc style: ThinArc should use NonNull.
If only for parallelism with Arc<>.

Differential Revision: https://phabricator.services.mozilla.com/D30131
2019-05-10 12:42:53 +02:00
Cameron McCormack
f889b303da style: Add support for static references to servo_arc::Arc. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D17186
2019-04-12 12:19:43 +02: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
Emilio Cobos Álvarez
4c97f68f3e
Fix tidy issues. 2018-09-18 11:46:01 +02:00
Manish Goregaokar
84ca681a78
servo_arc cleanups for publishing.
Differential Revision: https://phabricator.services.mozilla.com/D6034
2018-09-18 11:39:54 +02:00
Bobby Holley
89880727ec
style: Use an acquire load for is_unique in servo_arc.
Fixes #21186

Bug: 1476445
Reviewed-by: Manishearth
Differential Revision: https://phabricator.services.mozilla.com/D2205
2018-07-24 03:27:08 +02:00
Emilio Cobos Álvarez
292f899631
style: Fix tidy issues and Servo build. 2018-04-29 05:09:43 +02:00
Bobby Holley
cbbefebdba
servo_arc: ArcUnion.
Bug: 1455784
Reviewed-by: Manishearth
MozReview-Commit-ID: Jxp2A7cj6CV
2018-04-29 03:28:31 +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
Matt Brubeck
568038ca2b Fix license metadata for servo_arc crate
The header in lib.rs states that this library is MIT / Apache-2.0, since
it is forked from the Rust standard library.
2018-02-21 16:35:18 -08:00
janczer
661d234c3c Change debug assertions to specific ones 2018-02-07 09:21:24 +01:00
CYBAI
6e4e318b24 Use specific negative assertion for ServoArc 2018-01-26 02:24:06 +08:00
CYBAI
f81ba5e9dd Use specific assertion for ServoArc 2018-01-26 01:18:59 +08:00
Simon Sapin
4be3096040 Add some FIXME comments about using ptr::NonNull 2018-01-22 17:41:26 +01:00
Simon Sapin
b0003f77e4 Prepare servo_arc for publication on crates.io 2018-01-12 15:10:44 +01:00
Emilio Cobos Álvarez
a1521d9d4d
servo_arc: Add some #[inline] and repr(C) annotations.
inline is probably unnecessary, but anyway... We rely on those being repr(C), so
they rather have some.
2017-12-01 14:34:38 +01:00
Nicholas Nethercote
4506f0d30c Replace all uses of the heapsize crate with malloc_size_of.
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`.
`malloc_size_of` is better -- it handles various cases that `heapsize` does not
-- so this patch changes Servo to use `malloc_size_of`.

This patch makes the following changes to the `malloc_size_of` crate.

- Adds `MallocSizeOf` trait implementations for numerous types, some built-in
  (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`).

- Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't
  support that operation.

- For `HashSet`/`HashMap`, falls back to a computed estimate when
  `enclosing_size_of_op` isn't available.

- Adds an extern "C" `malloc_size_of` function that does the actual heap
  measurement; this is based on the same functions from the `heapsize` crate.

This patch makes the following changes elsewhere.

- Converts all the uses of `heapsize` to instead use `malloc_size_of`.

- Disables the "heapsize"/"heap_size" feature for the external crates that
  provide it.

- Removes the `HeapSizeOf` implementation from `hashglobe`.

- Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of`
  doesn't derive those types, unlike `heapsize`.
2017-10-18 22:20:37 +11: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
Cameron McCormack
9c738711bc servo_arc: Make Arc do a pointer equality check in eq and ne first. 2017-10-11 09:24:03 +08:00
Emilio Cobos Álvarez
cb31e782aa
style: Share user agent cascade data across documents.
MozReview-Commit-ID: KcyuTHD0bt9
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-09-15 09:26:23 +02:00