mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +01:00
style: Move DocumentStyleSheet to style.
This commit is contained in:
parent
e60266a723
commit
02b203891f
3 changed files with 35 additions and 32 deletions
|
@ -7,6 +7,7 @@ use context::QuirksMode;
|
|||
use cssparser::{Parser, RuleListParser, ParserInput};
|
||||
use error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||
use fnv::FnvHashMap;
|
||||
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
||||
use media_queries::{MediaList, Device};
|
||||
use parking_lot::RwLock;
|
||||
use parser::ParserContext;
|
||||
|
@ -275,6 +276,37 @@ impl StylesheetInDocument for Stylesheet {
|
|||
}
|
||||
}
|
||||
|
||||
/// A simple wrapper over an `Arc<Stylesheet>`, with pointer comparison, and
|
||||
/// suitable for its use in a `StylesheetSet`.
|
||||
#[derive(Clone)]
|
||||
pub struct DocumentStyleSheet(pub Arc<Stylesheet>);
|
||||
|
||||
impl PartialEq for DocumentStyleSheet {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
Arc::ptr_eq(&self.0, &other.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToMediaListKey for DocumentStyleSheet {
|
||||
fn to_media_list_key(&self) -> MediaListKey {
|
||||
self.0.to_media_list_key()
|
||||
}
|
||||
}
|
||||
|
||||
impl StylesheetInDocument for DocumentStyleSheet {
|
||||
fn contents(&self, guard: &SharedRwLockReadGuard) -> &StylesheetContents {
|
||||
self.0.contents(guard)
|
||||
}
|
||||
|
||||
fn media<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> Option<&'a MediaList> {
|
||||
self.0.media(guard)
|
||||
}
|
||||
|
||||
fn enabled(&self) -> bool {
|
||||
self.0.enabled()
|
||||
}
|
||||
}
|
||||
|
||||
impl Stylesheet {
|
||||
/// Updates an empty stylesheet from a given string of text.
|
||||
pub fn update_from_str(existing: &Stylesheet,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue