style/stylesheets/
starting_style_rule.rs1use crate::derives::*;
9use crate::shared_lock::{DeepCloneWithLock, Locked};
10use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
11use crate::stylesheets::CssRules;
12use cssparser::SourceLocation;
13#[cfg(feature = "gecko")]
14use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf};
15use servo_arc::Arc;
16use std::fmt::{self, Debug, Write};
17use style_traits::CssStringWriter;
18
19#[derive(Debug, ToShmem)]
23pub struct StartingStyleRule {
24 pub rules: Arc<Locked<CssRules>>,
26 pub source_location: SourceLocation,
28}
29
30impl StartingStyleRule {
31 #[cfg(feature = "gecko")]
33 pub fn size_of(&self, guard: &SharedRwLockReadGuard, ops: &mut MallocSizeOfOps) -> usize {
34 self.rules.unconditional_shallow_size_of(ops)
35 + self.rules.read_with(guard).size_of(guard, ops)
36 }
37}
38
39impl ToCssWithGuard for StartingStyleRule {
40 fn to_css(&self, guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
41 dest.write_str("@starting-style")?;
42 self.rules.read_with(guard).to_css_block(guard, dest)
43 }
44}
45
46impl DeepCloneWithLock for StartingStyleRule {
47 fn deep_clone_with_lock(&self, lock: &SharedRwLock, guard: &SharedRwLockReadGuard) -> Self {
48 let rules = self.rules.read_with(guard);
49 StartingStyleRule {
50 rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
51 source_location: self.source_location.clone(),
52 }
53 }
54}