aboutsummaryrefslogtreecommitdiffstats
path: root/components/selectors/builder.rs
Commit message (Collapse)AuthorAgeFilesLines
* Move Stylo to its own repo (#31350)Delan Azabani2024-02-271-398/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove packages that were moved to external repo * Add workspace dependencies pointing to 2023-06-14 branch * Fix servo-tidy.toml errors * Update commit to include #31346 * Update commit to include servo/stylo#2 * Move css-properties.json lookup to target/doc/stylo * Remove dependency on vendored mako in favour of pypi dependency This also removes etc/ci/generate_workflow.py, which has been unused since at least 9e71bd6a7010d6e5723831696ae0ebe26b47682f. * Add temporary code to debug Windows test failures * Fix failures on Windows due to custom target dir * Update commit to include servo/stylo#3 * Fix license in tests/unit/style/build.rs * Document how to build with local Stylo in Cargo.toml
* Revert as many changes to selectors from upstream as possible (#31365)Martin Robinson2024-02-201-8/+2
| | | | | | | | | | This is part of the preparation for splitting stylo into a separate crate. We have made various changes to selectors includings: 1. Bumping the rust edition 2. Fixing typos and updating links In addition to reverting those changes, this PR pulls in some changes to selectors we seem to have missed in the process of updates.
* style: Rustfmt servo/. r=zrhoffmanEmilio Cobos Álvarez2023-11-241-2/+1
| | | | | | | | $ find servo -name '*.rs' | xargs rustup run nightly rustfmt Depends on D179380 Differential Revision: https://phabricator.services.mozilla.com/D179381
* style: `:has` relative selector matching, with no caching/filteringDavid Shin2023-11-211-14/+25
| | | | Differential Revision: https://phabricator.services.mozilla.com/D172019
* style: Parsing for relative selectors in `:has()`David Shin2023-11-211-1/+2
| | | | Differential Revision: https://phabricator.services.mozilla.com/D171358
* style: [css-nesting] Parse parent selectorEmilio Cobos Álvarez2023-11-061-43/+66
| | | | | | | | | | | | | This parses the ampersand as a parent selector behind an (off-by-default) selectors feature. The plan is to call replace_parent_selector while we're doing the CascadeData rebuilds, which is where we can have all the ancestor nesting information. No behavior change. Differential Revision: https://phabricator.services.mozilla.com/D167237
* style: Move nth-related logic to the NthSelectorData type for reuseZach Hoffman2023-11-041-3/+3
| | | | | | | Drive-by, but selector_list_specificity() was also renamed to max_selector_list_specificity(). Differential Revision: https://phabricator.services.mozilla.com/D166263
* style: Implement parsing and serialization for nth-child(An+B of selector ↵Zach Hoffman2023-11-041-6/+22
| | | | | | | | | list) and :nth-last-child(An+B of selector list) :nth-{,last-}child parsing is disabled by default for now by pref layout.css.nth-child-of.enabled. Differential Revision: https://phabricator.services.mozilla.com/D165895
* style: Represent FirstChild, FirstOfType, LastChild, LastOfType, OnlyChild, ↵Zach Hoffman2023-11-041-6/+0
| | | | | | | | | | | | and OnlyOfType as functionless Nth variants Like bug 1808226, this doesn't change any behavior, it just simplifies matching. I also added a WPT JavaScript test for :only-of-type, since dedicated WPT JavScript tests already exist for the other pseudo-classes this patch touches. Differential Revision: https://phabricator.services.mozilla.com/D165859
* style: Store values for :nth- selectors in dedicated struct NthSelectorDataZach Hoffman2023-11-041-4/+1
| | | | | | | | | | | To accomplish this, all :nth- Components were replaced with type Nth, which uses NthSelectorData. Using NthSelectorData will make it easier to add selector lists for :nth selectors later on, but this change by itself shouldn't change any behavior. Differential Revision: https://phabricator.services.mozilla.com/D165831
* style: Run "cargo +nightly fmt" for style components in servoTing-Yu Lin2023-11-031-3/+1
| | | | | | | | | | | | | | | | | | 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
* style: Add simple parsing and matching support for :hasTiaan Louw2023-10-021-4/+6
| | | | | | | | Parsing is behind a config value `layout.css.has-selectors.enabled`. This change does not support p:has(> a) combinators, but will handle them gracefully, just not matching on them. Differential Revision: https://phabricator.services.mozilla.com/D149515
* Upgrade remaining components to edition 2018sagudev2023-02-181-0/+4
|
* selectors/*.rs - Put all the to_shmem attributes behind a "shmem" featureFederico Mena Quintero2023-02-141-2/+4
|
* style: Implement complex :not().Emilio Cobos Álvarez2021-02-261-6/+1
| | | | | | | | | | | | | | | This fixes the failures in bug 1671573 and just works thanks to the invalidation improvements I did for :is / :where. Added a couple tests for invalidation which is the tricky bit. 001 is a very straight-forward test, 002 is the :is test but with :is() replaced by double-:not(). This also fixes default namespaces inside :is() / :where(), which are supposed to get ignored, but aren't. Added tests for that and for the pre-existing :not() behavior which Chrome doesn't quite get right. Differential Revision: https://phabricator.services.mozilla.com/D94142
* style: Replace :-moz-native-anonymous-no-specificity with ↵Masatoshi Kimura2021-02-261-7/+3
| | | | | | :where(:-moz-native-anonymous). Differential Revision: https://phabricator.services.mozilla.com/D88255
* style: Implement parsing / selector-matching for :is() and :where().Emilio Cobos Álvarez2020-04-181-0/+13
| | | | | | | | | | | | | | This implements the easy / straight-forward parts of the :where / :is selectors. The biggest missing piece is to handle properly invalidation when there are combinators present inside the :where. That's the hard part of this, actually. But this is probably worth landing in the interim. This fixes some of the visitors that were easy to fix. Differential Revision: https://phabricator.services.mozilla.com/D70788
* Rustfmt recent changes.Emilio Cobos Álvarez2019-12-161-1/+1
|
* style: Update smallvec to 1.0.Emilio Cobos Álvarez2019-12-161-2/+2
| | | | Differential Revision: https://phabricator.services.mozilla.com/D56044
* style: Correctly style dark scrollbars in tree components.Cameron McCormack2019-12-161-3/+7
| | | | | | | | | | | | | | | | We need to ensure the rules that override all properties for scrollbar part elements only apply to those that are NAC (and so will be eligible for NAC style sharing). We have some uses of non-NAC <scrollbar> elements that should continue to inherit properties from their parents. To avoid any changes in rule matching order that come with changing specificity, we add a new :-moz-native-anonymous-no-specificity pseudo-class. While we're here, we note :-moz-native-anonymous-no-specificity (and the regular :-moz-native-anonymous pseudo-class) as not needing style sharing cache revalidation, as we never share NAC styles. Differential Revision: https://phabricator.services.mozilla.com/D56154
* Rustfmt and fix tidy on recent changes.Emilio Cobos Álvarez2019-06-251-6/+3
|
* style: Add an extra flag to flag ::part() to selectors.Emilio Cobos Álvarez2019-06-251-14/+36
| | | | | | | | This grows the selector struct, but only in 32-bit, since in 64-bit we take space from the alignment padding that we're paying due to having the size of the slice as a word. Differential Revision: https://phabricator.services.mozilla.com/D32645
* style: Cleanup selector-matching for nested pseudo-elements, match ::slotted ↵Emilio Cobos Álvarez2019-05-291-6/+0
| | | | | | | | | | | correctly when there's no selector before it, and add tests. D29542 fixed the bogus checks that was making nested pseudo-elements match author rules. This adds tests and ends up being just a cleanup, though as it turns out we it also fixes an issue with ::slotted() matched from Element.matches. Differential Revision: https://phabricator.services.mozilla.com/D27529
* style: Rustfmt recent changes.Emilio Cobos Álvarez2019-05-071-2/+1
|
* style: Add parsing support for ::part().Emilio Cobos Álvarez2019-05-071-0/+1
| | | | | | Disabled for now of course. This should be pretty uncontroversial I'd think. Differential Revision: https://phabricator.services.mozilla.com/D28060
* style: Add derived ToShmem implementations.Cameron McCormack2019-04-121-1/+1
| | | | Differential Revision: https://phabricator.services.mozilla.com/D17197
* style: Derive more.Bobby Holley2019-01-291-33/+1
| | | | Differential Revision: https://phabricator.services.mozilla.com/D17029
* Update MPL license to https (part 4)Jan Andre Ikenmeyer2018-11-191-1/+1
|
* `cargo fix --edition`Simon Sapin2018-11-101-2/+2
|
* Reorder importsPyfisch2018-11-061-1/+1
|
* style: Assert earlier to try to get a more helpful stack.Emilio Cobos Álvarez2018-10-281-1/+1
|
* style: Back out diagnostics for not being helpful enough at diagnosing.Emilio Cobos Álvarez2018-10-281-16/+9
| | | | | | The selectors that crash seem just corrupted data structures, none of the selectors from crash dumps make sense, and the ones for which I could trace the source found no issue.
* format components/selectorsAnshul Malik2018-09-121-6/+5
|
* style: Make :host() and ::slotted() account for the inner selector's ↵Emilio Cobos Álvarez2018-07-011-12/+37
| | | | | | | | | | specificity. As resolved in https://github.com/w3c/csswg-drafts/issues/1915. Bug: 1454165 Reviewed-by: xidorn Differential Revision: https://phabricator.services.mozilla.com/D1849
* style: Add diagnostics.Emilio Cobos Álvarez2018-06-121-7/+18
| | | | | | Bug: 1416282 Reviewed-by: xidorn MozReview-Commit-ID: GTnFyZnXR84
* Run rustfmt on selectors, servo_arc, and style.Bobby Holley2018-04-101-40/+33
| | | | | | | | | | 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)
* style: Implement the functional :host(..) selector.Emilio Cobos Álvarez2018-04-101-1/+1
| | | | | | | | | We could invalidate in a slightly more fine-grained way, but I don't think it's worth the churn vs. keeping the special-cases minimal. Bug: 1452640 Reviewed-by: xidorn MozReview-Commit-ID: 5DkQrgwg9GW
* style: Implement the non-functional :host selector.Emilio Cobos Álvarez2018-04-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Kinda tricky because :host only matches rules on the shadow root where the rules come from. So we need to be careful during invalidation and style sharing. I didn't use the non_ts_pseudo_class_list bits because as soon as we implement the :host(..) bits we're going to need to special-case it anyway. The general schema is the following: * Rightmost featureless :host selectors are handled inserting them in the host_rules hashmap. Note that we only insert featureless stuff there. We could insert all of them and just filter during matching, but that's slightly annoying. * The other selectors, like non-featureless :host or what not, are added to the normal cascade data. This is harmless, since the shadow host rules are never matched against the host, so we know they'll just never match, and avoids adding more special-cases. * Featureless :host selectors to the left of a combinator are handled during matching, in the special-case of next_element_for_combinator in selectors. This prevents this from being more invasive, and keeps the usual fast path slim, but it's a bit hard to match the spec and the implementation. We could keep a copy of the SelectorIter instead in the matching context to make the handling of featureless-ness explicit in match_non_ts_pseudo_class, but we'd still need the special-case anyway, so I'm not fond of it. * We take advantage of one thing that makes this sound. As you may have noticed, if you had `root` element which is a ShadowRoot, and you matched something like `div:host` against it, using a MatchingContext with current_host == root, we'd incorrectly report a match. But this is impossible due to the following constraints: * Shadow root rules aren't matched against the host during styling (except these featureless selectors). * DOM APIs' current_host needs to be the _containing_ host, not the element itself if you're a Shadow host. Bug: 992245 Reviewed-by: xidorn MozReview-Commit-ID: KayYNfTXb5h
* style: Store ::slotted rules separately on the cascade data, since they may ↵Emilio Cobos Álvarez2018-01-091-2/+20
| | | | | | cross the shadow boundary. MozReview-Commit-ID: EY9nK3169vv
* selectors: Add parsing support for ::slotted().Emilio Cobos Álvarez2017-12-141-3/+14
| | | | | | | | | | | | | | | | | | | Without turning it on yet, of course. The reason why I didn't use the general PseudoElement mechanism is because this pseudo is a bit of its own thing, and I found easier to make ::selectors know about it (because you need to jump to the assigned slot) than the other way around. Also, we need to support ::slotted(..)::before and such, and supporting multiple pseudo-elements like that breaks some other invariants around the SelectorMap, and fixing those would require special-casing slotted a lot more in other parts of the code. Let me know if you think otherwise. I also don't like much the boolean tuple return value, but I plan to do some cleanup in the area in a bit, so it should go away soon, I'd hope.
* Add support for :scope pseudo-classXidorn Quan2017-10-091-1/+1
|
* Report invalid selectors (bug 1384216).Josh Matthews2017-08-281-0/+6
|
* order derivable traits listsClément DAVID2017-08-231-1/+1
| | | | | | Ignoring : - **generated**.rs - python/tidy/servo_tidy_tests/rust_tidy.rs
* Less unsafe in selectors::builder.Simon Sapin2017-06-201-58/+40
| | | | MozReview-Commit-ID: 7IIyio8WAa7
* Invert the order of each compound selector.Bobby Holley2017-06-201-12/+200
| | | | MozReview-Commit-ID: JkBjqyYgbrB
* Hoist specificity computation into a new private builder module.Bobby Holley2017-06-201-0/+141
This patch doesn't modify any of the code because making a few things pub. I did this first to make the next patch easier to audit. MozReview-Commit-ID: 7PYxoS5bVGN