aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/invalidation
Commit message (Collapse)AuthorAgeFilesLines
...
* style: Finer grained invalidation for attribute changes.Emilio Cobos Álvarez2020-06-042-92/+60
| | | | | | | | | | | | | | | | | | | | | | | This should help out quite a bit with uBO, which has lots of very general attribute selectors. We invalidate per attribute name rather than using a SelectorMap, which prevents matching for attribute selectors that can't have changed. The idea is that this should be generally cheaper, though there are cases where this would be a slight pesimization. For example, if there's an attribute selector like: my-specific-element[my-attribute] { /* ... */ } And you change `my-attribute` in an element that isn't a `my-specific-element`, before that the SelectorMap would've prevented us from selector-matching completely. Now we'd still run selector-matching for that (though the matching would be pretty cheap). However I think this should speed up things generally, let's see what the perf tests think before landing this though. Differential Revision: https://phabricator.services.mozilla.com/D76825
* style: Fix a no-longer valid assumption in pseudo-element matching / ↵Emilio Cobos Álvarez2020-06-041-11/+17
| | | | | | | | | | | invalidation code. After bug 1632647, we can have pseudo-classes inside :not / :is / :where, which the invalidation and matching code weren't handling. Add a few tests for this stuff working as expected. Differential Revision: https://phabricator.services.mozilla.com/D76160
* style: Optimize invalidation by scanning the rightmost compound inside ↵Emilio Cobos Álvarez2020-06-041-14/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | :where() and :is() with the outer visitor. See the comment about why this is valuable. For a selector like: .foo:is(.bar) > .baz Before this patch we'd generate an Dependency for .bar like this: Dependency { selector: .bar, offset: 0, parent: Some(Dependency { selector: .foo:is(.bar) > .baz, offset: 1, // Pointing to the `>` combinator. parent: None, }), } After this patch we'd generate just: Dependency { selector: .foo:is(.bar) > .baz, offset: 1, // Pointing to the `>` combinator. parent: None, } This is not only less memory but also less work. The reason for that is that, before this patch, when .bar changes, we'd look the dependency, and see there's a parent, and then scan that, so we'd match `.bar` two times, one for the initial dependency, and one for .foo:is(.bar). Instead, with this we'd only check `.foo:is(.bar)` once. Differential Revision: https://phabricator.services.mozilla.com/D71423
* style: Make Invalidation work in terms of a dependency, not a selector.Emilio Cobos Álvarez2020-06-044-192/+297
| | | | | | | | | | | | | That way we can look at the parent dependency as described in the previous patch. An alternative would be to add a: parent_dependency: Option<&'a Dependency> on construction to `Invalidation`, but this way seems slightly better to avoid growing the struct. It's not even one more indirection because the selector is contained directly in the Dependency struct. Differential Revision: https://phabricator.services.mozilla.com/D71422
* style: Keep track of nested dependencies for :where() and :is().Emilio Cobos Álvarez2020-06-042-146/+245
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tricky part of :is() and :where() is that they can have combinators inside, so something like this is valid: foo:is(#bar > .baz) ~ taz The current invalidation logic is based on the assumption that you can represent a combinator as a (selector, offset) tuple, which are stored in the Dependency struct. This assumption breaks with :is() and :where(), so we need to make them be able to represent a combinator in an "inner" selector. For this purpose, we add a `parent` dependency. With it, when invalidating inside the `:is()` we can represent combinators inside as a stack. The basic idea is that, for the example above, when an id of "bar" is added or removed, we'd find a dependency like: Dependency { selector: #bar > .baz, offset: 1, // pointing to the `>` combinator parent: Some(Dependency { selector: foo:is(#bar > .baz) > taz, offset: 1, // Pointing to the `~` combinator. parent: None, }) } That way, we'd start matching at the element that changed, towards the right, and if we find an element that matches .baz, instead of invalidating that element, we'd look at the parent dependency, then double-check that the whole left-hand-side of the selector (foo:is(#bar > .baz)) actually changed, and then keep invalidating to the right using the parent dependency as usual. This patch only builds the data structure and keeps the code compiling, the actual invalidation work will come in a following patch. Differential Revision: https://phabricator.services.mozilla.com/D71421
* style: Implement parsing / selector-matching for :is() and :where().Emilio Cobos Álvarez2020-04-181-1/+12
| | | | | | | | | | | | | | 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
* style: Allow to export a shadow part under multiple names.Emilio Cobos Álvarez2020-04-161-10/+0
| | | | | | | Other browsers allow this and the spec doesn't really disallow it, so fix it, add a test and carry on. Differential Revision: https://phabricator.services.mozilla.com/D65107
* Don't expose any AtomicRefCell directly from style traitsAnthony Ramine2020-04-041-1/+1
| | | | This lets us experiment with how we store this data on the DOM side.
* Rustfmt recent changes.Emilio Cobos Álvarez2019-12-162-5/+10
|
* style: Update smallvec to 1.0.Emilio Cobos Álvarez2019-12-161-1/+1
| | | | Differential Revision: https://phabricator.services.mozilla.com/D56044
* style: Refactor InvalidationMap flags to use bitflags.enordin2019-12-152-29/+34
| | | | Differential Revision: https://phabricator.services.mozilla.com/D55862
* style: Rustfmt recent changes.Emilio Cobos Álvarez2019-11-301-1/+1
|
* style: Invalidate parts in nested shadow trees correctly.Emilio Cobos Álvarez2019-11-302-25/+61
| | | | Differential Revision: https://phabricator.services.mozilla.com/D54010
* style: Implement shadow part forwarding (minus invalidation).Emilio Cobos Álvarez2019-11-304-8/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the stuff, in particular inside GeckoBindings stuff should be refactored to be less ugly and duplicate a bit less code, but the rest of the code should be landable as is. Some invalidation changes are already needed because we weren't matching with the right shadow host during invalidation (which made existing ::part() tests fail). Pending invalidation work: * Making exportparts work right on the snapshots. * Invalidating parts from descendant hosts. They're not very hard but I need to think how to best implement it: * Maybe get rid of ShadowRoot::mParts and just walk DOM descendants in the Shadow DOM. * Maybe implement a ElementHasExportPartsAttr much like HasPartAttr and use that to keep the list of elements. * Maybe invalidate :host and ::part() together in here[1] * Maybe something else. Opinions? [1]: https://searchfox.org/mozilla-central/rev/131338e5017bc0283d86fb73844407b9a2155c98/servo/components/style/invalidation/element/invalidator.rs#561 Differential Revision: https://phabricator.services.mozilla.com/D53730
* style: Fix ElementWrapper::is_link.Emilio Cobos Álvarez2019-11-302-7/+6
| | | | | | | | And do a full restyle only when the state goes from visited to unvisited or vice versa. That is, use regular invalidation for addition or removals of href attributes, for example. Differential Revision: https://phabricator.services.mozilla.com/D50821
* style: Always restyle / repaint when a visited query finishes.Emilio Cobos Álvarez2019-11-301-0/+8
| | | | Differential Revision: https://phabricator.services.mozilla.com/D50810
* style: Remove some XBL code in the style system.Emilio Cobos Álvarez2019-11-042-16/+1
| | | | Differential Revision: https://phabricator.services.mozilla.com/D50554
* style: Use fallible allocation for stylesheet invalidation.Emilio Cobos Álvarez2019-10-091-9/+18
| | | | | | | If the sets get too big we cannot allocate anything else, we'll just empty them and invalidate the whole document. Differential Revision: https://phabricator.services.mozilla.com/D46828
* style: Account for user stylesheets for Shadow DOM invalidation.Emilio Cobos Álvarez2019-09-121-2/+2
| | | | Differential Revision: https://phabricator.services.mozilla.com/D43992
* Rustfmt and fix tidy on recent changes.Emilio Cobos Álvarez2019-06-251-5/+3
|
* style: Invalidate style for ::selection.violet2019-06-251-0/+13
| | | | | | | | | | | | This patch invalidates the style for `::selection`, which will restore the behavior before the regression. However, it's still not quite correct, because repaint is not triggered. Given that `::selection` requires some major change to implement https://github.com/w3c/csswg-drafts/issues/2474, we can address this problem later. Differential Revision: https://phabricator.services.mozilla.com/D35305
* style: Add plumbing code to invalidate shadow parts.Emilio Cobos Álvarez2019-06-253-4/+49
| | | | | | | | Still does nothing, since we still do not collect part rules, but this is all the plumbing that should allow us to invalidate parts when attributes or state change on their ancestors. Differential Revision: https://phabricator.services.mozilla.com/D32642
* Auto merge of #23532 - est31:unused_code_removal_4, r=emiliobors-servo2019-06-071-6/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove unused code (4/4) <!-- Please describe your changes on the following line: --> Fourth and final PR in a series of PRs to remove unused/dead code from servo, powered by an (upcoming) tool of mine. Please take a look and tell me if you want to keep something. * First PR: #23477 * Second PR: #23498 * Third PR: #23499 Shortstat of the combined PR series: ``` 47 files changed, 7 insertions(+), 805 deletions(-) ``` --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because they only remove dead code <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/23532) <!-- Reviewable:end -->
| * Remove unused code from selector and style cratesest312019-06-071-6/+0
| |
* | style: Do not use borrowed types in the selectors::Element trait.Evgeniy Reizner2019-06-041-4/+15
| | | | | | | | | | Closes #22972 Closes #23463
* | style: Cleanup selector-matching for nested pseudo-elements, match ::slotted ↵Emilio Cobos Álvarez2019-05-291-0/+4
|/ | | | | | | | | | | 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: Implement selector-matching for ::part().Emilio Cobos Álvarez2019-05-071-2/+9
| | | | | | | | | | Also fairly straight-forward. This may get more complicated when we do part forwarding, if any. I've opened https://github.com/w3c/csswg-drafts/issues/3841 in what I think would be a cleaner model for forwarding. Differential Revision: https://phabricator.services.mozilla.com/D28063
* style: Add parsing support for ::part().Emilio Cobos Álvarez2019-05-073-1/+12
| | | | | | Disabled for now of course. This should be pretty uncontroversial I'd think. Differential Revision: https://phabricator.services.mozilla.com/D28060
* style: Remove support for XBL resources.Emilio Cobos Álvarez2019-05-071-8/+4
| | | | | | So much unsound code going away :-) Differential Revision: https://phabricator.services.mozilla.com/D28380
* style: Fix ::marker invalidation when we need to potentially insert a marker ↵Emilio Cobos Álvarez2019-04-121-2/+13
| | | | | | as a result of a style change. Differential Revision: https://phabricator.services.mozilla.com/D24888
* style: Add support for the ::marker pseudo element on list items. Alias ↵Mats Palmgren2019-03-271-0/+4
| | | | | | | :-moz-list-bullet/number to that in the parser. Bug: 205202 Reviewed-by: emilio
* style: Use a single RestyleHint representation.Emilio Cobos Álvarez2019-03-271-72/+1
| | | | Differential Revision: https://phabricator.services.mozilla.com/D22828
* style: Remove unnecessary mem::transmute in MediaListKey.Cameron McCormack2019-01-131-3/+1
| | | | Differential Revision: https://phabricator.services.mozilla.com/D16147
* style: Rustfmt recent changes.Emilio Cobos Álvarez2019-01-071-2/+6
|
* style: Update the Rust target version for bindgen.Emilio Cobos Álvarez2019-01-071-22/+15
| | | | | | This brings us alignas support and also associated constants for bitfield enums. Differential Revision: https://phabricator.services.mozilla.com/D15334
* Rustfmt has changed its default style :/Simon Sapin2018-12-281-2/+2
|
* style: Handle nested slots correctly in slotted matching and invalidation.Emilio Cobos Álvarez2018-12-161-11/+20
| | | | | | The patch and test should be pretty much self-descriptive. Differential Revision: https://phabricator.services.mozilla.com/D14063
* Update MPL license to https (part 4)Jan Andre Ikenmeyer2018-11-1910-10/+10
|
* `cargo fix --edition --features gecko`Simon Sapin2018-11-102-10/+10
|
* `cargo fix --edition`Simon Sapin2018-11-108-52/+52
|
* Reorder importsPyfisch2018-11-065-10/+10
|
* Format style component.chansuke2018-09-094-23/+26
|
* style: Only no-op visited <-> unvisited changes.Emilio Cobos Álvarez2018-09-051-15/+4
| | | | | | Other changes should really be (and are) indistinguishable. Differential Revision: https://phabricator.services.mozilla.com/D4847
* style: Use an Atom to represent Direction values in pseudo-classes.Cameron McCormack2018-09-032-19/+2
| | | | Differential Revision: https://phabricator.services.mozilla.com/D4730
* style: Remove an assertion that doesn't hold in some cases.Emilio Cobos Álvarez2018-09-031-5/+10
|
* style: Simplify visited-related code in invalidation.Emilio Cobos Álvarez2018-08-181-78/+27
| | | | | | | | | | | | | | | | We match with AllLinksVisitedAndUnvisited for style invalidation, and we already do a subtree restyle because :visited matching doesn't depend on the actual element state. So all this stuff is just not needed. The comment points to the attribute tests in bug 1328509, but those still trivially pass with this change. I think this was unneeded since I introduced AllLinksVisitedAndUnvisited, or maybe since https://github.com/servo/servo/pull/19520. In any case it doesn't really matter, and I already had done this cleanup in my WIP patches for bug 1406622, but I guess this is a slightly more suitable place to land them :) Differential Revision: https://phabricator.services.mozilla.com/D3305
* style: no-op visited changes earlier if visited links are disabled.Emilio Cobos Álvarez2018-08-181-1/+6
| | | | | | | | We force a repaint from ContentStateChangedInternal if visited links are disabled, and that's observable. Let's cut it off as early as we can to avoid timing attacks even when :visited is disabled. Differential Revision: https://phabricator.services.mozilla.com/D3304
* style: Cleanup invalidation processor constructor.Emilio Cobos Álvarez2018-08-081-12/+12
| | | | | | | | | It used to be this way because of lifetime issues (plus the shadow datas were in RwLocks at some point IIRC). Now we guarantee that as long as the element is away the cascade data is as well, so we don't need to thread it around. Differential Revision: https://phabricator.services.mozilla.com/D2768
* style: Remove unused selectors methods.Emilio Cobos Álvarez2018-08-081-10/+0
| | | | Differential Revision: https://phabricator.services.mozilla.com/D2767
* style: Improve logging for attribute changes.Emilio Cobos Álvarez2018-08-082-14/+31
| | | | | | | | And general Element logging. We now print all the attributes for comparison. If this turns out to be too verbose we can change it to diff them or something. Differential Revision: https://phabricator.services.mozilla.com/D2471