mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add an extra data field to ParserContext.
This will be used for passing Gecko-specific information through the CSS parser in stylo.
This commit is contained in:
parent
a636b7127e
commit
bb85f5faf0
10 changed files with 91 additions and 27 deletions
|
@ -9,16 +9,38 @@ use selectors::parser::ParserContext as SelectorParserContext;
|
|||
use stylesheets::Origin;
|
||||
use url::Url;
|
||||
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
pub struct ParserContextExtraData;
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
pub struct ParserContextExtraData {
|
||||
}
|
||||
|
||||
impl ParserContextExtraData {
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
pub fn default() -> ParserContextExtraData {
|
||||
ParserContextExtraData
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn default() -> ParserContextExtraData {
|
||||
ParserContextExtraData { }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ParserContext<'a> {
|
||||
pub stylesheet_origin: Origin,
|
||||
pub base_url: &'a Url,
|
||||
pub selector_context: SelectorParserContext,
|
||||
pub error_reporter: Box<ParseErrorReporter + Send>,
|
||||
pub extra_data: ParserContextExtraData,
|
||||
}
|
||||
|
||||
impl<'a> ParserContext<'a> {
|
||||
pub fn new(stylesheet_origin: Origin, base_url: &'a Url, error_reporter: Box<ParseErrorReporter + Send>)
|
||||
-> ParserContext<'a> {
|
||||
pub fn new_with_extra_data(stylesheet_origin: Origin, base_url: &'a Url,
|
||||
error_reporter: Box<ParseErrorReporter + Send>,
|
||||
extra_data: ParserContextExtraData)
|
||||
-> ParserContext<'a> {
|
||||
let mut selector_context = SelectorParserContext::new();
|
||||
selector_context.in_user_agent_stylesheet = stylesheet_origin == Origin::UserAgent;
|
||||
ParserContext {
|
||||
|
@ -26,8 +48,15 @@ impl<'a> ParserContext<'a> {
|
|||
base_url: base_url,
|
||||
selector_context: selector_context,
|
||||
error_reporter: error_reporter,
|
||||
extra_data: extra_data,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(stylesheet_origin: Origin, base_url: &'a Url, error_reporter: Box<ParseErrorReporter + Send>)
|
||||
-> ParserContext<'a> {
|
||||
let extra_data = ParserContextExtraData::default();
|
||||
ParserContext::new_with_extra_data(stylesheet_origin, base_url, error_reporter, extra_data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue