mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Add a no-op constructor of StyleSheetEntry, in preparation for more changes.
MozReview-Commit-ID: 6Kz0S7YYmFC Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
e1517d62af
commit
029ab24671
1 changed files with 13 additions and 4 deletions
|
@ -14,13 +14,22 @@ use stylesheets::{Origin, OriginSet, StylesheetInDocument};
|
||||||
/// Entry for a StylesheetSet. We don't bother creating a constructor, because
|
/// Entry for a StylesheetSet. We don't bother creating a constructor, because
|
||||||
/// there's no sensible defaults for the member variables.
|
/// there's no sensible defaults for the member variables.
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub struct StylesheetSetEntry<S>
|
struct StylesheetSetEntry<S>
|
||||||
where
|
where
|
||||||
S: StylesheetInDocument + PartialEq + 'static,
|
S: StylesheetInDocument + PartialEq + 'static,
|
||||||
{
|
{
|
||||||
sheet: S,
|
sheet: S,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<S> StylesheetSetEntry<S>
|
||||||
|
where
|
||||||
|
S: StylesheetInDocument + PartialEq + 'static,
|
||||||
|
{
|
||||||
|
fn new(sheet: S) -> Self {
|
||||||
|
Self { sheet }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A iterator over the stylesheets of a list of entries in the StylesheetSet.
|
/// A iterator over the stylesheets of a list of entries in the StylesheetSet.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct StylesheetIterator<'a, S>(slice::Iter<'a, StylesheetSetEntry<S>>)
|
pub struct StylesheetIterator<'a, S>(slice::Iter<'a, StylesheetSetEntry<S>>)
|
||||||
|
@ -119,7 +128,7 @@ where
|
||||||
debug!("StylesheetSet::append_stylesheet");
|
debug!("StylesheetSet::append_stylesheet");
|
||||||
self.remove_stylesheet_if_present(&sheet);
|
self.remove_stylesheet_if_present(&sheet);
|
||||||
self.collect_invalidations_for(device, &sheet, guard);
|
self.collect_invalidations_for(device, &sheet, guard);
|
||||||
self.entries.push(StylesheetSetEntry { sheet });
|
self.entries.push(StylesheetSetEntry::new(sheet));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prepend a new stylesheet to the current set.
|
/// Prepend a new stylesheet to the current set.
|
||||||
|
@ -132,7 +141,7 @@ where
|
||||||
debug!("StylesheetSet::prepend_stylesheet");
|
debug!("StylesheetSet::prepend_stylesheet");
|
||||||
self.remove_stylesheet_if_present(&sheet);
|
self.remove_stylesheet_if_present(&sheet);
|
||||||
self.collect_invalidations_for(device, &sheet, guard);
|
self.collect_invalidations_for(device, &sheet, guard);
|
||||||
self.entries.insert(0, StylesheetSetEntry { sheet });
|
self.entries.insert(0, StylesheetSetEntry::new(sheet));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert a given stylesheet before another stylesheet in the document.
|
/// Insert a given stylesheet before another stylesheet in the document.
|
||||||
|
@ -149,7 +158,7 @@ where
|
||||||
entry.sheet == before_sheet
|
entry.sheet == before_sheet
|
||||||
}).expect("`before_sheet` stylesheet not found");
|
}).expect("`before_sheet` stylesheet not found");
|
||||||
self.collect_invalidations_for(device, &sheet, guard);
|
self.collect_invalidations_for(device, &sheet, guard);
|
||||||
self.entries.insert(index, StylesheetSetEntry { sheet });
|
self.entries.insert(index, StylesheetSetEntry::new(sheet));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove a given stylesheet from the set.
|
/// Remove a given stylesheet from the set.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue