style/stylesheets/
starting_style_rule.rs1use crate::shared_lock::{DeepCloneWithLock, Locked};
9use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
10use crate::str::CssStringWriter;
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};
17
18#[derive(Debug, ToShmem)]
22pub struct StartingStyleRule {
23 pub rules: Arc<Locked<CssRules>>,
25 pub source_location: SourceLocation,
27}
28
29impl StartingStyleRule {
30 #[cfg(feature = "gecko")]
32 pub fn size_of(&self, guard: &SharedRwLockReadGuard, ops: &mut MallocSizeOfOps) -> usize {
33 self.rules.unconditional_shallow_size_of(ops)
34 + self.rules.read_with(guard).size_of(guard, ops)
35 }
36}
37
38impl ToCssWithGuard for StartingStyleRule {
39 fn to_css(&self, guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
40 dest.write_str("@starting-style")?;
41 self.rules.read_with(guard).to_css_block(guard, dest)
42 }
43}
44
45impl DeepCloneWithLock for StartingStyleRule {
46 fn deep_clone_with_lock(&self, lock: &SharedRwLock, guard: &SharedRwLockReadGuard) -> Self {
47 let rules = self.rules.read_with(guard);
48 StartingStyleRule {
49 rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
50 source_location: self.source_location.clone(),
51 }
52 }
53}