Commit graph

48 commits

Author SHA1 Message Date
Ting-Yu Lin
a0617bff0d style: Run rustfmt on servo/components/style and servo/ports/geckolib
This patch is generated by running `cargo +nightly fmt` under
`servo/components/style/` and `servo/ports/geckolib` against mozilla-central
https://hg.mozilla.org/mozilla-central/rev/b193f2e7a6a5d1f042c957ea4acd5c89bf210512

My nightly version is: 1.58.0-nightly (c9c4b5d72 2021-11-17)

Manually remove the redundant braces in author_styles.rs to fix a warning.

Differential Revision: https://phabricator.services.mozilla.com/D131556
2023-06-09 10:22:19 +02:00
Emilio Cobos Álvarez
04282ff04c style: Allow matches() / querySelector() / etc on chrome docs to access chrome-only selectors. r=boris
Without this some tests fail with the previous patch because code like:

  https://searchfox.org/mozilla-central/rev/267682a8f45221bf0bfe999d4a0239706a43bc56/browser/base/content/browser-gestureSupport.js#651

starts throwing. Unfortunately I had missed that on my try run, because
the error message didn't include that exception (it seemed like an
intermittent browser-chrome failure instead).

We could expose a ChromeOnly API for this, but this seems better. This
fixes it trivially, and also removes the "no url data" situation from
the selector parser, which is nice.

Differential Revision: https://phabricator.services.mozilla.com/D130818
2023-06-09 10:22:18 +02:00
Oriol Brufau
060d74ba3b style: Share CascadeData instances across ShadowRoots
This should be both a memory and speed win for pages using a lot of
Shadow DOM.

In order to make the cache properly work we need to start keying media query
results on the actual StyleSheetContents, as that's what we share on Gecko, but
that should all be fine.

Differential Revision: https://phabricator.services.mozilla.com/D107266
2023-05-16 13:00:08 +02:00
Emilio Cobos Álvarez
80dae5bc59 Rustfmt. 2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
df7ea837d8 style: Allow resource:// stylesheets to use chrome-only rules.
We'll use it to use @-moz-document from plaintext.css.

Differential Revision: https://phabricator.services.mozilla.com/D101516
2021-02-26 16:44:05 +01: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
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +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
Emilio Cobos Álvarez
6d43bf78bc
style: Fix servo build. 2018-09-03 12:56:30 +02:00
Cameron McCormack
4ee3b56d54
style: Use an Atom to represent Direction values in pseudo-classes.
Differential Revision: https://phabricator.services.mozilla.com/D4730
2018-09-03 12:33:13 +02:00
Cameron McCormack
a41127152b
style: Measure heap allocations hanging off selector components.
Bug: 1475191
Reviewed-by: emilio
MozReview-Commit-ID: D7vZQ7v8owS
2018-07-16 19:43:15 +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
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
Emilio Cobos Álvarez
b6a2bff032
style: Move :-moz-locale-dir matching to rust. 2018-01-11 14:47:29 +01:00
Michael Wilson
1ebc1382ce moving :dir() param serialization FIXME 2017-11-21 21:47:41 -08:00
bors-servo
5905f8d3ea Auto merge of #19315 - emilio:chrome-rules-user-sheets, r=heycam
style: Enable chrome-only CSS features in user stylesheets.

MozReview-Commit-ID: FJ4vTiOrotH
Bug: 1418963
Reviewed-by: heycam

<!-- 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/19315)
<!-- Reviewable:end -->
2017-11-21 04:27:25 -06:00
Emilio Cobos Álvarez
c7a3c929f6
style: Enable chrome-only CSS features in user stylesheets.
MozReview-Commit-ID: FJ4vTiOrotH
Reviewed-by: heycam
Bug: 1418963
2017-11-21 10:59:47 +01:00
Michael Wilson
10f3ef42bb style: :dir() pseudo class now represented by enum
Fixes #19195
2017-11-15 18:12:44 -08:00
Manish Goregaokar
b118ba72d0 Revert "Diagnostic map semantics."
This reverts commit f5c5be00a7.
2017-10-23 13:51:08 -07:00
Xidorn Quan
4ce3dc7729 Add slots in PerPseudoElementMap for tree pseudos. 2017-10-20 14:08:35 +11: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
Emilio Cobos Álvarez
bfe230f3ed
style: Remove the ElementExt trait.
It is likely it's the most useless trait ever existing.
2017-10-16 13:30:22 +02:00
Bobby Holley
f5c5be00a7 Diagnostic map semantics.
MozReview-Commit-ID: C0a5g6xMPY0
2017-10-07 12:54:15 -07:00
Bobby Holley
15b866d8de Revert #18668 - Add mprotect diagnostics for HashMap crash 2017-10-03 12:44:26 -07:00
Bobby Holley
98f370130d Semantics for ProtectedHashMap.
MozReview-Commit-ID: K0m65uZi7iw
2017-09-28 14:13:01 -07:00
Nicholas Nethercote
f7023a120e Measure the UA cache.
ServoStyleSetSizes now has two uses, one for the Stylist, and one for the UA
cache, and so the patch removes 'Stylist' from the field names.

Example output from about:memory:

> +----1,359,608 B (00.55%) -- layout
> |    +----756,488 B (00.31%) -- style-sheet-cache [2]
> |    +----393,968 B (00.16%) -- servo-ua-cache
> |    |    +--234,496 B (00.10%) -- element-and-pseudos-maps
> |    |    +---59,648 B (00.02%) -- revalidation-selectors
> |    |    +---58,320 B (00.02%) -- invalidation-map
> |    |    +---30,752 B (00.01%) -- other
> |    |    +---10,752 B (00.00%) -- precomputed-pseudos
2017-09-20 08:50:21 +10:00
Nicholas Nethercote
d880efcab3
Measure the stylist during memory reporting. 2017-09-05 19:43:50 +02:00
Clément DAVID
c5fe235112 order derivable traits lists
Ignoring :
 - **generated**.rs
 - python/tidy/servo_tidy_tests/rust_tidy.rs
2017-08-23 21:38:44 +02:00
Emilio Cobos Álvarez
0f37b209cb
stylo: Remove a lot of the restyle damage related complexity.
The only reason why we had the `existing_style_for_style_damage` bit is to apply
some optimizations that we don't have anymore.

I still want to reintroduce a few of them, at least for the non-eager
pseudo-element case... But I think I won't need this at all.

This allows us to remove a fair amount of Gecko code too.
2017-08-20 13:59:46 +02:00
Emilio Cobos Álvarez
faa8646e0f
style: Use an enumerated array for per-pseudo maps.
This avoids random HashMaps.

MozReview-Commit-ID: LQeZrLsoOnl
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-08 12:40:31 +02:00
Ting-Yu Lin
585c00f235 style: Introduce Chrome UI privilege for parsers
The motivation is that Chrome XBL stylesheets can be parsed under author
level, but we allow some event-state pseudo classes like
:-moz-handled-clicktoplay to be used.

Also synchronize the privilege of pseudo classes in
non_ts_pseudo_class_list.rs and nsCSSPseudoClassList.h (except :fullscreen).

MozReview-Commit-ID: 8fUjjC8hbQO
2017-08-03 16:30:08 +08:00
Manish Goregaokar
04b0ae64f2 stylo: Introduce ComputedValuesInner 2017-07-17 18:01:36 -07:00
Xidorn Quan
2649d0332a Call non-functional pseudo-elements simple pseudo-element. 2017-07-12 15:07:29 +10:00
Josh Matthews
27ae1ef2e7 Thread ParseError return values through CSS parsing. 2017-06-09 16:46:25 -04:00
J. Ryan Stinnett
e3a256803d Look for relevant links while matching
Adjust the matching process to look for a "relevant link" while matching.  A
"relevant link" is the element being matched if it is a link or the nearest
ancestor link.

Matching for links now depends on the `VisitedHandlingMode`, which determines
whether all links match as if they are unvisited (the default) or if the
relevant link matches as visited (and all others remain unvisited).

If a relevant link is ever found for any selector, track this as part of the
`MatchingContext` object.  This is used in the next patch to determine if an
additional match and cascade should be performed to compute the styles when
visited.

MozReview-Commit-ID: 3xUbRo7vpuD
2017-05-24 18:07:24 -05:00
Emilio Cobos Álvarez
e8d1c5316d
style: Refactor the cascade function.
The `cascade_primary_or_pseudo` function was nice when we shared more code, but
right now I think it just makes it harder to understand what's going on.
2017-05-17 16:32:30 +02:00
Bobby Holley
d78ca4c4f9 Use StyleArc in the style system.
MozReview-Commit-ID: flF0fv9E9M
2017-05-02 17:35:44 -07:00
Emilio Cobos Álvarez
0ea58d1ffa
style: Stop special-casing a few attributes for style sharing, and use a visitor to track dependencies.
Also, simplify all the pre-snapshot attribute hacks in the script and style
code.

MozReview-Commit-ID: 6c9ipeb7Tnr
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-09 18:15:50 +08:00
Bobby Holley
3f0d022ba2 Use a more compact representation to store eager pseudo-elements.
This means that ElementStyles only need a single word to store eager pseudos.

MozReview-Commit-ID: 5bDXlDweN46
2017-04-03 14:34:23 -07:00
Bobby Holley
1ff008caa3 Improve some ergonomics around pseudo-elements.
I think a lot of the current indirection predates the crate merge.

MozReview-Commit-ID: FM28dgZa5go
2017-04-03 12:35:14 -07:00
Emilio Cobos Álvarez
fa8874fb14
style: Document the restyle hints code, and make it operate on TElement.
This removes the annoying constraint of having to provide the current state from
outside of the restyle hints code.
2017-01-02 12:57:52 +01:00
Bobby Holley
80460cc549 Make Restyle tracking more granular.
The primary idea of this patch is to ditch the rigid enum of Previous/Current
styles, and replace it with a series of indicators for the various types of
work that needs to be performed (expanding snapshots, rematching, recascading,
and damage processing). This loses us a little bit of sanity checking (since
the up-to-date-ness of our style is no longer baked into the type system), but
gives us a lot more flexibility that we'll need going forward (especially when
we separate matching from cascading). We also eliminate get_styling_mode in
favor of a method on the traversal.

This patch does a few other things as ridealongs:
* Temporarily eliminates the handling for transfering ownership of styles to the
  frame. We'll need this again at some point, but for now it's causing too much
  complexity for a half-implemented feature.
* Ditches TRestyleDamage, which is no longer necessary post-crate-merge, and is
  a constant source of compilation failures from either needing to be imported
  or being unnecessarily imported (which varies between gecko and servo).
* Expands Snapshots for the traversal root, which was missing before.
* Fixes up the skip_root stuff to avoid visiting the skipped root.
* Unifies parallel traversal and avoids spawning for a single work item.
* Adds an explicit pre_traverse step do any pre-processing and determine whether
  we need to traverse at all.

MozReview-Commit-ID: IKhLAkAigXE
2016-12-09 14:46:40 -10:00
Cameron McCormack
22b62e0913 Don't match native anonymous content to user/author rules. 2016-11-24 13:00:12 +08:00
Simon Sapin
81a3de3299 Remove SelectorImpl aliases 2016-11-22 14:50:22 +01:00
Simon Sapin
82b13d50e3 Update to selectors 0.15 2016-11-22 14:50:21 +01:00
Simon Sapin
b203ab2419 Rename selector_impl.rs to selector_parser.rs
This makes it consistent with an upcoming update of the selectors crate.
2016-11-20 15:30:37 +01:00
Renamed from components/style/selector_impl.rs (Browse further)