Bug 1499603 - Clear host rules from clear_cascade_data. r=heycam

While at it, also measure them for about:memory.

Differential Revision: https://phabricator.services.mozilla.com/D8972

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2018-10-17 13:37:47 +00:00
parent fa11ed5377
commit 410243369d
2 changed files with 27 additions and 0 deletions

View File

@ -2415,6 +2415,9 @@ impl CascadeData {
if let Some(ref mut slotted_rules) = self.slotted_rules {
slotted_rules.clear();
}
if let Some(ref mut host_rules) = self.host_rules {
host_rules.clear();
}
self.animations.clear();
self.extra_data.clear();
self.rules_source_order = 0;
@ -2440,6 +2443,9 @@ impl CascadeData {
if let Some(ref slotted_rules) = self.slotted_rules {
slotted_rules.add_size_of(ops, sizes);
}
if let Some(ref host_rules) = self.host_rules {
host_rules.add_size_of(ops, sizes);
}
sizes.mInvalidationMap += self.invalidation_map.size_of(ops);
sizes.mRevalidationSelectors += self.selectors_for_cache_revalidation.size_of(ops);
sizes.mOther += self.animations.size_of(ops);

View File

@ -0,0 +1,21 @@
<!doctype html>
<title>CSS Test: Invalidation of :host selectors</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-scoping/#host-selector">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1499603">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="host" style="color: green"></div>
<script>
host.attachShadow({ mode: "open" }).innerHTML = `
<style>
:host { color: red !important }
</style>
`;
test(function() {
assert_equals(getComputedStyle(host).color, "rgb(255, 0, 0)");
host.shadowRoot.querySelector("style").remove();
assert_equals(getComputedStyle(host).color, "rgb(0, 128, 0)");
}, ":host rules are properly invalidated when stylesheets are removed");
</script>