diff --git a/servo/components/style/properties/cascade.rs b/servo/components/style/properties/cascade.rs index e56073e1dd4f..a94ac5646882 100644 --- a/servo/components/style/properties/cascade.rs +++ b/servo/components/style/properties/cascade.rs @@ -56,6 +56,7 @@ pub fn cascade( pseudo: Option<&PseudoElement>, rule_node: &StrongRuleNode, guards: &StylesheetGuards, + originating_element_style: Option<&ComputedValues>, parent_style: Option<&ComputedValues>, parent_style_ignoring_first_line: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValues>, @@ -74,6 +75,7 @@ where pseudo, rule_node, guards, + originating_element_style, parent_style, parent_style_ignoring_first_line, layout_parent_style, @@ -174,6 +176,7 @@ fn cascade_rules( pseudo: Option<&PseudoElement>, rule_node: &StrongRuleNode, guards: &StylesheetGuards, + originating_element_style: Option<&ComputedValues>, parent_style: Option<&ComputedValues>, parent_style_ignoring_first_line: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValues>, @@ -197,6 +200,7 @@ where rule_node, guards, DeclarationIterator::new(rule_node, guards, pseudo), + originating_element_style, parent_style, parent_style_ignoring_first_line, layout_parent_style, @@ -233,6 +237,7 @@ pub fn apply_declarations<'a, E, I>( rules: &StrongRuleNode, guards: &StylesheetGuards, iter: I, + originating_element_style: Option<&ComputedValues>, parent_style: Option<&ComputedValues>, parent_style_ignoring_first_line: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValues>, @@ -247,6 +252,10 @@ where E: TElement, I: Iterator, { + debug_assert_eq!( + originating_element_style.is_some(), + element.is_some() && pseudo.is_some() + ); debug_assert!(layout_parent_style.is_none() || parent_style.is_some()); debug_assert_eq!( parent_style.is_some(), @@ -283,7 +292,7 @@ where let is_root_element = pseudo.is_none() && element.map_or(false, |e| e.is_root()); let container_size_query = - ContainerSizeQuery::for_option_element(element, pseudo.and(parent_style)); + ContainerSizeQuery::for_option_element(element, originating_element_style); let mut context = computed::Context::new( // We'd really like to own the rules here to avoid refcount traffic, but @@ -340,6 +349,7 @@ where if let Some(visited_rules) = visited_rules { cascade.compute_visited_style_if_needed( element, + originating_element_style, parent_style, parent_style_ignoring_first_line, layout_parent_style, @@ -726,6 +736,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> { fn compute_visited_style_if_needed( &mut self, element: Option, + originating_element_style: Option<&ComputedValues>, parent_style: Option<&ComputedValues>, parent_style_ignoring_first_line: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValues>, @@ -756,6 +767,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> { self.context.builder.pseudo, visited_rules, guards, + visited_parent!(originating_element_style), visited_parent!(parent_style), visited_parent!(parent_style_ignoring_first_line), visited_parent!(layout_parent_style), diff --git a/servo/components/style/style_resolver.rs b/servo/components/style/style_resolver.rs index eba94c786294..e2ad792eb0e6 100644 --- a/servo/components/style/style_resolver.rs +++ b/servo/components/style/style_resolver.rs @@ -349,6 +349,7 @@ where pseudo, inputs, &self.context.shared.guards, + pseudo.and(parent_style), parent_style, parent_style, layout_parent_style, diff --git a/servo/components/style/stylist.rs b/servo/components/style/stylist.rs index 45001d5f513c..b0ffdce8467e 100644 --- a/servo/components/style/stylist.rs +++ b/servo/components/style/stylist.rs @@ -894,8 +894,9 @@ impl Stylist { }, pseudo, guards, + /* originating_element_style */ None, parent, - None, + /* element */ None, ) } @@ -988,6 +989,7 @@ impl Stylist { cascade_inputs, pseudo, guards, + Some(originating_element_style), Some(parent_style), Some(element), )) @@ -1002,6 +1004,7 @@ impl Stylist { inputs: CascadeInputs, pseudo: &PseudoElement, guards: &StylesheetGuards, + originating_element_style: Option<&ComputedValues>, parent_style: Option<&ComputedValues>, element: Option, ) -> Arc @@ -1025,6 +1028,7 @@ impl Stylist { Some(pseudo), inputs, guards, + originating_element_style, parent_style, parent_style, parent_style, @@ -1051,6 +1055,7 @@ impl Stylist { pseudo: Option<&PseudoElement>, inputs: CascadeInputs, guards: &StylesheetGuards, + originating_element_style: Option<&ComputedValues>, parent_style: Option<&ComputedValues>, parent_style_ignoring_first_line: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValues>, @@ -1086,6 +1091,7 @@ impl Stylist { pseudo, inputs.rules.as_ref().unwrap_or(self.rule_tree.root()), guards, + originating_element_style, parent_style, parent_style_ignoring_first_line, layout_parent_style, @@ -1504,6 +1510,7 @@ impl Stylist { ), ) }), + /* originating_element_style */ None, Some(parent_style), Some(parent_style), Some(parent_style), diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index f92e22f4719b..d00751c2b330 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -4131,6 +4131,7 @@ fn get_pseudo_style( inputs, pseudo, &guards, + Some(styles.primary()), Some(inherited_styles), Some(element), ) @@ -5942,6 +5943,10 @@ pub extern "C" fn Servo_ReparentStyle( pseudo.as_ref(), inputs, &StylesheetGuards::same(&guard), + match element.is_some() && pseudo.is_some() { + true => Some(parent_style), + false => None, + }, Some(parent_style), Some(parent_style_ignoring_first_line), Some(layout_parent_style), diff --git a/testing/web-platform/meta/css/css-contain/container-queries/pseudo-elements-006.html.ini b/testing/web-platform/meta/css/css-contain/container-queries/pseudo-elements-006.html.ini index ef747cc22e72..56c90d405a4a 100644 --- a/testing/web-platform/meta/css/css-contain/container-queries/pseudo-elements-006.html.ini +++ b/testing/web-platform/meta/css/css-contain/container-queries/pseudo-elements-006.html.ini @@ -4,6 +4,3 @@ [Originating element container for ::marker] expected: FAIL - - [Originating element container for ::backdrop] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-contain/container-queries/pseudo-elements-007.html.ini b/testing/web-platform/meta/css/css-contain/container-queries/pseudo-elements-007.html.ini deleted file mode 100644 index 7bc801ef7ad1..000000000000 --- a/testing/web-platform/meta/css/css-contain/container-queries/pseudo-elements-007.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pseudo-elements-007.html] - [font-size for ::backdrop depending on container] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-contain/container-queries/pseudo-elements-008.html.ini b/testing/web-platform/meta/css/css-contain/container-queries/pseudo-elements-008.html.ini deleted file mode 100644 index 579a2c96323d..000000000000 --- a/testing/web-platform/meta/css/css-contain/container-queries/pseudo-elements-008.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pseudo-elements-008.html] - [Originating element container for ::backdrop] - expected: FAIL