aboutsummaryrefslogtreecommitdiffstats
path: root/components/selectors
Commit message (Collapse)AuthorAgeFilesLines
* Move Stylo to its own repo (#31350)Delan Azabani2024-02-2715-7234/+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 remaining Stylo changes (#31408)Delan Azabani2024-02-221-3/+2
| | | | | * Revert remaining changes from Stylo split-into-commits branch * Do the minimum amount of formatting to appease mach test-tidy
* Revert as many changes to selectors from upstream as possible (#31365)Martin Robinson2024-02-209-69/+58
| | | | | | | | | | 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: Reduce Servo's diff with upstream `to_shmem` (#31349)Martin Robinson2024-02-141-2/+2
| | | | | This is part of getting Servo using an version of style closer to upstream. This change reverts some changes we made to `to_shmem` and `to_shmem_derive` in order to reduce our diff with upstream stylo.
* Further changes required by ServoOriol Brufau2023-11-241-6/+11
|
* style: Remove the never_matches field from attr selectorsEmilio Cobos Álvarez2023-11-243-41/+14
| | | | | | | It's an extra branch which in practice we almost never take, plus extra checks during parsing. Differential Revision: https://phabricator.services.mozilla.com/D180529
* style: Add a way to optimize the "attribute in no namespace exists" checkEmilio Cobos Álvarez2023-11-242-5/+12
| | | | | | Go through the slow path by default. No behavior change. Differential Revision: https://phabricator.services.mozilla.com/D180528
* style: Move `ANCHORS_RELATIVE_SELECTOR` out of nsINode flagsDavid Shin2023-11-242-18/+28
| | | | | | Move the flag to ComputedValueFlags, like `CONSIDERED_RELATIVE_SELECTOR`. Differential Revision: https://phabricator.services.mozilla.com/D180726
* style: Rustfmt servo/. r=zrhoffmanEmilio Cobos Álvarez2023-11-242-17/+17
| | | | | | | | $ find servo -name '*.rs' | xargs rustup run nightly rustfmt Depends on D179380 Differential Revision: https://phabricator.services.mozilla.com/D179381
* style: Correct style sharing handling for any element that considered ↵David Shin2023-11-242-1/+15
| | | | | | | | | | | | | | `:has()` in selector matching For any element that anchors a `:has()` selector (i.e. Matches a selector that contains a `:has()` on its rightmost side), we prevent style sharing altogether, as evaluation of the `:has()` selector is required in the first place to determine style sharing. On the other hand, any element matching a rule containing `:has()` without anchoring it can do style sharing for siblings, but not cousins. Differential Revision: https://phabricator.services.mozilla.com/D176836
* style: More gracefully deal with broken calls into selector matchingEmilio Cobos Álvarez2023-11-241-2/+4
| | | | | | | | If this happens again, it might be worth not matching rather than potentially crashing. Though I guess crashing is a very good way getting it reported soon... Differential Revision: https://phabricator.services.mozilla.com/D178921
* style: Properly increase the nesting level when matching :nth-child(of) ↵Emilio Cobos Álvarez2023-11-241-6/+8
| | | | | | selectors Differential Revision: https://phabricator.services.mozilla.com/D178920
* style: [css-nesting] Do a first pass at parsing nested rules mixed with ↵Emilio Cobos Álvarez2023-11-241-0/+17
| | | | | | | | | | | | | | | | | | declarations Plumb everything up. This factors out declaration and rule parsing so we share the code with the regular declaration parser. This could be made a bit nicer in the future. We need to decide what to do for @page and @keyframe (it seems conditional rules inside ought to work, but that's not so easy because per spec we create a nested style rule). But this is a first pass that passes a good chunk of the tests. There are other fixups to cssom, and I think some of the tests we fail are actually wrong... Differential Revision: https://phabricator.services.mozilla.com/D178266
* style: Disallow :has selector nestingDavid Shin2023-11-241-1/+12
| | | | | | | | Unlike the `ParseRelative` flag, which turns on relative selector parsing for that parsing level only, the newly added `DISALLOW_RELATIVE_SELECTOR` flag propagates through nested parsing calls. Differential Revision: https://phabricator.services.mozilla.com/D176807
* Further changes required by ServoOriol Brufau2023-11-211-1/+1
|
* style: [css-nesting] Process nested rules at cascade data rebuildEmilio Cobos Álvarez2023-11-211-94/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | More nesting plumbing. Still does nothing because we don't parse the nested rules. Should be trivial to prove this patch doesn't change any behavior so far, but I want to land it on its own because it can have performance implications. This follows the pattern of what we do with other rules like layers and container conditions, that is, keep the ancestor selectors in a stack, and poke at the last one in order to replace the ancestor. This changes the behavior of replace_parent_selector as with the newer version of the spec, stuff like: div { .foo { stuff } } Should work as `div .foo`. A test is added for this case. Differential Revision: https://phabricator.services.mozilla.com/D176560
* style: Remove MatchingContext mutability FIXME that no longer appliesZach Hoffman2023-11-211-3/+0
| | | | Differential Revision: https://phabricator.services.mozilla.com/D175028
* style: Fix some spec linksEmilio Cobos Álvarez2023-11-211-1/+1
| | | | | | Trivial, comment-only Differential Revision: https://phabricator.services.mozilla.com/D174474
* style: `:has` relative selector matching, with no caching/filteringDavid Shin2023-11-213-61/+332
| | | | Differential Revision: https://phabricator.services.mozilla.com/D172019
* Further changes required by ServoOriol Brufau2023-11-211-0/+1
|
* style: Record attribute dependencies within the selector list of ↵Zach Hoffman2023-11-213-8/+79
| | | | | | | | | | | | | | | | | | | | :nth-child(... of <selector list>) There are separate filters for IDs, classes, attribute local names, and element state. Also, we invalidate siblings of elements matched against the selector list of :nth-child(... of <selector list>) by marking matched elements with NODE_HAS_SLOW_SELECTOR_NTH_OF. The only remaining invalidation case invalidation case is `:nth-child(An+B of :has())` (bug 1818155), which should not block shipping `layout.css.nth-child-of.enabled`, because :has(...) is still being implemented (bug 418039). Depends on D172352 Differential Revision: https://phabricator.services.mozilla.com/D171936
* style: Apply selector flags to the shadow rootZach Hoffman2023-11-211-23/+4
| | | | | | | | | | | | Because restyle events cannot be posted for non-element nodes like the shadow root, a child's siblings are restyled directly if its parent has NODE_HAS_SLOW_SELECTOR or NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS but that parent is the shadow root. Drive-by, but braces were also added to some single-line "if" statements in RestyleManager. Differential Revision: https://phabricator.services.mozilla.com/D172352
* Further changes required by ServoOriol Brufau2023-11-211-0/+1
|
* style: Parsing for relative selectors in `:has()`David Shin2023-11-214-64/+206
| | | | Differential Revision: https://phabricator.services.mozilla.com/D171358
* style: Basic implementation of Custom Highlight APIJan-Niklas Jaeschke2023-11-061-0/+25
| | | | | | | | | | | | Added WebIDL interfaces as per spec, added some necessary changes to support maplike and setlike structures to be accessed from C++. Added `::highlight(foo)` pseudo element to CSS engine. Implemented Highlight as new kind of `Selection` using `HighlightType::eHighlight`. This implies Selections being added/removed during runtime (one `Selection` object per highlight identifier), therefore a dynamic container for highlight `Selection` objects was added to `nsFrameSelection`. Also, the painting code queries the highlight style for highlight Selections. Implementation is currently hidden behind a pref `dom.customHighlightAPI.enabled`. Differential Revision: https://phabricator.services.mozilla.com/D164203
* style: [css-nesting] Parse parent selectorEmilio Cobos Álvarez2023-11-063-75/+317
| | | | | | | | | | | | | 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
* Further changes required by ServoOriol Brufau2023-11-061-1/+1
|
* style: Add lab(), lch(), oklab(), oklch() to specified colorsTiaan Louw2023-11-061-1/+1
| | | | | | | | | | | Use new changes from cssparser and use the new lab/lch/oklab/oklch color formats. Introduced a new color type AbsoluteColor. It represents any kind of color that has absolute numerical values. It is also tied to a color space and therefore can be trivially converted to another color space. Differential Revision: https://phabricator.services.mozilla.com/D163579
* style: Reuse list_matches_complex_selector() where possibleZach Hoffman2023-11-061-16/+6
| | | | | | It can be reused for the Is, Where, and Negation components. Differential Revision: https://phabricator.services.mozilla.com/D166267
* style: Apply slow selector flags before matchingZach Hoffman2023-11-061-12/+4
| | | | | | | | | This patch fixes a bug introduced by bug 1808228/D166266, where, if an element does not initially match :nth-child(An+B of selector list) or :nth-last-child(An+B of selector list), changing a sibling or ancestor will not invalidate that element. Differential Revision: https://phabricator.services.mozilla.com/D166982
* style: Implement selector matching for :nth-child(An+B of selector list) and ↵Zach Hoffman2023-11-043-56/+197
| | | | | | | | | | | | :nth-last-child(An+B of selector list) Since we have been using a single hash map to cache all :nth-child indices (with no selector list), each different selector will need its own cache. As a side note, this patch does not address invalidation. Differential Revision: https://phabricator.services.mozilla.com/D166266
* style: Move nth-related logic to the NthSelectorData type for reuseZach Hoffman2023-11-042-42/+50
| | | | | | | 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-043-10/+115
| | | | | | | | | 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: Minor clean-ups and fixes on top of the previous patchEmilio Cobos Álvarez2023-11-042-94/+113
| | | | | | | | This makes the matching / parsing more self-contained, and I believe it's generally easier to follow. Also addresses review comments from the previous patch. Differential Revision: https://phabricator.services.mozilla.com/D165861
* style: Represent FirstChild, FirstOfType, LastChild, LastOfType, OnlyChild, ↵Zach Hoffman2023-11-043-61/+75
| | | | | | | | | | | | 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-043-41/+47
| | | | | | | | | | | 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: Avoid generic soup and extra reference count bumpsEmilio Cobos Álvarez2023-11-042-3/+3
| | | | | | This makes me a bit happier about the previous patch :) Differential Revision: https://phabricator.services.mozilla.com/D165236
* style: Speed up selector matching with already-lowercase local name selectorsEmilio Cobos Álvarez2023-11-042-45/+46
| | | | | | | | | This makes relatively simple changes so that we check lowercase-ness of local-name selectors first. If so, we don't need to check whether we're an HTML element in an HTML document, which requires a fair bit of pointer-chasing. Differential Revision: https://phabricator.services.mozilla.com/D163627
* style: Run "cargo +nightly fmt" for style components in servoTing-Yu Lin2023-11-033-27/+23
| | | | | | | | | | | | | | | | | | 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: Disallow forgiving selector-parsing in @supportsEmilio Cobos Álvarez2023-11-031-1/+10
| | | | | | As per spec, see https://github.com/w3c/csswg-drafts/issues/7280 Differential Revision: https://phabricator.services.mozilla.com/D156468
* style: Add simple parsing and matching support for :hasTiaan Louw2023-10-024-9/+60
| | | | | | | | 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
* style: Update derive_more to 0.99.17Mike Hommey2023-10-021-1/+1
| | | | | | | Limit its features to those we actually use, which turns out is none for webrender_api. Differential Revision: https://phabricator.services.mozilla.com/D148734
* style: Use debug_unreachable!() in matches_simple_selectorEmilio Cobos Álvarez2023-10-022-1/+5
| | | | | | | | | This shrinks the function by avoiding generating rather noisy panic code. Depends on D145486 Differential Revision: https://phabricator.services.mozilla.com/D145487
* style: Reorder some variantsEmilio Cobos Álvarez2023-10-022-69/+70
| | | | | | | | | | | | | This doesn't make a difference, I was hoping it would allow us to remove the special-casey code we have here: https://searchfox.org/mozilla-central/rev/997a56b018662e2940c99bbaf57a6ac9d1aa5422/servo/components/selectors/matching.rs#610-632 But it doesn't. Still I think it doesn't hurt tho, shouldn't change behavior. Depends on D145485 Differential Revision: https://phabricator.services.mozilla.com/D145486
* style: Simplify a bit hot selector-matching loopEmilio Cobos Álvarez2023-10-021-11/+7
| | | | | | | | | | | | Note that element.clone() is just copying a couple pointers. Have a single place where we compute the next element and check for linky-ness. This saves a couple checks (very very minor win in the micro-benchmark I've been looking at, but consistent). Depends on D145484 Differential Revision: https://phabricator.services.mozilla.com/D145485
* style: Compute hover / active quirk state lazilyEmilio Cobos Álvarez2023-10-021-35/+22
| | | | | | | | | This makes the inner function much smaller which improves selector-matching performance very mildly for the benchmarks I've been looking at. Also, this should help selector matching on quirks mode by only doing this when we actually find :hover / :active pseudo-classes. Differential Revision: https://phabricator.services.mozilla.com/D145484
* style: Avoid some clone()s in selector parsing now that lifetimes are ↵Emilio Cobos Álvarez2023-10-021-16/+13
| | | | | | non-lexical Differential Revision: https://phabricator.services.mozilla.com/D123622
* remove `extern crate` (#30311)Samson2023-09-082-3/+1
| | | | | | | | | | | * remove extern crate * Update components/script_plugins/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Format toml files (#30112)Samson2023-08-171-1/+1
| | | | | | | * Add taplo fmt config for toml fmt * fmt toml files * Add even-better-toml to extensions recommendations
* Avoid complaints from ./mach test-tidyOriol Brufau2023-08-161-0/+1
|