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