script/css/
stylesheet_set.rs1use style::device::Device;
6use style::shared_lock::SharedRwLockReadGuard;
7use style::stylesheet_set::{AuthorStylesheetSet, DocumentStylesheetSet};
8use style::stylesheets::{CustomMediaMap, StylesheetInDocument};
9
10pub(crate) enum StylesheetSetRef<'a, S>
12where
13 S: StylesheetInDocument + PartialEq + 'static,
14{
15 Author(&'a mut AuthorStylesheetSet<S>),
17 Document(&'a mut DocumentStylesheetSet<S>),
19}
20
21impl<S> StylesheetSetRef<'_, S>
22where
23 S: StylesheetInDocument + PartialEq + 'static,
24{
25 pub(crate) fn append_stylesheet(&mut self, sheet: S, guard: &SharedRwLockReadGuard) {
29 match self {
30 StylesheetSetRef::Author(set) => set.append_stylesheet(sheet, guard),
31 StylesheetSetRef::Document(set) => set.append_stylesheet(sheet, guard),
32 }
33 }
34
35 pub(crate) fn insert_stylesheet_before(
37 &mut self,
38 sheet: S,
39 before_sheet: S,
40 guard: &SharedRwLockReadGuard,
41 ) {
42 match self {
43 StylesheetSetRef::Author(set) => {
44 set.insert_stylesheet_before(sheet, before_sheet, guard)
45 },
46 StylesheetSetRef::Document(set) => {
47 set.insert_stylesheet_before(sheet, before_sheet, guard)
48 },
49 }
50 }
51
52 pub(crate) fn remove_stylesheet(
54 &mut self,
55 device: Option<&Device>,
56 sheet: S,
57 guard: &SharedRwLockReadGuard,
58 ) {
59 let custom_media = &CustomMediaMap::default();
60 match self {
61 StylesheetSetRef::Author(set) => {
62 set.remove_stylesheet(device, custom_media, sheet, guard)
63 },
64 StylesheetSetRef::Document(set) => {
65 set.remove_stylesheet(device, custom_media, sheet, guard)
66 },
67 }
68 }
69}