mirror of
https://github.com/servo/servo.git
synced 2025-08-01 03:30:33 +01:00
Pull rule_type into ParserContext
Absorb `rule_type` into the `ParserContext` so that it's easier to pass down to deeper levels of the parser. MozReview-Commit-ID: DjBNytLxGKX
This commit is contained in:
parent
a093b0a087
commit
4574cd8ea6
35 changed files with 125 additions and 97 deletions
|
@ -10,6 +10,7 @@ use dom::bindings::str::DOMString;
|
|||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use style::parser::ParserContext;
|
||||
use style::stylesheets::CssRuleType;
|
||||
use style::supports::{Declaration, parse_condition_or_declaration};
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -29,7 +30,7 @@ impl CSS {
|
|||
pub fn Supports(win: &Window, property: DOMString, value: DOMString) -> bool {
|
||||
let decl = Declaration { prop: property.into(), val: value.into() };
|
||||
let url = win.Document().url();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter());
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports));
|
||||
decl.eval(&context)
|
||||
}
|
||||
|
||||
|
@ -39,7 +40,7 @@ impl CSS {
|
|||
let cond = parse_condition_or_declaration(&mut input);
|
||||
if let Ok(cond) = cond {
|
||||
let url = win.Document().url();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter());
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports));
|
||||
cond.eval(&context)
|
||||
} else {
|
||||
false
|
||||
|
|
|
@ -17,7 +17,7 @@ use dom_struct::dom_struct;
|
|||
use std::sync::Arc;
|
||||
use style::media_queries::parse_media_query_list;
|
||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
||||
use style::stylesheets::MediaRule;
|
||||
use style::stylesheets::{CssRuleType, MediaRule};
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -68,6 +68,9 @@ impl CSSMediaRule {
|
|||
/// https://drafts.csswg.org/css-conditional-3/#the-cssmediarule-interface
|
||||
pub fn set_condition_text(&self, text: DOMString) {
|
||||
let mut input = Parser::new(&text);
|
||||
let win = self.global().as_window();
|
||||
let url = win.Document().url();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media));
|
||||
let new_medialist = parse_media_query_list(&mut input);
|
||||
let mut guard = self.cssconditionrule.shared_lock().write();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use dom_struct::dom_struct;
|
|||
use std::sync::Arc;
|
||||
use style::parser::ParserContext;
|
||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
||||
use style::stylesheets::SupportsRule;
|
||||
use style::stylesheets::{CssRuleType, SupportsRule};
|
||||
use style::supports::SupportsCondition;
|
||||
use style_traits::ToCss;
|
||||
|
||||
|
@ -61,7 +61,7 @@ impl CSSSupportsRule {
|
|||
let global = self.global();
|
||||
let win = global.as_window();
|
||||
let url = win.Document().url();
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter());
|
||||
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports));
|
||||
let enabled = cond.eval(&context);
|
||||
let mut guard = self.cssconditionrule.shared_lock().write();
|
||||
let rule = self.supportsrule.write_with(&mut guard);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue