mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Don't apply containing shadow-host rules to NAC.
This is a regression from bug 1487856. Differential Revision: https://phabricator.services.mozilla.com/D6700
This commit is contained in:
parent
426683cd4b
commit
2751df808b
1 changed files with 61 additions and 51 deletions
|
@ -1134,7 +1134,7 @@ impl Stylist {
|
||||||
|
|
||||||
let rule_hash_target = element.rule_hash_target();
|
let rule_hash_target = element.rule_hash_target();
|
||||||
|
|
||||||
let matches_user_rules = rule_hash_target.matches_user_and_author_rules();
|
let matches_user_and_author_rules = rule_hash_target.matches_user_and_author_rules();
|
||||||
|
|
||||||
// Normal user-agent rules.
|
// Normal user-agent rules.
|
||||||
if let Some(map) = self
|
if let Some(map) = self
|
||||||
|
@ -1162,7 +1162,7 @@ impl Stylist {
|
||||||
// rule_hash_target.matches_user_and_author_rules())
|
// rule_hash_target.matches_user_and_author_rules())
|
||||||
//
|
//
|
||||||
// Which may be more what you would probably expect.
|
// Which may be more what you would probably expect.
|
||||||
if matches_user_rules {
|
if matches_user_and_author_rules {
|
||||||
// User normal rules.
|
// User normal rules.
|
||||||
if let Some(map) = self.cascade_data.user.normal_rules(pseudo_element) {
|
if let Some(map) = self.cascade_data.user.normal_rules(pseudo_element) {
|
||||||
map.get_all_matching_rules(
|
map.get_all_matching_rules(
|
||||||
|
@ -1204,11 +1204,15 @@ impl Stylist {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut match_document_author_rules = matches_user_rules;
|
let mut match_document_author_rules = matches_user_and_author_rules;
|
||||||
let mut shadow_cascade_order = 0;
|
let mut shadow_cascade_order = 0;
|
||||||
|
|
||||||
// XBL / Shadow DOM rules, which are author rules too.
|
// XBL / Shadow DOM rules, which are author rules too.
|
||||||
if let Some(shadow) = rule_hash_target.shadow_root() {
|
if let Some(shadow) = rule_hash_target.shadow_root() {
|
||||||
|
debug_assert!(
|
||||||
|
matches_user_and_author_rules,
|
||||||
|
"NAC should not be a shadow host"
|
||||||
|
);
|
||||||
if let Some(map) = shadow
|
if let Some(map) = shadow
|
||||||
.style_data()
|
.style_data()
|
||||||
.and_then(|data| data.host_rules(pseudo_element))
|
.and_then(|data| data.host_rules(pseudo_element))
|
||||||
|
@ -1233,6 +1237,10 @@ impl Stylist {
|
||||||
let mut slots = SmallVec::<[_; 3]>::new();
|
let mut slots = SmallVec::<[_; 3]>::new();
|
||||||
let mut current = rule_hash_target.assigned_slot();
|
let mut current = rule_hash_target.assigned_slot();
|
||||||
while let Some(slot) = current {
|
while let Some(slot) = current {
|
||||||
|
debug_assert!(
|
||||||
|
matches_user_and_author_rules,
|
||||||
|
"We should not slot NAC anywhere"
|
||||||
|
);
|
||||||
slots.push(slot);
|
slots.push(slot);
|
||||||
current = slot.assigned_slot();
|
current = slot.assigned_slot();
|
||||||
}
|
}
|
||||||
|
@ -1258,55 +1266,57 @@ impl Stylist {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut current_containing_shadow = rule_hash_target.containing_shadow();
|
if matches_user_and_author_rules {
|
||||||
while let Some(containing_shadow) = current_containing_shadow {
|
let mut current_containing_shadow = rule_hash_target.containing_shadow();
|
||||||
let cascade_data = containing_shadow.style_data();
|
while let Some(containing_shadow) = current_containing_shadow {
|
||||||
let host = containing_shadow.host();
|
let cascade_data = containing_shadow.style_data();
|
||||||
if let Some(map) = cascade_data.and_then(|data| data.normal_rules(pseudo_element)) {
|
let host = containing_shadow.host();
|
||||||
context.with_shadow_host(Some(host), |context| {
|
if let Some(map) = cascade_data.and_then(|data| data.normal_rules(pseudo_element)) {
|
||||||
map.get_all_matching_rules(
|
context.with_shadow_host(Some(host), |context| {
|
||||||
element,
|
map.get_all_matching_rules(
|
||||||
rule_hash_target,
|
element,
|
||||||
applicable_declarations,
|
rule_hash_target,
|
||||||
context,
|
applicable_declarations,
|
||||||
flags_setter,
|
context,
|
||||||
CascadeLevel::SameTreeAuthorNormal,
|
flags_setter,
|
||||||
shadow_cascade_order,
|
CascadeLevel::SameTreeAuthorNormal,
|
||||||
);
|
shadow_cascade_order,
|
||||||
});
|
);
|
||||||
shadow_cascade_order += 1;
|
});
|
||||||
|
shadow_cascade_order += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
let host_is_svg_use_element =
|
||||||
|
host.is_svg_element() && host.local_name() == &*local_name!("use");
|
||||||
|
|
||||||
|
if !host_is_svg_use_element {
|
||||||
|
match_document_author_rules = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug_assert!(
|
||||||
|
cascade_data.is_none(),
|
||||||
|
"We allow no stylesheets in <svg:use> subtrees"
|
||||||
|
);
|
||||||
|
|
||||||
|
// NOTE(emilio): Hack so <svg:use> matches the rules of the
|
||||||
|
// enclosing tree.
|
||||||
|
//
|
||||||
|
// This is not a problem for invalidation and that kind of stuff
|
||||||
|
// because they still don't match rules based on elements
|
||||||
|
// outside of the shadow tree, and because the <svg:use>
|
||||||
|
// subtrees are immutable and recreated each time the source
|
||||||
|
// tree changes.
|
||||||
|
//
|
||||||
|
// We historically allow cross-document <svg:use> to have these
|
||||||
|
// rules applied, but I think that's not great. Gecko is the
|
||||||
|
// only engine supporting that.
|
||||||
|
//
|
||||||
|
// See https://github.com/w3c/svgwg/issues/504 for the relevant
|
||||||
|
// spec discussion.
|
||||||
|
current_containing_shadow = host.containing_shadow();
|
||||||
|
match_document_author_rules = current_containing_shadow.is_none();
|
||||||
}
|
}
|
||||||
|
|
||||||
let host_is_svg_use_element =
|
|
||||||
host.is_svg_element() && host.local_name() == &*local_name!("use");
|
|
||||||
|
|
||||||
if !host_is_svg_use_element {
|
|
||||||
match_document_author_rules = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug_assert!(
|
|
||||||
cascade_data.is_none(),
|
|
||||||
"We allow no stylesheets in <svg:use> subtrees"
|
|
||||||
);
|
|
||||||
|
|
||||||
// NOTE(emilio): Hack so <svg:use> matches the rules of the
|
|
||||||
// enclosing tree.
|
|
||||||
//
|
|
||||||
// This is not a problem for invalidation and that kind of stuff
|
|
||||||
// because they still don't match rules based on elements
|
|
||||||
// outside of the shadow tree, and because the <svg:use>
|
|
||||||
// subtrees are immutable and recreated each time the source
|
|
||||||
// tree changes.
|
|
||||||
//
|
|
||||||
// We historically allow cross-document <svg:use> to have these
|
|
||||||
// rules applied, but I think that's not great. Gecko is the
|
|
||||||
// only engine supporting that.
|
|
||||||
//
|
|
||||||
// See https://github.com/w3c/svgwg/issues/504 for the relevant
|
|
||||||
// spec discussion.
|
|
||||||
current_containing_shadow = host.containing_shadow();
|
|
||||||
match_document_author_rules = current_containing_shadow.is_none();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let cut_xbl_binding_inheritance =
|
let cut_xbl_binding_inheritance =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue