style/stylesheets/
nested_declarations_rule.rs1use crate::properties::PropertyDeclarationBlock;
9use crate::shared_lock::{
10 DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
11};
12use crate::str::CssStringWriter;
13use cssparser::SourceLocation;
14use malloc_size_of::{MallocSizeOf, MallocSizeOfOps, MallocUnconditionalShallowSizeOf};
15use servo_arc::Arc;
16
17#[derive(Clone, Debug, ToShmem)]
19pub struct NestedDeclarationsRule {
20 pub block: Arc<Locked<PropertyDeclarationBlock>>,
22 pub source_location: SourceLocation,
24}
25
26impl NestedDeclarationsRule {
27 pub fn size_of(&self, guard: &SharedRwLockReadGuard, ops: &mut MallocSizeOfOps) -> usize {
29 self.block.unconditional_shallow_size_of(ops) + self.block.read_with(guard).size_of(ops)
30 }
31}
32
33impl DeepCloneWithLock for NestedDeclarationsRule {
34 fn deep_clone_with_lock(&self, lock: &SharedRwLock, guard: &SharedRwLockReadGuard) -> Self {
35 Self {
36 block: Arc::new(lock.wrap(self.block.read_with(&guard).clone())),
37 source_location: self.source_location.clone(),
38 }
39 }
40}
41
42impl ToCssWithGuard for NestedDeclarationsRule {
43 fn to_css(
44 &self,
45 guard: &SharedRwLockReadGuard,
46 dest: &mut CssStringWriter,
47 ) -> std::fmt::Result {
48 self.block.read_with(guard).to_css(dest)
49 }
50}