Details
- Reviewers
emilio smaug • canadahonk - Commits
- rMOZILLACENTRALae536a17c1ff: Bug 1861466 - Add CustomStateSet and :state() pseudo. r=emilio,smaug
- Bugzilla Bug ID
- 1861466
Diff Detail
- Repository
- rMOZILLACENTRAL mozilla-central
- Build Status
Buildable 595311 Build 693443: arc lint + arc unit
Event Timeline
| dom/html/CustomStateSet.cpp | ||
|---|---|---|
| 92 | Figured it out for now by getting the presshell to invalid styles. | |
4 defects closed compared to the previous diff 780867.
If you see a problem in this automated review, please report it here.
| dom/base/rust/lib.rs | ||
|---|---|---|
| 135 ↗ | (On Diff #780869) | I don't understand why you need this flag, care explaining? |
| dom/html/CustomStateSet.cpp | ||
| 88 | This is not only too inefficient. It's also incorrect if there are combinators (:state(foo) + div won't get invalidated). Need tests for that, but also we should hook this up into the style invalidation machinery just like ElementStatesChanged does. | |
| 92 | Fwiw, please use needinfo for questions next time since phab email is super easy to miss | |
| 125 | This assertion seems a bit silly | |
| dom/html/CustomStateSet.h | ||
| 62 | This seems leftover | |
| dom/html/ElementInternals.cpp | ||
| 31 | (here) | |
| 55 | No need to initialise a refptr explicitly fwiw | |
| dom/html/ElementInternals.h | ||
| 209 | This needs to be traversed / unlinked to prevent leaks. | |
| servo/components/style/gecko/wrapper.rs | ||
| 1217 | Leftover? | |
| servo/components/style/invalidation/element/invalidation_map.rs | ||
| 570 ↗ | (On Diff #780869) | Hm? |
| dom/base/rust/lib.rs | ||
|---|---|---|
| 135 ↗ | (On Diff #780869) | I figured that this flag would allow the matcher to skip a bunch of work if there are no custom states set. Premature/needless optimization? |
| dom/html/CustomStateSet.cpp | ||
| 88 | I've added some tests. I'm struggling to know what to do here though. | |
| 92 | Thanks for the tip! Still new to all this, so this kind of information is very much appreciated. | |
| 125 | Oh yeah 😅 this was when I was failing to understand why my methods were being called because I missed that setlike<> IDL needs the partial interface to override the methods for this code to actually kick in. | |
| servo/components/style/gecko/wrapper.rs | ||
| 1217 | Yes 😆 can you tell I struggled with this? | |
r- because I couldn't figure out how CheckStateToken should work.
| dom/base/Element.cpp | ||
|---|---|---|
| 4407 | How can we know that we have slots around? Is there some hidden expectation that GetCustomStates is called only after slots has been created? If so, that should be somehow reflected in the method name. | |
| dom/html/CustomStateSet.cpp | ||
| 26 | One could simplify this by using NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE. I know I know, there are tons of macros. | |
| 73 | This doesn't seem to quite check whether aState is valid. On the other hand if I'm looking at https://github.com/whatwg/html/pull/8467, I'm not sure what the behavior should be. | |
| dom/base/Element.cpp | ||
|---|---|---|
| 4407 | CustomStateSet can only be retrieved from ElementInternals which only exists if CustomElementData does - and that only exists in the extended DOM slots. However I have no strong opinions on it remaining that way and I'm happy to use ExtendedDOMSlots() instead. | |
| dom/html/CustomStateSet.cpp | ||
| 73 | Based on further discussions in the whatwg channels, we've settled to not add validation - so I've removed it. | |
Looks good modulo the comments below. Thanks!
| dom/base/rust/lib.rs | ||
|---|---|---|
| 135 ↗ | (On Diff #780869) | Is it really all that much work? If there are no states you don't do much work at all, the array is empty etc. Let's remove this. |
| dom/html/CustomStateSet.cpp | ||
| 48 | OwnerDoc can't return null. | |
| 59 | Okay, we can go for this for now, but let's file a follow-up to make invalidation correct and reference it from here, since this doesn't deal with :has, sibling combinators, :nth-child(.. of :state()), etc. All those things need tests (they can be marked as failing for now). | |
| 63 | There's no need to check Failed() at the beginning of the method right? | |
| dom/html/ElementInternals.cpp | ||
| 347 | Can this just be a regular pointer? It's kept alive by the ElementInternals anyways. | |
| servo/components/style/gecko/wrapper.rs | ||
| 1370 | I'd remove these rustfmt changes. | |
| 2024 | This can just be self.has_custom_state(..). It's not substantially more expensive if there are no states to check html-ness. | |
| dom/html/CustomStateSet.cpp | ||
|---|---|---|
| 59 | Definitely happy to follow up with more robust tests and a proper implementation here. | |
Style stuff looks good, one suggestion about the DOM
| dom/base/Element.h | ||
|---|---|---|
| 623 | Let's call this either EnsureCustomStates(), or GetOrCreateCustomStates(), since it's otherwise very subtle that it allocates. | |
| dom/html/CustomStateSet.cpp | ||
|---|---|---|
| 59 | Delete returns true if something was deleted, so wouldn't it make sense to check also the return value before removing entry from native side? | |
| dom/html/CustomStateSet.h | ||
| 56 | It makes very much sense that mTarget is a strong pointer. I wonder if there are tests where JS has strong reference only to CustomStateSet and weak ref to the relevant element, and then GC/CC is triggered and element should stay around. | |
| dom/html/CustomStateSet.h | ||
|---|---|---|
| 56 | Should I use a WeakPtr instead? | |
| dom/html/CustomStateSet.h | ||
|---|---|---|
| 56 | Actually I wrote a test instead, I know you didn't request one but I felt better with it. Hopefully it is sufficient. | |