mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 08:45:46 +00:00
Bug 1502893 - Don't match document author rules if not needed for revalidation. r=heycam,firefox-style-system-reviewers
When you're in a ShadowRoot and can share style with a sibling, the sharing code is smart enough to skip document author rules. But then it could get confused if you also include document rules, since revalidation selectors are matched against these. This is not a correctness issue, because we're matching more than what we need, and avoid sharing if we failed. Also fix the detection for user rules in any_applicable_rule_data. Differential Revision: https://phabricator.services.mozilla.com/D10117 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
ca98980366
commit
bb25a09e27
29
layout/style/crashtests/1502893.html
Normal file
29
layout/style/crashtests/1502893.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<style>
|
||||
#animate_0[onrepeat=''] {}
|
||||
</style>
|
||||
<animate id="animate_0" />
|
||||
<animate id="animate_1" />
|
||||
<script>
|
||||
window.CustomElement0 = class extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.attachShadow({
|
||||
mode: 'open'
|
||||
})
|
||||
}
|
||||
connectedCallback() {
|
||||
this.shadowRoot.prepend(o2)
|
||||
this.setAttribute('contenteditable', 'true')
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('custom-element-0', CustomElement0)
|
||||
o1 = document.createElement('custom-element-0')
|
||||
o2 = document.getElementById('animate_0')
|
||||
o3 = document.getElementById('animate_1')
|
||||
document.documentElement.appendChild(o1)
|
||||
document.replaceChild(document.documentElement, document.documentElement)
|
||||
o1.shadowRoot.prepend(o3)
|
||||
o3.offsetTop;
|
||||
</script>
|
@ -294,3 +294,4 @@ load 1475003.html
|
||||
load 1479681.html
|
||||
load 1488817.html
|
||||
load 1490012.html
|
||||
load 1502893.html
|
||||
|
@ -605,11 +605,11 @@ impl Stylist {
|
||||
maybe = maybe || f(&*data);
|
||||
});
|
||||
|
||||
if maybe || !doc_author_rules_apply {
|
||||
return maybe;
|
||||
if maybe || f(&self.cascade_data.user) {
|
||||
return true;
|
||||
}
|
||||
|
||||
f(&self.cascade_data.author) || f(&self.cascade_data.user)
|
||||
doc_author_rules_apply && f(&self.cascade_data.author)
|
||||
}
|
||||
|
||||
/// Computes the style for a given "precomputed" pseudo-element, taking the
|
||||
@ -1491,7 +1491,33 @@ impl Stylist {
|
||||
// the lookups, which means that the bitvecs are comparable. We verify
|
||||
// this in the caller by asserting that the bitvecs are same-length.
|
||||
let mut results = SmallBitVec::new();
|
||||
for (data, _) in self.cascade_data.iter_origins() {
|
||||
|
||||
let matches_document_rules =
|
||||
element.each_applicable_non_document_style_rule_data(|data, quirks_mode, host| {
|
||||
matching_context.with_shadow_host(host, |matching_context| {
|
||||
data.selectors_for_cache_revalidation.lookup(
|
||||
element,
|
||||
quirks_mode,
|
||||
|selector_and_hashes| {
|
||||
results.push(matches_selector(
|
||||
&selector_and_hashes.selector,
|
||||
selector_and_hashes.selector_offset,
|
||||
Some(&selector_and_hashes.hashes),
|
||||
&element,
|
||||
matching_context,
|
||||
flags_setter,
|
||||
));
|
||||
true
|
||||
},
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
for (data, origin) in self.cascade_data.iter_origins() {
|
||||
if origin == Origin::Author && !matches_document_rules {
|
||||
continue;
|
||||
}
|
||||
|
||||
data.selectors_for_cache_revalidation.lookup(
|
||||
element,
|
||||
self.quirks_mode,
|
||||
@ -1509,25 +1535,6 @@ impl Stylist {
|
||||
);
|
||||
}
|
||||
|
||||
element.each_applicable_non_document_style_rule_data(|data, quirks_mode, host| {
|
||||
matching_context.with_shadow_host(host, |matching_context| {
|
||||
data.selectors_for_cache_revalidation.lookup(
|
||||
element,
|
||||
quirks_mode,
|
||||
|selector_and_hashes| {
|
||||
results.push(matches_selector(
|
||||
&selector_and_hashes.selector,
|
||||
selector_and_hashes.selector_offset,
|
||||
Some(&selector_and_hashes.hashes),
|
||||
&element,
|
||||
matching_context,
|
||||
flags_setter,
|
||||
));
|
||||
true
|
||||
},
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
results
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user