style/
context.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5//! The context within which style is calculated.
6
7#[cfg(feature = "servo")]
8use crate::animation::DocumentAnimationSet;
9use crate::bloom::StyleBloom;
10use crate::computed_value_flags::ComputedValueFlags;
11use crate::data::{EagerPseudoStyles, ElementData};
12use crate::dom::{SendElement, TElement};
13#[cfg(feature = "gecko")]
14use crate::gecko_bindings::structs;
15use crate::parallel::{STACK_SAFETY_MARGIN_KB, STYLE_THREAD_STACK_SIZE_KB};
16use crate::properties::ComputedValues;
17#[cfg(feature = "servo")]
18use crate::properties::PropertyId;
19use crate::rule_cache::RuleCache;
20use crate::rule_tree::StrongRuleNode;
21use crate::selector_parser::{SnapshotMap, EAGER_PSEUDO_COUNT};
22use crate::shared_lock::StylesheetGuards;
23use crate::sharing::StyleSharingCache;
24use crate::stylist::Stylist;
25use crate::thread_state::{self, ThreadState};
26use crate::traversal::DomTraversal;
27use crate::traversal_flags::TraversalFlags;
28use app_units::Au;
29use euclid::default::Size2D;
30use euclid::Scale;
31#[cfg(feature = "servo")]
32use fxhash::FxHashMap;
33use selectors::context::SelectorCaches;
34#[cfg(feature = "gecko")]
35use servo_arc::Arc;
36#[cfg(feature = "servo")]
37use stylo_atoms::Atom;
38use std::fmt;
39use std::ops;
40use std::time::{Duration, Instant};
41use style_traits::CSSPixel;
42use style_traits::DevicePixel;
43#[cfg(feature = "servo")]
44use style_traits::SpeculativePainter;
45
46pub use selectors::matching::QuirksMode;
47
48/// A global options structure for the style system. We use this instead of
49/// opts to abstract across Gecko and Servo.
50#[derive(Clone)]
51pub struct StyleSystemOptions {
52    /// Whether the style sharing cache is disabled.
53    pub disable_style_sharing_cache: bool,
54    /// Whether we should dump statistics about the style system.
55    pub dump_style_statistics: bool,
56    /// The minimum number of elements that must be traversed to trigger a dump
57    /// of style statistics.
58    pub style_statistics_threshold: usize,
59}
60
61#[cfg(feature = "gecko")]
62fn get_env_bool(name: &str) -> bool {
63    use std::env;
64    match env::var(name) {
65        Ok(s) => !s.is_empty(),
66        Err(_) => false,
67    }
68}
69
70const DEFAULT_STATISTICS_THRESHOLD: usize = 50;
71
72#[cfg(feature = "gecko")]
73fn get_env_usize(name: &str) -> Option<usize> {
74    use std::env;
75    env::var(name).ok().map(|s| {
76        s.parse::<usize>()
77            .expect("Couldn't parse environmental variable as usize")
78    })
79}
80
81/// A global variable holding the state of
82/// `StyleSystemOptions::default().disable_style_sharing_cache`.
83/// See [#22854](https://github.com/servo/servo/issues/22854).
84#[cfg(feature = "servo")]
85pub static DEFAULT_DISABLE_STYLE_SHARING_CACHE: std::sync::atomic::AtomicBool =
86    std::sync::atomic::AtomicBool::new(false);
87
88/// A global variable holding the state of
89/// `StyleSystemOptions::default().dump_style_statistics`.
90/// See [#22854](https://github.com/servo/servo/issues/22854).
91#[cfg(feature = "servo")]
92pub static DEFAULT_DUMP_STYLE_STATISTICS: std::sync::atomic::AtomicBool =
93    std::sync::atomic::AtomicBool::new(false);
94
95impl Default for StyleSystemOptions {
96    #[cfg(feature = "servo")]
97    fn default() -> Self {
98        use std::sync::atomic::Ordering;
99
100        StyleSystemOptions {
101            disable_style_sharing_cache: DEFAULT_DISABLE_STYLE_SHARING_CACHE
102                .load(Ordering::Relaxed),
103            dump_style_statistics: DEFAULT_DUMP_STYLE_STATISTICS.load(Ordering::Relaxed),
104            style_statistics_threshold: DEFAULT_STATISTICS_THRESHOLD,
105        }
106    }
107
108    #[cfg(feature = "gecko")]
109    fn default() -> Self {
110        StyleSystemOptions {
111            disable_style_sharing_cache: get_env_bool("DISABLE_STYLE_SHARING_CACHE"),
112            dump_style_statistics: get_env_bool("DUMP_STYLE_STATISTICS"),
113            style_statistics_threshold: get_env_usize("STYLE_STATISTICS_THRESHOLD")
114                .unwrap_or(DEFAULT_STATISTICS_THRESHOLD),
115        }
116    }
117}
118
119/// A shared style context.
120///
121/// There's exactly one of these during a given restyle traversal, and it's
122/// shared among the worker threads.
123pub struct SharedStyleContext<'a> {
124    /// The CSS selector stylist.
125    pub stylist: &'a Stylist,
126
127    /// Whether visited styles are enabled.
128    ///
129    /// They may be disabled when Gecko's pref layout.css.visited_links_enabled
130    /// is false, or when in private browsing mode.
131    pub visited_styles_enabled: bool,
132
133    /// Configuration options.
134    pub options: StyleSystemOptions,
135
136    /// Guards for pre-acquired locks
137    pub guards: StylesheetGuards<'a>,
138
139    /// The current time for transitions and animations. This is needed to ensure
140    /// a consistent sampling time and also to adjust the time for testing.
141    pub current_time_for_animations: f64,
142
143    /// Flags controlling how we traverse the tree.
144    pub traversal_flags: TraversalFlags,
145
146    /// A map with our snapshots in order to handle restyle hints.
147    pub snapshot_map: &'a SnapshotMap,
148
149    /// The state of all animations for our styled elements.
150    #[cfg(feature = "servo")]
151    pub animations: DocumentAnimationSet,
152
153    /// Paint worklets
154    #[cfg(feature = "servo")]
155    pub registered_speculative_painters: &'a dyn RegisteredSpeculativePainters,
156}
157
158impl<'a> SharedStyleContext<'a> {
159    /// Return a suitable viewport size in order to be used for viewport units.
160    pub fn viewport_size(&self) -> Size2D<Au> {
161        self.stylist.device().au_viewport_size()
162    }
163
164    /// The device pixel ratio
165    pub fn device_pixel_ratio(&self) -> Scale<f32, CSSPixel, DevicePixel> {
166        self.stylist.device().device_pixel_ratio()
167    }
168
169    /// The quirks mode of the document.
170    pub fn quirks_mode(&self) -> QuirksMode {
171        self.stylist.quirks_mode()
172    }
173}
174
175/// The structure holds various intermediate inputs that are eventually used by
176/// by the cascade.
177///
178/// The matching and cascading process stores them in this format temporarily
179/// within the `CurrentElementInfo`. At the end of the cascade, they are folded
180/// down into the main `ComputedValues` to reduce memory usage per element while
181/// still remaining accessible.
182#[derive(Clone, Debug, Default)]
183pub struct CascadeInputs {
184    /// The rule node representing the ordered list of rules matched for this
185    /// node.
186    pub rules: Option<StrongRuleNode>,
187
188    /// The rule node representing the ordered list of rules matched for this
189    /// node if visited, only computed if there's a relevant link for this
190    /// element. A element's "relevant link" is the element being matched if it
191    /// is a link or the nearest ancestor link.
192    pub visited_rules: Option<StrongRuleNode>,
193
194    /// The set of flags from container queries that we need for invalidation.
195    pub flags: ComputedValueFlags,
196}
197
198impl CascadeInputs {
199    /// Construct inputs from previous cascade results, if any.
200    pub fn new_from_style(style: &ComputedValues) -> Self {
201        Self {
202            rules: style.rules.clone(),
203            visited_rules: style.visited_style().and_then(|v| v.rules.clone()),
204            flags: style.flags.for_cascade_inputs(),
205        }
206    }
207}
208
209/// A list of cascade inputs for eagerly-cascaded pseudo-elements.
210/// The list is stored inline.
211#[derive(Debug)]
212pub struct EagerPseudoCascadeInputs(Option<[Option<CascadeInputs>; EAGER_PSEUDO_COUNT]>);
213
214// Manually implement `Clone` here because the derived impl of `Clone` for
215// array types assumes the value inside is `Copy`.
216impl Clone for EagerPseudoCascadeInputs {
217    fn clone(&self) -> Self {
218        if self.0.is_none() {
219            return EagerPseudoCascadeInputs(None);
220        }
221        let self_inputs = self.0.as_ref().unwrap();
222        let mut inputs: [Option<CascadeInputs>; EAGER_PSEUDO_COUNT] = Default::default();
223        for i in 0..EAGER_PSEUDO_COUNT {
224            inputs[i] = self_inputs[i].clone();
225        }
226        EagerPseudoCascadeInputs(Some(inputs))
227    }
228}
229
230impl EagerPseudoCascadeInputs {
231    /// Construct inputs from previous cascade results, if any.
232    fn new_from_style(styles: &EagerPseudoStyles) -> Self {
233        EagerPseudoCascadeInputs(styles.as_optional_array().map(|styles| {
234            let mut inputs: [Option<CascadeInputs>; EAGER_PSEUDO_COUNT] = Default::default();
235            for i in 0..EAGER_PSEUDO_COUNT {
236                inputs[i] = styles[i].as_ref().map(|s| CascadeInputs::new_from_style(s));
237            }
238            inputs
239        }))
240    }
241
242    /// Returns the list of rules, if they exist.
243    pub fn into_array(self) -> Option<[Option<CascadeInputs>; EAGER_PSEUDO_COUNT]> {
244        self.0
245    }
246}
247
248/// The cascade inputs associated with a node, including those for any
249/// pseudo-elements.
250///
251/// The matching and cascading process stores them in this format temporarily
252/// within the `CurrentElementInfo`. At the end of the cascade, they are folded
253/// down into the main `ComputedValues` to reduce memory usage per element while
254/// still remaining accessible.
255#[derive(Clone, Debug)]
256pub struct ElementCascadeInputs {
257    /// The element's cascade inputs.
258    pub primary: CascadeInputs,
259    /// A list of the inputs for the element's eagerly-cascaded pseudo-elements.
260    pub pseudos: EagerPseudoCascadeInputs,
261}
262
263impl ElementCascadeInputs {
264    /// Construct inputs from previous cascade results, if any.
265    #[inline]
266    pub fn new_from_element_data(data: &ElementData) -> Self {
267        debug_assert!(data.has_styles());
268        ElementCascadeInputs {
269            primary: CascadeInputs::new_from_style(data.styles.primary()),
270            pseudos: EagerPseudoCascadeInputs::new_from_style(&data.styles.pseudos),
271        }
272    }
273}
274
275/// Statistics gathered during the traversal. We gather statistics on each
276/// thread and then combine them after the threads join via the Add
277/// implementation below.
278#[derive(AddAssign, Clone, Default)]
279pub struct PerThreadTraversalStatistics {
280    /// The total number of elements traversed.
281    pub elements_traversed: u32,
282    /// The number of elements where has_styles() went from false to true.
283    pub elements_styled: u32,
284    /// The number of elements for which we performed selector matching.
285    pub elements_matched: u32,
286    /// The number of cache hits from the StyleSharingCache.
287    pub styles_shared: u32,
288    /// The number of styles reused via rule node comparison from the
289    /// StyleSharingCache.
290    pub styles_reused: u32,
291}
292
293/// Statistics gathered during the traversal plus some information from
294/// other sources including stylist.
295#[derive(Default)]
296pub struct TraversalStatistics {
297    /// Aggregated statistics gathered during the traversal.
298    pub aggregated: PerThreadTraversalStatistics,
299    /// The number of selectors in the stylist.
300    pub selectors: u32,
301    /// The number of revalidation selectors.
302    pub revalidation_selectors: u32,
303    /// The number of state/attr dependencies in the dependency set.
304    pub dependency_selectors: u32,
305    /// The number of declarations in the stylist.
306    pub declarations: u32,
307    /// The number of times the stylist was rebuilt.
308    pub stylist_rebuilds: u32,
309    /// Time spent in the traversal, in milliseconds.
310    pub traversal_time: Duration,
311    /// Whether this was a parallel traversal.
312    pub is_parallel: bool,
313    /// Whether this is a "large" traversal.
314    pub is_large: bool,
315}
316
317/// Format the statistics in a way that the performance test harness understands.
318/// See https://bugzilla.mozilla.org/show_bug.cgi?id=1331856#c2
319impl fmt::Display for TraversalStatistics {
320    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
321        writeln!(f, "[PERF] perf block start")?;
322        writeln!(
323            f,
324            "[PERF],traversal,{}",
325            if self.is_parallel {
326                "parallel"
327            } else {
328                "sequential"
329            }
330        )?;
331        writeln!(
332            f,
333            "[PERF],elements_traversed,{}",
334            self.aggregated.elements_traversed
335        )?;
336        writeln!(
337            f,
338            "[PERF],elements_styled,{}",
339            self.aggregated.elements_styled
340        )?;
341        writeln!(
342            f,
343            "[PERF],elements_matched,{}",
344            self.aggregated.elements_matched
345        )?;
346        writeln!(f, "[PERF],styles_shared,{}", self.aggregated.styles_shared)?;
347        writeln!(f, "[PERF],styles_reused,{}", self.aggregated.styles_reused)?;
348        writeln!(f, "[PERF],selectors,{}", self.selectors)?;
349        writeln!(
350            f,
351            "[PERF],revalidation_selectors,{}",
352            self.revalidation_selectors
353        )?;
354        writeln!(
355            f,
356            "[PERF],dependency_selectors,{}",
357            self.dependency_selectors
358        )?;
359        writeln!(f, "[PERF],declarations,{}", self.declarations)?;
360        writeln!(f, "[PERF],stylist_rebuilds,{}", self.stylist_rebuilds)?;
361        writeln!(f, "[PERF],traversal_time_ms,{}", self.traversal_time.as_secs_f64() * 1000.)?;
362        writeln!(f, "[PERF] perf block end")
363    }
364}
365
366impl TraversalStatistics {
367    /// Generate complete traversal statistics.
368    ///
369    /// The traversal time is computed given the start time in seconds.
370    pub fn new<E, D>(
371        aggregated: PerThreadTraversalStatistics,
372        traversal: &D,
373        parallel: bool,
374        start: Instant,
375    ) -> TraversalStatistics
376    where
377        E: TElement,
378        D: DomTraversal<E>,
379    {
380        let threshold = traversal
381            .shared_context()
382            .options
383            .style_statistics_threshold;
384        let stylist = traversal.shared_context().stylist;
385        let is_large = aggregated.elements_traversed as usize >= threshold;
386        TraversalStatistics {
387            aggregated,
388            selectors: stylist.num_selectors() as u32,
389            revalidation_selectors: stylist.num_revalidation_selectors() as u32,
390            dependency_selectors: stylist.num_invalidations() as u32,
391            declarations: stylist.num_declarations() as u32,
392            stylist_rebuilds: stylist.num_rebuilds() as u32,
393            traversal_time: Instant::now() - start,
394            is_parallel: parallel,
395            is_large,
396        }
397    }
398}
399
400#[cfg(feature = "gecko")]
401bitflags! {
402    /// Represents which tasks are performed in a SequentialTask of
403    /// UpdateAnimations which is a result of normal restyle.
404    pub struct UpdateAnimationsTasks: u8 {
405        /// Update CSS Animations.
406        const CSS_ANIMATIONS = structs::UpdateAnimationsTasks_CSSAnimations;
407        /// Update CSS Transitions.
408        const CSS_TRANSITIONS = structs::UpdateAnimationsTasks_CSSTransitions;
409        /// Update effect properties.
410        const EFFECT_PROPERTIES = structs::UpdateAnimationsTasks_EffectProperties;
411        /// Update animation cacade results for animations running on the compositor.
412        const CASCADE_RESULTS = structs::UpdateAnimationsTasks_CascadeResults;
413        /// Display property was changed from none.
414        /// Script animations keep alive on display:none elements, so we need to trigger
415        /// the second animation restyles for the script animations in the case where
416        /// the display property was changed from 'none' to others.
417        const DISPLAY_CHANGED_FROM_NONE = structs::UpdateAnimationsTasks_DisplayChangedFromNone;
418        /// Update CSS named scroll progress timelines.
419        const SCROLL_TIMELINES = structs::UpdateAnimationsTasks_ScrollTimelines;
420        /// Update CSS named view progress timelines.
421        const VIEW_TIMELINES = structs::UpdateAnimationsTasks_ViewTimelines;
422    }
423}
424
425/// A task to be run in sequential mode on the parent (non-worker) thread. This
426/// is used by the style system to queue up work which is not safe to do during
427/// the parallel traversal.
428pub enum SequentialTask<E: TElement> {
429    /// Entry to avoid an unused type parameter error on servo.
430    Unused(SendElement<E>),
431
432    /// Performs one of a number of possible tasks related to updating
433    /// animations based on the |tasks| field. These include updating CSS
434    /// animations/transitions that changed as part of the non-animation style
435    /// traversal, and updating the computed effect properties.
436    #[cfg(feature = "gecko")]
437    UpdateAnimations {
438        /// The target element or pseudo-element.
439        el: SendElement<E>,
440        /// The before-change style for transitions. We use before-change style
441        /// as the initial value of its Keyframe. Required if |tasks| includes
442        /// CSSTransitions.
443        before_change_style: Option<Arc<ComputedValues>>,
444        /// The tasks which are performed in this SequentialTask.
445        tasks: UpdateAnimationsTasks,
446    },
447}
448
449impl<E: TElement> SequentialTask<E> {
450    /// Executes this task.
451    pub fn execute(self) {
452        use self::SequentialTask::*;
453        debug_assert!(thread_state::get().contains(ThreadState::LAYOUT));
454        match self {
455            Unused(_) => unreachable!(),
456            #[cfg(feature = "gecko")]
457            UpdateAnimations {
458                el,
459                before_change_style,
460                tasks,
461            } => {
462                el.update_animations(before_change_style, tasks);
463            },
464        }
465    }
466
467    /// Creates a task to update various animation-related state on a given
468    /// (pseudo-)element.
469    #[cfg(feature = "gecko")]
470    pub fn update_animations(
471        el: E,
472        before_change_style: Option<Arc<ComputedValues>>,
473        tasks: UpdateAnimationsTasks,
474    ) -> Self {
475        use self::SequentialTask::*;
476        UpdateAnimations {
477            el: unsafe { SendElement::new(el) },
478            before_change_style,
479            tasks,
480        }
481    }
482}
483
484/// A list of SequentialTasks that get executed on Drop.
485pub struct SequentialTaskList<E>(Vec<SequentialTask<E>>)
486where
487    E: TElement;
488
489impl<E> ops::Deref for SequentialTaskList<E>
490where
491    E: TElement,
492{
493    type Target = Vec<SequentialTask<E>>;
494
495    fn deref(&self) -> &Self::Target {
496        &self.0
497    }
498}
499
500impl<E> ops::DerefMut for SequentialTaskList<E>
501where
502    E: TElement,
503{
504    fn deref_mut(&mut self) -> &mut Self::Target {
505        &mut self.0
506    }
507}
508
509impl<E> Drop for SequentialTaskList<E>
510where
511    E: TElement,
512{
513    fn drop(&mut self) {
514        debug_assert!(thread_state::get().contains(ThreadState::LAYOUT));
515        for task in self.0.drain(..) {
516            task.execute()
517        }
518    }
519}
520
521/// A helper type for stack limit checking.  This assumes that stacks grow
522/// down, which is true for all non-ancient CPU architectures.
523pub struct StackLimitChecker {
524    lower_limit: usize,
525}
526
527impl StackLimitChecker {
528    /// Create a new limit checker, for this thread, allowing further use
529    /// of up to |stack_size| bytes beyond (below) the current stack pointer.
530    #[inline(never)]
531    pub fn new(stack_size_limit: usize) -> Self {
532        StackLimitChecker {
533            lower_limit: StackLimitChecker::get_sp() - stack_size_limit,
534        }
535    }
536
537    /// Checks whether the previously stored stack limit has now been exceeded.
538    #[inline(never)]
539    pub fn limit_exceeded(&self) -> bool {
540        let curr_sp = StackLimitChecker::get_sp();
541
542        // Do some sanity-checking to ensure that our invariants hold, even in
543        // the case where we've exceeded the soft limit.
544        //
545        // The correctness of depends on the assumption that no stack wraps
546        // around the end of the address space.
547        if cfg!(debug_assertions) {
548            // Compute the actual bottom of the stack by subtracting our safety
549            // margin from our soft limit. Note that this will be slightly below
550            // the actual bottom of the stack, because there are a few initial
551            // frames on the stack before we do the measurement that computes
552            // the limit.
553            let stack_bottom = self.lower_limit - STACK_SAFETY_MARGIN_KB * 1024;
554
555            // The bottom of the stack should be below the current sp. If it
556            // isn't, that means we've either waited too long to check the limit
557            // and burned through our safety margin (in which case we probably
558            // would have segfaulted by now), or we're using a limit computed for
559            // a different thread.
560            debug_assert!(stack_bottom < curr_sp);
561
562            // Compute the distance between the current sp and the bottom of
563            // the stack, and compare it against the current stack. It should be
564            // no further from us than the total stack size. We allow some slop
565            // to handle the fact that stack_bottom is a bit further than the
566            // bottom of the stack, as discussed above.
567            let distance_to_stack_bottom = curr_sp - stack_bottom;
568            let max_allowable_distance = (STYLE_THREAD_STACK_SIZE_KB + 10) * 1024;
569            debug_assert!(distance_to_stack_bottom <= max_allowable_distance);
570        }
571
572        // The actual bounds check.
573        curr_sp <= self.lower_limit
574    }
575
576    // Technically, rustc can optimize this away, but shouldn't for now.
577    // We should fix this once black_box is stable.
578    #[inline(always)]
579    fn get_sp() -> usize {
580        let mut foo: usize = 42;
581        (&mut foo as *mut usize) as usize
582    }
583}
584
585/// A thread-local style context.
586///
587/// This context contains data that needs to be used during restyling, but is
588/// not required to be unique among worker threads, so we create one per worker
589/// thread in order to be able to mutate it without locking.
590pub struct ThreadLocalStyleContext<E: TElement> {
591    /// A cache to share style among siblings.
592    pub sharing_cache: StyleSharingCache<E>,
593    /// A cache from matched properties to elements that match those.
594    pub rule_cache: RuleCache,
595    /// The bloom filter used to fast-reject selector-matching.
596    pub bloom_filter: StyleBloom<E>,
597    /// A set of tasks to be run (on the parent thread) in sequential mode after
598    /// the rest of the styling is complete. This is useful for
599    /// infrequently-needed non-threadsafe operations.
600    ///
601    /// It's important that goes after the style sharing cache and the bloom
602    /// filter, to ensure they're dropped before we execute the tasks, which
603    /// could create another ThreadLocalStyleContext for style computation.
604    pub tasks: SequentialTaskList<E>,
605    /// Statistics about the traversal.
606    pub statistics: PerThreadTraversalStatistics,
607    /// A checker used to ensure that parallel.rs does not recurse indefinitely
608    /// even on arbitrarily deep trees.  See Gecko bug 1376883.
609    pub stack_limit_checker: StackLimitChecker,
610    /// Collection of caches (And cache-likes) for speeding up expensive selector matches.
611    pub selector_caches: SelectorCaches,
612}
613
614impl<E: TElement> ThreadLocalStyleContext<E> {
615    /// Creates a new `ThreadLocalStyleContext`
616    pub fn new() -> Self {
617        ThreadLocalStyleContext {
618            sharing_cache: StyleSharingCache::new(),
619            rule_cache: RuleCache::new(),
620            bloom_filter: StyleBloom::new(),
621            tasks: SequentialTaskList(Vec::new()),
622            statistics: PerThreadTraversalStatistics::default(),
623            stack_limit_checker: StackLimitChecker::new(
624                (STYLE_THREAD_STACK_SIZE_KB - STACK_SAFETY_MARGIN_KB) * 1024,
625            ),
626            selector_caches: SelectorCaches::default(),
627        }
628    }
629}
630
631/// A `StyleContext` is just a simple container for a immutable reference to a
632/// shared style context, and a mutable reference to a local one.
633pub struct StyleContext<'a, E: TElement + 'a> {
634    /// The shared style context reference.
635    pub shared: &'a SharedStyleContext<'a>,
636    /// The thread-local style context (mutable) reference.
637    pub thread_local: &'a mut ThreadLocalStyleContext<E>,
638}
639
640/// A registered painter
641#[cfg(feature = "servo")]
642pub trait RegisteredSpeculativePainter: SpeculativePainter {
643    /// The name it was registered with
644    fn name(&self) -> Atom;
645    /// The properties it was registered with
646    fn properties(&self) -> &FxHashMap<Atom, PropertyId>;
647}
648
649/// A set of registered painters
650#[cfg(feature = "servo")]
651pub trait RegisteredSpeculativePainters: Sync {
652    /// Look up a speculative painter
653    fn get(&self, name: &Atom) -> Option<&dyn RegisteredSpeculativePainter>;
654}