Struct style::stylesheets::StylesheetContents

source ·
pub struct StylesheetContents {
    pub rules: Arc<Locked<CssRules>>,
    pub origin: Origin,
    pub url_data: RwLock<UrlExtraData>,
    pub namespaces: RwLock<Namespaces>,
    pub quirks_mode: QuirksMode,
    pub source_map_url: RwLock<Option<String>>,
    pub source_url: RwLock<Option<String>>,
    _forbid_construction: (),
}
Expand description

The contents of a given stylesheet. This effectively maps to a StyleSheetInner in Gecko.

Fields§

§rules: Arc<Locked<CssRules>>

List of rules in the order they were found (important for cascading order)

§origin: Origin

The origin of this stylesheet.

§url_data: RwLock<UrlExtraData>

The url data this stylesheet should use.

§namespaces: RwLock<Namespaces>

The namespaces that apply to this stylesheet.

§quirks_mode: QuirksMode

The quirks mode of this stylesheet.

§source_map_url: RwLock<Option<String>>

This stylesheet’s source map URL.

§source_url: RwLock<Option<String>>

This stylesheet’s source URL.

§_forbid_construction: ()

We don’t want to allow construction outside of this file, to guarantee that all contents are created with Arc<>.

Implementations§

source§

impl StylesheetContents

source

pub fn from_str( css: &str, url_data: UrlExtraData, origin: Origin, shared_lock: &SharedRwLock, stylesheet_loader: Option<&dyn StylesheetLoader>, error_reporter: Option<&dyn ParseErrorReporter>, quirks_mode: QuirksMode, use_counters: Option<&UseCounters>, allow_import_rules: AllowImportRules, sanitization_data: Option<&mut SanitizationData>, ) -> Arc<Self>

Parse a given CSS string, with a given url-data, origin, and quirks mode.

source

pub fn from_data( rules: Arc<Locked<CssRules>>, origin: Origin, url_data: UrlExtraData, quirks_mode: QuirksMode, ) -> Arc<Self>

Creates a new StylesheetContents with the specified pre-parsed rules, origin, URL data, and quirks mode.

Since the rules have already been parsed, and the intention is that this function is used for read only User Agent style sheets, an empty namespace map is used, and the source map and source URLs are set to None.

An empty namespace map should be fine, as it is only used for parsing, not serialization of existing selectors. Since UA sheets are read only, we should never need the namespace map.

source

pub fn from_shared_data( rules: Arc<Locked<CssRules>>, origin: Origin, url_data: UrlExtraData, quirks_mode: QuirksMode, ) -> Arc<Self>

Same as above, but ensuring that the rules are static.

source

pub fn rules<'a, 'b: 'a>( &'a self, guard: &'b SharedRwLockReadGuard<'_>, ) -> &'a [CssRule]

Returns a reference to the list of rules.

Trait Implementations§

source§

impl Debug for StylesheetContents

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl DeepCloneWithLock for StylesheetContents

source§

fn deep_clone_with_lock( &self, lock: &SharedRwLock, guard: &SharedRwLockReadGuard<'_>, ) -> Self

Deep clones this object.
source§

impl ToMediaListKey for StylesheetContents

source§

fn to_media_list_key(&self) -> MediaListKey

Get a MediaListKey for this item. This key needs to uniquely identify the item.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T