Skip to content

Commit 30f8960

Browse files
delanLoirooriol
authored andcommitted
Commit our changes on top of upstream Stylo
This is a rebase of 35cd802, but with 6a39161 reverted. Signed-off-by: Oriol Brufau <[email protected]>
1 parent 218809d commit 30f8960

File tree

33 files changed

+1367
-115
lines changed

33 files changed

+1367
-115
lines changed

.github/workflows/main.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ jobs:
3434
env:
3535
RUST_BACKTRACE: 1
3636

37+
macos-debug:
38+
name: macOS (Debug)
39+
runs-on: macos-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
- name: Install Rust
43+
uses: dtolnay/rust-toolchain@stable
44+
- name: Run Tests
45+
run: cargo build --features servo
46+
env:
47+
RUST_BACKTRACE: 1
48+
49+
windows-debug:
50+
name: Windows (Debug)
51+
runs-on: windows-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
- name: Install Rust
55+
uses: dtolnay/rust-toolchain@stable
56+
- name: Run Tests
57+
run: cargo build --features servo
58+
env:
59+
RUST_BACKTRACE: 1
60+
3761
build-result:
3862
name: Result
3963
runs-on: ubuntu-latest

.github/workflows/sync-upstream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ jobs:
1919
key: upstream
2020
- run: |
2121
./sync.sh _filtered
22-
git fetch -f --progress ./_filtered master:upstream
22+
git fetch -f --progress ./_filtered main:upstream
2323
git push -fu --progress origin upstream

Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[workspace]
2+
resolver = "2"
3+
members = [
4+
"stylo_atoms",
5+
"stylo_dom",
6+
"malloc_size_of",
7+
"rustfmt.toml",
8+
"selectors",
9+
"servo_arc",
10+
"style",
11+
"style_derive",
12+
"stylo_config",
13+
"stylo_static_prefs",
14+
"style_traits",
15+
"to_shmem",
16+
"to_shmem_derive",
17+
]
18+
default-members = ["style"]

README.md

Lines changed: 79 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,107 @@
11
Stylo
22
=====
33

4-
This repo contains Servo’s downstream fork of [Stylo](https://searchfox.org/mozilla-central/source/servo).
4+
**High-Performance CSS Style Engine**
55

6-
The branches are as follows:
6+
[![Build Status](https://github.com/servo/stylo/actions/workflows/main.yml/badge.svg)](https://github.com/servo/stylo/actions)
7+
[![Crates.io](https://img.shields.io/crates/v/stylo.svg)](https://crates.io/crates/stylo)
8+
[![Docs](https://docs.rs/stylo/badge.svg)](https://docs.rs/stylo)
9+
![Crates.io License](https://img.shields.io/crates/l/stylo)
710

8-
- [`upstream`](https://github.com/servo/style/tree/upstream) has upstream mozilla-central filtered to the paths we care about ([style.paths](style.paths)), but is otherwise unmodified
9-
- [`main`](https://github.com/servo/style/tree/ci) has our downstream patches, plus the scripts and workflows for syncing with mozilla-central, to be rebased onto `upstream`
11+
Stylo is a high-performance, browser-grade CSS style engine written in Rust that powers [Servo](https://servo.org) and [Firefox](https://firefox.com). This repo contains Servo’s downstream version of Stylo. The upstream version lives in mozilla-central with the rest of the Gecko/Firefox codebase.
1012

11-
## Building Servo against your local Stylo
13+
Coordination of Stylo development happens:
1214

13-
Assuming your local `servo` and `stylo` directories are siblings, you can build `servo` against `stylo` by adding the following to `servo/Cargo.toml`:
15+
- Here in Github Issues
16+
- In the [#stylo](https://servo.zulipchat.com/#narrow/channel/417109-stylo) channel of the [Servo Zulip](https://servo.zulipchat.com/)
17+
- In the [#layout](https://chat.mozilla.org/#/room/#layout:mozilla.org) room of the Mozilla Matrix instance (matrix.mozilla.org)
1418

15-
```toml
16-
[patch."https://github.com/servo/stylo"]
17-
selectors = { path = "../stylo/selectors" }
18-
servo_arc = { path = "../stylo/servo_arc" }
19-
stylo_atoms = { path = "../stylo/stylo_atoms" }
20-
style = { path = "../stylo/style" }
21-
stylo_config = { path = "../stylo/stylo_config" }
22-
stylo_dom = { path = "../stylo/stylo_dom" }
23-
style_malloc_size_of = { path = "../stylo/malloc_size_of", package = "malloc_size_of" }
24-
style_traits = { path = "../stylo/style_traits" }
25-
```
19+
## High-Level Documentation
2620

27-
## Syncing `upstream` with mozilla-central
21+
- This [Mozilla Hacks article](https://hacks.mozilla.org/2017/08/inside-a-super-fast-css-engine-quantum-css-aka-stylo) contains a high-level overview of the Stylo architecture.
22+
- There is a [chapter](https://book.servo.org/architecture/style.html) in the Servo Book (although it is a little out of date).
2823

29-
Start by generating a filtered copy of mozilla-central. This will cache the raw mozilla-central in `_cache/upstream`, storing the result in `_filtered`:
24+
## Branches
3025

31-
```sh
32-
$ ./sync.sh _filtered
33-
```
26+
The branches are as follows:
3427

35-
If `_filtered` already exists, you will need to delete it and try again:
28+
- [**upstream**](https://github.com/servo/style/tree/upstream) has upstream [mozilla-central](https://searchfox.org/mozilla-central/source/servo) filtered to the paths we care about ([style.paths](style.paths)), but is otherwise unmodified.
29+
- [**main**](https://github.com/servo/style/tree/ci) adds our downstream patches, plus the scripts and workflows for syncing with mozilla-central on top of **upstream**.
3630

37-
```sh
38-
$ rm -Rf _filtered
39-
```
31+
> [!WARNING]
32+
> This repo syncs from upstream by creating a new branch and then rebasing our changes on top of it. This means that `git pull` will not work across syncs (you will need to use `git fetch`, `git reset` and `git rebase`).
4033
41-
Now overwrite our `upstream` with those commits and push:
34+
More information on the syncing process is available in [SYNCING.md](SYNCING.md)
4235

43-
```sh
44-
$ git fetch -f --progress ./_filtered master:upstream
45-
$ git push -fu --progress origin upstream
46-
```
36+
## Crates
4737

48-
## Rebasing `main` onto `upstream`
38+
A guide to the crates contained within this repo
4939

50-
Start by fetching `upstream` into your local repo:
40+
### Stylo Crates
5141

52-
```sh
53-
$ git fetch -f origin upstream:upstream
54-
```
42+
These crates are largely implementation details of Stylo, although you may need to use some of them directly if you use Stylo.
5543

56-
In general, the filtering process is deterministic, yielding the same commit hashes each time, so we can rebase normally:
44+
| Directory | Crate | Notes |
45+
| --- | --- | --- |
46+
| style | [![Crates.io](https://img.shields.io/crates/v/stylo.svg)](https://crates.io/crates/stylo) | The main Stylo crate containing the entire CSS engine |
47+
| style_traits | [![Crates.io](https://img.shields.io/crates/v/stylo_traits.svg)](https://crates.io/crates/stylo_traits) | Types and traits which allow other code to interoperate with Stylo without depending on the main crate directly. |
48+
| stylo_dom | [![Crates.io](https://img.shields.io/crates/v/stylo_dom.svg)](https://crates.io/crates/stylo_dom) | Similar to stylo_traits (but much smaller) |
49+
| stylo_atoms | [![Crates.io](https://img.shields.io/crates/v/stylo_atoms.svg)](https://crates.io/crates/stylo_atoms) | [Atoms](https://docs.rs/string_cache/latest/string_cache/struct.Atom.html) for CSS and HTML event related strings |
50+
| stylo_config | [![Crates.io](https://img.shields.io/crates/v/stylo_config.svg)](https://crates.io/crates/stylo_config) | Configuration for Stylo. Can be used to set runtime preferences (enabling/disabling properties, etc) |
51+
| stylo_static_prefs | [![Crates.io](https://img.shields.io/crates/v/stylo_static_prefs.svg)](https://crates.io/crates/stylo_static_prefs) | Static configuration for Stylo. Config be overridden by patching in a replacement crate. |
52+
| style_derive | [![Crates.io](https://img.shields.io/crates/v/stylo_derive.svg)](https://crates.io/crates/stylo_derive) | Internal derive macro for stylo crate |
5753

58-
```sh
59-
$ git rebase upstream
60-
```
54+
### Standalone Crates
6155

62-
But if the filtering config changes or Mozilla moves to GitHub, the commit hashes on `upstream` may change. In this case, we need to tell git where the old upstream ends and our own commits start (notice the `~`):
56+
These crates form part of Stylo but are also be useful standalone.
6357

64-
```sh
65-
$ git log --pretty=\%H --grep='Servo initial downstream commit'
66-
e62d7f0090941496e392e1dc91df103a38e3f488
58+
| Directory | Crate | Notes |
59+
| --- | --- | --- |
60+
| selectors | [![Crates.io](https://img.shields.io/crates/v/selectors.svg)](https://crates.io/crates/selectors) | CSS Selector matching |
61+
| servo_arc | [![Crates.io](https://img.shields.io/crates/v/servo_arc.svg)](https://crates.io/crates/servo_arc) | A variant on `std::Arc` |
6762

68-
$ git rebase --onto upstream e62d7f0090941496e392e1dc91df103a38e3f488~
69-
Successfully rebased and updated refs/heads/main.
70-
```
63+
You may also be interested in the `cssparser` crate which lives in the [servo/rust-cssparser](https://github.com/servo/rust-cssparser) repo.
7164

72-
`start-rebase.sh` takes care of this automatically, but you should still use `git rebase` for subsequent steps like `--continue` and `--abort`:
65+
### Support Crates
7366

74-
```sh
75-
$ ./start-rebase.sh upstream
76-
$ ./start-rebase.sh upstream -i # interactive
77-
$ git rebase --continue # not ./start-rebase.sh --continue
78-
$ git rebase --abort # not ./start-rebase.sh --abort
79-
```
67+
Low-level crates which could technically be used standalone but are unlikely to be generally useful in practice.
68+
69+
| Directory | Crate | Notes |
70+
| --- | --- | --- |
71+
| malloc_size_of | [![Crates.io](https://img.shields.io/crates/v/stylo_malloc_size_of.svg)](https://crates.io/crates/stylo_malloc_size_of) | Heap size measurement for Stylo values |
72+
| to_shmem | [![Crates.io](https://img.shields.io/crates/v/to_shmem.svg)](https://crates.io/crates/to_shmem) | Internal utility crate for sharing memory across processes. |
73+
| to_shmem_derive | [![Crates.io](https://img.shields.io/crates/v/to_shmem_derive.svg)](https://crates.io/crates/to_shmem_derive) | Internal derive macro for to_shmem crate |
8074

81-
Or if we aren’t ready to rebase onto the tip of upstream:
75+
## Building Servo Against a Local Copy of Stylo
76+
77+
Assuming your local `servo` and `stylo` directories are siblings, you can build `servo` against `stylo` by adding the following to `servo/Cargo.toml`:
8278

83-
```sh
84-
$ ./start-rebase.sh upstream~10 -i
79+
```toml
80+
[patch."https://github.com/servo/stylo"]
81+
selectors = { path = "../stylo/selectors" }
82+
servo_arc = { path = "../stylo/servo_arc" }
83+
stylo_atoms = { path = "../stylo/stylo_atoms" }
84+
stylo = { path = "../stylo/style" }
85+
stylo_config = { path = "../stylo/stylo_config" }
86+
stylo_dom = { path = "../stylo/stylo_dom" }
87+
stylo_malloc_size_of = { path = "../stylo/malloc_size_of" }
88+
stylo_traits = { path = "../stylo/style_traits" }
8589
```
90+
91+
## Releases
92+
93+
Releases are made every time this repository rebases its changes on top of the latest version of upstream Stylo. There are a lot of crates here. In order to publish them, they must be done in order. One order that works is:
94+
95+
- selectors
96+
- stylo_static_prefs
97+
- stylo_config
98+
- stylo_atoms
99+
- stylo_malloc_size_of
100+
- stylo_dom
101+
- stylo_derive
102+
- stylo_traits
103+
- stylo
104+
105+
## License
106+
107+
Stylo is licensed under MPL 2.0

SYNCING.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Syncing
2+
3+
This file documents the process of syncing this repository with the upstream copy of Stylo in mozilla-central.
4+
5+
## Syncing `upstream` with mozilla-central
6+
7+
Start by generating a filtered copy of mozilla-central. This will cache the raw mozilla-central in `_cache/upstream`, storing the result in `_filtered`:
8+
9+
```sh
10+
$ ./sync.sh _filtered
11+
```
12+
13+
If `_filtered` already exists, you will need to delete it and try again:
14+
15+
```sh
16+
$ rm -Rf _filtered
17+
```
18+
19+
Now overwrite our `upstream` with those commits and push:
20+
21+
```sh
22+
$ git fetch -f --progress ./_filtered main:upstream
23+
$ git push -fu --progress origin upstream
24+
```
25+
26+
## Rebasing `main` onto `upstream`
27+
28+
Start by fetching `upstream` into your local repo:
29+
30+
```sh
31+
$ git fetch -f origin upstream:upstream
32+
```
33+
34+
In general, the filtering process is deterministic, yielding the same commit hashes each time, so we can rebase normally:
35+
36+
```sh
37+
$ git rebase upstream
38+
```
39+
40+
But if the filtering config changes or Mozilla moves to GitHub, the commit hashes on `upstream` may change. In this case, we need to tell git where the old upstream ends and our own commits start (notice the `~`):
41+
42+
```sh
43+
$ git log --pretty=\%H --grep='Servo initial downstream commit'
44+
e62d7f0090941496e392e1dc91df103a38e3f488
45+
46+
$ git rebase --onto upstream e62d7f0090941496e392e1dc91df103a38e3f488~
47+
Successfully rebased and updated refs/heads/main.
48+
```
49+
50+
`start-rebase.sh` takes care of this automatically, but you should still use `git rebase` for subsequent steps like `--continue` and `--abort`:
51+
52+
```sh
53+
$ ./start-rebase.sh upstream
54+
$ ./start-rebase.sh upstream -i # interactive
55+
$ git rebase --continue # not ./start-rebase.sh --continue
56+
$ git rebase --abort # not ./start-rebase.sh --abort
57+
```
58+
59+
Or if we aren’t ready to rebase onto the tip of upstream:
60+
61+
```sh
62+
$ ./start-rebase.sh upstream~10 -i
63+
```

malloc_size_of/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "malloc_size_of"
3-
version = "0.0.1"
2+
name = "stylo_malloc_size_of"
3+
version = "0.6.0"
44
authors = ["The Servo Project Developers"]
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/servo/stylo"
@@ -15,12 +15,12 @@ servo = ["string_cache"]
1515

1616
[dependencies]
1717
app_units = "0.7"
18-
cssparser = "0.34"
18+
cssparser = "0.35"
1919
euclid = "0.22"
20-
selectors = { path = "../selectors" }
21-
servo_arc = { path = "../servo_arc" }
20+
selectors = { version = "0.31", path = "../selectors" }
21+
servo_arc = { version = "0.4", path = "../servo_arc" }
2222
smallbitvec = "2.3.0"
23-
smallvec = "1.0"
23+
smallvec = "1.13"
2424
string_cache = { version = "0.8", optional = true }
25-
thin-vec = { version = "0.2.1" }
25+
thin-vec = { version = "0.2.13" }
2626
void = "1.0.2"

selectors/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "selectors"
3-
version = "0.26.0"
3+
version = "0.31.0"
44
authors = ["The Servo Project Developers"]
55
documentation = "https://docs.rs/selectors/"
66
description = "CSS Selectors matching for Rust"
@@ -21,15 +21,15 @@ to_shmem = ["dep:to_shmem", "dep:to_shmem_derive"]
2121

2222
[dependencies]
2323
bitflags = "2"
24-
cssparser = "0.34"
24+
cssparser = "0.35"
2525
derive_more = { version = "2", features = ["add", "add_assign"] }
2626
fxhash = "0.2"
2727
log = "0.4"
2828
phf = "0.11"
2929
precomputed-hash = "0.1"
3030
servo_arc = { version = "0.4", path = "../servo_arc" }
3131
smallvec = "1.0"
32-
to_shmem = { version = "0.1", path = "../to_shmem", features = ["servo_arc"], optional = true }
32+
to_shmem = { version = "0.2", path = "../to_shmem", features = ["servo_arc"], optional = true }
3333
to_shmem_derive = { version = "0.1", path = "../to_shmem_derive", optional = true }
3434
new_debug_unreachable = "1"
3535

servo_arc/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
[package]
22
name = "servo_arc"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
authors = ["The Servo Project Developers"]
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/servo/stylo"
77
description = "A fork of std::sync::Arc with some extra functionality and without weak references"
88
edition = "2021"
9+
readme = "../README.md"
910

1011
[lib]
1112
name = "servo_arc"
1213
path = "lib.rs"
1314

1415
[features]
16+
default = ["track_alloc_size"]
1517
gecko_refcount_logging = []
1618
servo = ["serde", "track_alloc_size"]
1719
track_alloc_size = []

0 commit comments

Comments
 (0)