mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
style: Add FFI API to create a StyleSheet backed by shared data.
Differential Revision: https://phabricator.services.mozilla.com/D17199
This commit is contained in:
parent
7aac260c5d
commit
debd837bf0
1 changed files with 28 additions and 0 deletions
|
@ -107,6 +107,34 @@ impl StylesheetContents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
pub fn from_shared_data(
|
||||||
|
rules: Arc<Locked<CssRules>>,
|
||||||
|
origin: Origin,
|
||||||
|
url_data: UrlExtraData,
|
||||||
|
quirks_mode: QuirksMode,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
rules,
|
||||||
|
origin,
|
||||||
|
url_data: RwLock::new(url_data),
|
||||||
|
namespaces: RwLock::new(Namespaces::default()),
|
||||||
|
quirks_mode,
|
||||||
|
source_map_url: RwLock::new(None),
|
||||||
|
source_url: RwLock::new(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a reference to the list of rules.
|
/// Returns a reference to the list of rules.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn rules<'a, 'b: 'a>(&'a self, guard: &'b SharedRwLockReadGuard) -> &'a [CssRule] {
|
pub fn rules<'a, 'b: 'a>(&'a self, guard: &'b SharedRwLockReadGuard) -> &'a [CssRule] {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue