#![forbid(unsafe_code)]
use crate::properties::PropertyDeclarationBlock;
use crate::shared_lock::{Locked, SharedRwLockReadGuard};
use servo_arc::Arc;
use std::io::Write;
use std::ptr;
#[derive(Clone, Debug)]
pub struct StyleSource(Arc<Locked<PropertyDeclarationBlock>>);
impl PartialEq for StyleSource {
fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.0, &other.0)
}
}
impl StyleSource {
#[inline]
pub(super) fn key(&self) -> ptr::NonNull<()> {
self.0.raw_ptr()
}
#[inline]
pub fn from_declarations(decls: Arc<Locked<PropertyDeclarationBlock>>) -> Self {
Self(decls)
}
pub(super) fn dump<W: Write>(&self, guard: &SharedRwLockReadGuard, writer: &mut W) {
let _ = write!(writer, " -> {:?}", self.read(guard).declarations());
}
#[inline]
pub fn read<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> &'a PropertyDeclarationBlock {
self.0.read_with(guard)
}
#[inline]
pub fn get(&self) -> &Arc<Locked<PropertyDeclarationBlock>> {
&self.0
}
}