Commit Graph

299 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
45c33fd498 Bug 1281158 - Improve interaction of ThinVec in the style system. r=dshin
This is the logical continuation of bug 1121792. This improves on the
existing support by totally removing all the manual nsTArray bindings,
which have always been a bit clumsy.

This is a prerequisite for bug 1281158 because I want to use ThinVec to
avoid a few extra heap allocations in the computed values of the Content
property.

Differential Revision: https://phabricator.services.mozilla.com/D209689
2024-05-08 16:06:46 +00:00
Emilio Cobos Álvarez
2eb976c4ac Bug 1874050 - Share more memory in custom property storage. r=dshin
This implements a similar optimization as WebKit's, see the bug comment.
This should be specially useful for sites with lots of custom
properties.

This is a high-confidence win on this speedometer subtest:

 * 1.9x faster in style updates.
 * 4.2x faster in layout object destruction (we no longer free the huge
   custom properties map).
 * Also speeds up paint and layout a bit, probably from less memory
   churn.

Differential Revision: https://phabricator.services.mozilla.com/D198308
2024-01-12 18:01:17 +00:00
Markus Stange
e2e8d19ab3 Bug 1839081 - Inline eq_atom. r=emilio
In a profile of querySelectorAll with a class selector, I noticed a
non-inlined call to `eq_atom` from `style::gecko::snapshot_helpers::has_class_or_part`.

This was in a local build on arm64 macOS with `--enable-release` but without PGO.

Before: https://share.firefox.dev/3pduJ2j
After: https://share.firefox.dev/3Nhv0JH

Differential Revision: https://phabricator.services.mozilla.com/D181345
2023-06-19 21:44:16 +00:00
Zach Hoffman
e9212ca619 Bug 1833538 - [css-properties-values-api] Parsing and serialization for @property syntax descriptor r=emilio
Based off of @emilio's syntax parser at
<https://github.com/emilio/css-typed-om-syntax>.

Co-authored-by: Emilio Cobos Álvarez <emilio@crisal.io>

Differential Revision: https://phabricator.services.mozilla.com/D178268
2023-05-22 05:14:13 +00:00
Emilio Cobos Álvarez
2cf0b4f65e Bug 1833229 - Move a bit declaration_block and cascade modules. r=boris
So that they aren't imported via #[path]. This allows cargo to see them
even before building.

Differential Revision: https://phabricator.services.mozilla.com/D178105
2023-05-15 20:57:59 +00:00
Tiaan Louw
c5ec3dca48 Bug 1128204 - Implement color() function from CSS specification r=emilio,supply-chain-reviewers
Colors can now be defined in different color spaces with the color()
function.

https://w3c.github.io/csswg-drafts/css-color-4/#predefined

Differential Revision: https://phabricator.services.mozilla.com/D164866
2023-01-27 12:44:18 +00:00
Ting-Yu Lin
a6d1bf0cc4 Bug 1792615 - Run "cargo +nightly fmt" for style components in servo. r=emilio
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
2022-09-28 07:10:52 +00:00
AW255
fd0dfc615f Bug 1573830 - 0% values are not skipped when parsing CSS transform. r=emilio
Adds trait ZeroNoPercent to check for values that are 0 (such as 0px) but not 0%

Updated test css/css-transforms/animation/translate-interpolation.html and removed unnecessary formatting changes

Differential Revision: https://phabricator.services.mozilla.com/D154930
2022-08-26 11:11:30 +00:00
Emilio Cobos Álvarez
1c58e2a928 Bug 1773070 - Unify Gecko and Servo EventState/ElementState bits. r=smaug
Add a dom/base/rust crate called just "dom" where we can share these.

Most of the changes are automatic:

  s/mozilla::EventStates/mozilla::dom::ElementState/
  s/EventStates/ElementState/
  s/NS_EVENT_STATE_/ElementState::/
  s/NS_DOCUMENT_STATE_/DocumentState::/

And so on. This requires a new cbindgen version to avoid ugly casts for
large shifts.

Differential Revision: https://phabricator.services.mozilla.com/D148537
2022-06-07 23:09:52 +00:00
Emilio Cobos Álvarez
7115380b63 Bug 1769612 - More container queries plumbing. r=boris
Provide container information in computed::Context and use it to resolve
the container queries.

This still fails a lot of tests because we are not ensuring that layout
is up-to-date when we style the container descendants, but that's
expected.

Differential Revision: https://phabricator.services.mozilla.com/D146478
2022-05-20 09:59:39 +00:00
Marian-Vasile Laza
351f42f99b Backed out changeset 99ab9844b58a (bug 1769612) for causing web-platform failures on container-size-invalidation-after-load.html. 2022-05-20 05:20:30 +03:00
Emilio Cobos Álvarez
b9430f4967 Bug 1769612 - More container queries plumbing. r=boris
Provide container information in computed::Context and use it to resolve
the container queries.

This still fails a lot of tests because we are not ensuring that layout
is up-to-date when we style the container descendants, but that's
expected.

Differential Revision: https://phabricator.services.mozilla.com/D146478
2022-05-20 00:49:44 +00:00
Emilio Cobos Álvarez
a04fc5a9a0 Bug 1768905 - Lint and 32-bit build fix.
MANUAL PUSH: Bustage fix CLOSED TREE
2022-05-11 21:43:39 +02:00
Emilio Cobos Álvarez
3c6af3a480 Bug 1768905 - Convert specified value tests to compile-time tests. r=dshin
These were written at a time where std::mem::size_of wasn't a `const fn` in
Rust.

Now that it is, we can make these tests live in the style crate, and the build
not to compile if they fail.

Differential Revision: https://phabricator.services.mozilla.com/D146103
2022-05-11 19:02:57 +00:00
David Shin
fb0628cc6a Bug 1764126 - Part 1: Implement piecewise linear function. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D145256
2022-05-06 11:49:53 +00:00
Emilio Cobos Álvarez
8f207de2e8 Bug 1765999 - Move some of the media query code to a more generic queries module. r=hiro
No behavior change, just moving and renaming files.

The code in the "queries" module will be shared between @media and
@container.

@media has some other code that container queries doesn't need like
MediaList / MediaType / etc. That remains in the media_queries module.

Differential Revision: https://phabricator.services.mozilla.com/D144435
2022-04-24 21:48:02 +00:00
Emilio Cobos Álvarez
62a5271ff6 Bug 1747037 - Shrink maps if needed after stylist rebuilds. r=bholley
Hashbrown grows a lot sometimes making us waste a lot of memory. Shrink
some of these maps after CascadeData rebuild / stylesheet collection
invalidation.

Differential Revision: https://phabricator.services.mozilla.com/D134716
2021-12-28 17:19:31 +00:00
Emilio Cobos Álvarez
4eb1027ebf Bug 1744102 - Remove servo/components/{hashglobe,fallible} in favor of try_reserve. r=xidorn
Differential Revision: https://phabricator.services.mozilla.com/D134194
2021-12-18 09:54:24 +00:00
Nazım Can Altınova
7acee11994 Bug 1652560 - Remove the old profiler label frames code in the servo codebase and replace it with the new API r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D120795
2021-07-30 21:49:22 +00:00
Emilio Cobos Álvarez
e8ee779a63 Bug 1695251 - Cherry-pick various servo changes.
All formatting and not-part-of-the-gecko-build changes.

Differential Revision: https://phabricator.services.mozilla.com/D106634
2021-02-26 17:00:55 +00:00
Emilio Cobos Álvarez
69199d50b9 Bug 1678881 - Avoid some allocations in selector serialization. r=xidorn
The allocations in display_to_css_identifier show up in the profiles of
bug 1675628.

Differential Revision: https://phabricator.services.mozilla.com/D97856
2020-11-22 01:02:22 +00:00
Emilio Cobos Álvarez
0d6306d00d Bug 1646811 - Remove some unused extern crate declarations now that style is in rust 2018.
This avoids some warnings.

Depends on D80247

Differential Revision: https://phabricator.services.mozilla.com/D80248
2020-06-18 18:14:24 +00:00
Emilio Cobos Álvarez
8d384d9cb8 Bug 1646811 - servo: Remove the dependency on font-kit from style.
No good reason to have this IMO, and helps remove some #[cfg] blocks.

Depends on D80246

Differential Revision: https://phabricator.services.mozilla.com/D80247
2020-06-18 18:14:21 +00:00
Utsav Oza
362c198a29 Bug 1646811 - servo: Enable textAlign, textBaseline and direction attributes for canvas.
Depends on D80238

Differential Revision: https://phabricator.services.mozilla.com/D80239
2020-06-18 18:12:56 +00:00
Simon Sapin
738eb8f46b Bug 1633410 - Back out bug 1631721.
Rebased and squashed.

Differential Revision: https://phabricator.services.mozilla.com/D78174
2020-06-18 15:25:33 +00:00
Dorel Luca
0e71203f06 Backed out changeset bde27b38c9c5 (bug 1643201) for causing Valgrind failures and build bustages 2020-06-04 05:17:11 +03:00
Emilio Cobos Álvarez
54a9e01014 Bug 1643201 - Cherry-pick servo changes to use the matches macro from the standard library.
Depends on D78201

Differential Revision: https://phabricator.services.mozilla.com/D78202
2020-06-04 00:35:22 +00:00
Martin Robinson
8bf2322ba1 Bug 1643201 - servo: Start having animations conform to the HTML spec.
This is a small step toward fixing #19242. The main idea is that the
clock for animations should advance as the event loop ticks. We
accomplish this by moving the clock from layout and naming it the
"animation timeline" which is the spec language. This should fix
flakiness with animations and transitions tests where a reflow could
move animations forward while script was running.

This change also starts to break out transition and animation events
into their own data structure, because it's quite likely that the next
step in fixing #19242 is to no longer send these events through a
channel.

Depends on D78188

Differential Revision: https://phabricator.services.mozilla.com/D78189
2020-06-04 00:34:18 +00:00
Martin Robinson
0a86ef369c Bug 1643201 - servo: Add ElementAnimationState and PossibleElementAnimationState.
This refactor is preparation for implementing a specification
compliant transitions and animations processing model.

These data structures hold all the animation information about a single
node. Since adding, updating, and modifying animations for a single node
are all interdependent, it makes sense to start encapsulating animation
data and functionality into a single data structure. This also opens up
the possibility for easier concurrency in the future by more easily
allowing per-node mutexes.

Differential Revision: https://phabricator.services.mozilla.com/D78184
2020-06-04 00:34:02 +00:00
Boris Chiou
5d90d2861f Bug 1635939 - Let aspect-ratio (css-sizing-4) support 'auto | <ratio>'. r=emilio
In order to test its parsing and serialization, we expose it but protect
it behind a pref.

Besides, I would like to drop layout.css.aspect-ratio-number.enabled in
the next patch because the spec has been updated. It seems we don't have
to keep this pref and we should always use Number.

Differential Revision: https://phabricator.services.mozilla.com/D74955
2020-05-21 06:45:10 +00:00
Simon Sapin
9a6ce7d347 Bug 1631721 - Use hashbrown instead of hashglobe r=manishearth
Differential Revision: https://phabricator.services.mozilla.com/D71741
2020-04-23 00:19:51 +00:00
Emilio Cobos Álvarez
15055d662f Bug 1614394 - Remove now unused dependency from the style system.
Differential Revision: https://phabricator.services.mozilla.com/D62308
2020-02-10 17:32:35 +00:00
Emilio Cobos Álvarez
bdf0e6893c Bug 1614394 - Rustfmt recent changes.
Differential Revision: https://phabricator.services.mozilla.com/D62307
2020-02-10 17:32:27 +00:00
Emilio Cobos Álvarez
48eb20de60 Bug 1611912 - Add a style flag for the root element style. r=heycam
This is needed to make the root element not a containing block in presence of
filters or what not.

Differential Revision: https://phabricator.services.mozilla.com/D61167
2020-01-31 14:51:06 +00:00
Emilio Cobos Álvarez
aab1464a8a Bug 1605803 - Use cbindgen for content property. r=xidorn
This cleans up and also allows us to keep the distinction between content: none
and content: normal, which allows us to fix the computed style we return from
getComputedStyle().

Do this last bit from the resolved value instead of StyleAdjuster, because
otherwise we need to tweak every initial struct for ::before / ::after.

Differential Revision: https://phabricator.services.mozilla.com/D58276
2020-01-05 13:10:39 +00:00
Boris Chiou
2382837326 Bug 1429305 - Use serde to serialize LengthPercentage and StyleRayFunction. r=emilio
We need to pass these two types into the compositor, so we need a better
way to serialize these rust types. We use serde and bincode to
serialize/deserialize them, and use ByteBuf to pass the &[u8] data
through IPC. We define StyleVecU8 for FFI usage only.

Differential Revision: https://phabricator.services.mozilla.com/D50688
2019-10-31 21:35:05 +00:00
Emilio Cobos Álvarez
11632d1702 Bug 1574148 - Fix Servo build and unify display representation.
Differential Revision: https://phabricator.services.mozilla.com/D42130
2019-08-15 13:31:44 +00:00
Nicholas Nethercote
85e194318f Bug 1563555 - Use static_prefs::pref! in Stylo. r=emilio
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-07 22:58:55 +00:00
Cosmin Sabou
4a5cc732bb Backed out 2 changesets (bug 1563555) for causing marionette failures on test_profile_management.py.
Backed out changeset 2559f5ddf8e0 (bug 1563555)
Backed out changeset e3c86ffa168c (bug 1563555)
2019-08-07 12:09:13 +03:00
Nicholas Nethercote
89e2a446f9 Bug 1563555 - Use static_prefs::pref! in Stylo. r=emilio
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-07 04:17:08 +00:00
Emilio Cobos Álvarez
849ae38693 Bug 1550554 - Use ArcSlice for quotes. r=heycam
This saves the intermediate allocation.

Differential Revision: https://phabricator.services.mozilla.com/D30546
2019-05-16 23:04:31 +00:00
Ciure Andrei
0cdc899d9a Backed out 17 changesets (bug 1550554, bug 1549593, bug 1551991, bug 1529002) for failing multiple Android tests and Windows 2012 bustages CLOSED TREE
Backed out changeset 3bb3fafa62e2 (bug 1551991)
Backed out changeset e12a979de502 (bug 1551991)
Backed out changeset d81e4aa6bf0c (bug 1551991)
Backed out changeset c354e61f2a34 (bug 1551991)
Backed out changeset 37fd602bebc2 (bug 1551991)
Backed out changeset 6c1f00cc30ca (bug 1551991)
Backed out changeset 8a7a0329bdc3 (bug 1551991)
Backed out changeset 86159475ddd3 (bug 1551991)
Backed out changeset 35f91a9ea82a (bug 1529002)
Backed out changeset 6798155e71dc (bug 1529002)
Backed out changeset b90c2cf5b8c5 (bug 1550554)
Backed out changeset 882ab9868c95 (bug 1550554)
Backed out changeset b28a48e2ed21 (bug 1550554)
Backed out changeset 2c31fe18eefd (bug 1550554)
Backed out changeset 57f2362aa538 (bug 1550554)
Backed out changeset 45f171b26e95 (bug 1550554)
Backed out changeset 2e4b263c9410 (bug 1549593)
2019-05-16 13:17:10 +03:00
Emilio Cobos Álvarez
ac28947f0c Bug 1550554 - Use ArcSlice for quotes. r=heycam
This saves the intermediate allocation.

Differential Revision: https://phabricator.services.mozilla.com/D30546
2019-05-16 16:24:24 +02:00
Emilio Cobos Álvarez
b01a00c1e1 Bug 1549559 - Introduce ArcSlice, a small wrapper over ThinArc but without an explicit header. r=heycam
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-09 10:53:50 +00:00
Emilio Cobos Álvarez
8e122feb73 Bug 1549593 - Move OwnedSlice to style_traits. r=heycam
Differential Revision: https://phabricator.services.mozilla.com/D30126
2019-05-09 10:49:50 +00:00
Emilio Cobos Álvarez
39689c5d90 Bug 1548691 - Add an owned slice type which cbindgen can understand. r=heycam
Passing these by value won't be ok of course, but that's fine.

I plan to combine this with https://github.com/eqrion/cbindgen/pull/333 to
actually be able to share representation for ~all the things, this is just the
first bit.

Box<T>, Atom and Arc<T> will be much easier since cbindgen can understand them
without issues.

It's boxed slices the only ones I should need something like this. I could avoid
it if I rely on Rust's internal representation, which we can per [1], but then I
need to teach cbindgen all about slices, which is generally hard, I think.

[1]: https://github.com/rust-lang/unsafe-code-guidelines/blob/master/reference/src/layout/pointers.md

Differential Revision: https://phabricator.services.mozilla.com/D29768
2019-05-09 10:49:22 +00:00
Cameron McCormack
325131e833 Bug 1474793 - Part 10.8: Add derived ToShmem implementations. r=emilio
Depends on D17196

Differential Revision: https://phabricator.services.mozilla.com/D17197
2019-03-30 00:16:25 +00:00
Cameron McCormack
3b635a549f Bug 1474793 - Part 10.1: Add simple ToShmem implementations. r=emilio
Depends on D17189

Differential Revision: https://phabricator.services.mozilla.com/D17190
2019-03-30 00:16:11 +00:00
Cameron McCormack
91b23f0f08 Bug 1474793 - Part 9: Add support for deriving ToShmem. r=emilio
Depends on D17188

Differential Revision: https://phabricator.services.mozilla.com/D17189
2019-03-30 00:16:08 +00:00
Cameron McCormack
705612e9ff Bug 1474793 - Part 7: Add SharedMemoryBuilder type and ToShmem trait. r=emilio
Depends on D17186

Differential Revision: https://phabricator.services.mozilla.com/D17187
2019-03-30 00:15:59 +00:00