mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
style: Invalidate shadow part pseudo-class styles correctly.
I was going to send a test for `:focus` via wpt, but then realized it was probably not spec-compliant with the new rules people want to follow for :focus, so I filed https://github.com/w3c/csswg-drafts/issues/4555 instead. Testing `:hover` / `:active` via wpt looked quite a bit of a hassle. Differential Revision: https://phabricator.services.mozilla.com/D55591
This commit is contained in:
parent
6973317a58
commit
7cd59da2a0
3 changed files with 53 additions and 4 deletions
|
@ -807,6 +807,9 @@ pub trait TElement:
|
|||
/// data if it comes from Shadow DOM.
|
||||
///
|
||||
/// Returns whether normal document author rules should apply.
|
||||
///
|
||||
/// TODO(emilio): We could separate the invalidation data for elements
|
||||
/// matching in other scopes to avoid over-invalidation.
|
||||
fn each_applicable_non_document_style_rule_data<'a, F>(&self, mut f: F) -> bool
|
||||
where
|
||||
Self: 'a,
|
||||
|
@ -841,11 +844,42 @@ pub trait TElement:
|
|||
// Slots can only have assigned nodes when in a shadow tree.
|
||||
let shadow = slot.containing_shadow().unwrap();
|
||||
if let Some(data) = shadow.style_data() {
|
||||
f(data, shadow.host());
|
||||
if data.any_slotted_rule() {
|
||||
f(data, shadow.host());
|
||||
}
|
||||
}
|
||||
current = slot.assigned_slot();
|
||||
}
|
||||
|
||||
if target.has_part_attr() {
|
||||
if let Some(mut inner_shadow) = target.containing_shadow() {
|
||||
loop {
|
||||
let inner_shadow_host = inner_shadow.host();
|
||||
match inner_shadow_host.containing_shadow() {
|
||||
Some(shadow) => {
|
||||
if let Some(data) = shadow.style_data() {
|
||||
if data.any_part_rule() {
|
||||
f(data, shadow.host())
|
||||
}
|
||||
}
|
||||
// TODO: Could be more granular.
|
||||
if !shadow.host().exports_any_part() {
|
||||
break;
|
||||
}
|
||||
inner_shadow = shadow;
|
||||
}
|
||||
None => {
|
||||
// TODO(emilio): Should probably distinguish with
|
||||
// MatchesDocumentRules::{No,Yes,IfPart} or
|
||||
// something so that we could skip some work.
|
||||
doc_rules_apply = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
doc_rules_apply
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue