use style::media_queries::Device;
use style::shared_lock::SharedRwLockReadGuard;
use style::stylesheet_set::{AuthorStylesheetSet, DocumentStylesheetSet};
use style::stylesheets::StylesheetInDocument;
pub enum StylesheetSetRef<'a, S>
where
S: StylesheetInDocument + PartialEq + 'static,
{
Author(&'a mut AuthorStylesheetSet<S>),
Document(&'a mut DocumentStylesheetSet<S>),
}
impl<'a, S> StylesheetSetRef<'a, S>
where
S: StylesheetInDocument + PartialEq + 'static,
{
pub fn append_stylesheet(
&mut self,
device: Option<&Device>,
sheet: S,
guard: &SharedRwLockReadGuard,
) {
match self {
StylesheetSetRef::Author(set) => set.append_stylesheet(device, sheet, guard),
StylesheetSetRef::Document(set) => set.append_stylesheet(device, sheet, guard),
}
}
pub fn insert_stylesheet_before(
&mut self,
device: Option<&Device>,
sheet: S,
before_sheet: S,
guard: &SharedRwLockReadGuard,
) {
match self {
StylesheetSetRef::Author(set) => {
set.insert_stylesheet_before(device, sheet, before_sheet, guard)
},
StylesheetSetRef::Document(set) => {
set.insert_stylesheet_before(device, sheet, before_sheet, guard)
},
}
}
pub fn remove_stylesheet(
&mut self,
device: Option<&Device>,
sheet: S,
guard: &SharedRwLockReadGuard,
) {
match self {
StylesheetSetRef::Author(set) => set.remove_stylesheet(device, sheet, guard),
StylesheetSetRef::Document(set) => set.remove_stylesheet(device, sheet, guard),
}
}
}