1use style::media_queries::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(
29 &mut self,
30 device: Option<&Device>,
31 sheet: S,
32 guard: &SharedRwLockReadGuard,
33 ) {
34 let custom_media = &CustomMediaMap::default();
35 match self {
36 StylesheetSetRef::Author(set) => {
37 set.append_stylesheet(device, custom_media, sheet, guard)
38 },
39 StylesheetSetRef::Document(set) => {
40 set.append_stylesheet(device, custom_media, sheet, guard)
41 },
42 }
43 }
44
45 pub(crate) fn insert_stylesheet_before(
47 &mut self,
48 device: Option<&Device>,
49 sheet: S,
50 before_sheet: S,
51 guard: &SharedRwLockReadGuard,
52 ) {
53 let custom_media = &CustomMediaMap::default();
54 match self {
55 StylesheetSetRef::Author(set) => {
56 set.insert_stylesheet_before(device, custom_media, sheet, before_sheet, guard)
57 },
58 StylesheetSetRef::Document(set) => {
59 set.insert_stylesheet_before(device, custom_media, sheet, before_sheet, guard)
60 },
61 }
62 }
63
64 pub(crate) fn remove_stylesheet(
66 &mut self,
67 device: Option<&Device>,
68 sheet: S,
69 guard: &SharedRwLockReadGuard,
70 ) {
71 let custom_media = &CustomMediaMap::default();
72 match self {
73 StylesheetSetRef::Author(set) => {
74 set.remove_stylesheet(device, custom_media, sheet, guard)
75 },
76 StylesheetSetRef::Document(set) => {
77 set.remove_stylesheet(device, custom_media, sheet, guard)
78 },
79 }
80 }
81}