style: Fix slotted invalidation.

This is a partial revert of
ce1d8cd232

If you're in a shadow tree, you may not be slotted but you still need to look at
the slotted rules, since a <slot> could be a descendant of yours.

Just use the same invalidation map everywhere, and remove complexity.

This means that we can do some extra work while trying to gather invalidation
if there are slotted rules, but I don't think it's a problem.

The test is ported from https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/fast/css/invalidation/slotted.html?l=1&rcl=58d68fdf783d7edde1c82a642e037464861f2787

Curiously, Blink fails the test as written, presumably because they don't flush
styles from getComputedStyle correctly (in their test they do via
updateStyleAndReturnAffectedElementCount), due to <slot>s not being in the flat
tree in their implementation.

Bug: 1429846
Reviewed-by: heycam
MozReview-Commit-ID: 6b7BQ6bGMgd
This commit is contained in:
Emilio Cobos Álvarez 2018-01-11 17:39:47 +01:00
parent 4f09987611
commit 7bdeeaa702
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 139 additions and 219 deletions

View file

@ -24,7 +24,7 @@ use selectors::matching::{MatchingContext, MatchingMode, VisitedHandlingMode};
use selectors::matching::matches_selector;
use smallvec::SmallVec;
use stylesheets::origin::{Origin, OriginSet};
use stylist::StyleRuleCascadeData;
use stylist::CascadeData;
#[derive(Debug, PartialEq)]
enum VisitedDependent {
@ -57,7 +57,7 @@ where
/// changes.
pub struct StateAndAttrInvalidationProcessor<'a, 'b: 'a, E: TElement> {
shared_context: &'a SharedStyleContext<'b>,
shadow_rule_datas: &'a [(AtomicRef<'b, StyleRuleCascadeData>, QuirksMode)],
shadow_rule_datas: &'a [(AtomicRef<'b, CascadeData>, QuirksMode)],
cut_off_inheritance: bool,
element: E,
data: &'a mut ElementData,
@ -68,7 +68,7 @@ impl<'a, 'b: 'a, E: TElement> StateAndAttrInvalidationProcessor<'a, 'b, E> {
/// Creates a new StateAndAttrInvalidationProcessor.
pub fn new(
shared_context: &'a SharedStyleContext<'b>,
shadow_rule_datas: &'a [(AtomicRef<'b, StyleRuleCascadeData>, QuirksMode)],
shadow_rule_datas: &'a [(AtomicRef<'b, CascadeData>, QuirksMode)],
cut_off_inheritance: bool,
element: E,
data: &'a mut ElementData,
@ -255,11 +255,11 @@ where
OriginSet::all()
};
self.shared_context.stylist.each_normal_rule_cascade_data(|cascade_data, origin| {
for (cascade_data, origin) in self.shared_context.stylist.iter_origins() {
if document_origins.contains(origin.into()) {
collector.collect_dependencies_in_invalidation_map(cascade_data.invalidation_map());
}
});
}
for &(ref data, quirks_mode) in self.shadow_rule_datas {
// FIXME(emilio): Replace with assert / remove when we figure