diff options
Diffstat (limited to 'components/script/dom/htmlstyleelement.rs')
-rw-r--r-- | components/script/dom/htmlstyleelement.rs | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index dcf15060776..9e22061fd66 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -4,16 +4,13 @@ use std::cell::Cell; -use cssparser::{Parser as CssParser, ParserInput}; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; use js::rust::HandleObject; use net_traits::ReferrerPolicy; use servo_arc::Arc; -use style::media_queries::MediaList; -use style::parser::ParserContext as CssParserContext; -use style::stylesheets::{AllowImportRules, CssRuleType, Origin, Stylesheet, UrlExtraData}; -use style_traits::ParsingMode; +use style::media_queries::MediaList as StyleMediaList; +use style::stylesheets::{AllowImportRules, Origin, Stylesheet, UrlExtraData}; use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; @@ -26,6 +23,7 @@ use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::document::Document; use crate::dom::element::{AttributeMutation, Element, ElementCreator}; use crate::dom::htmlelement::HTMLElement; +use crate::dom::medialist::MediaList; use crate::dom::node::{BindContext, ChildrenMutation, Node, NodeTraits, UnbindContext}; use crate::dom::stylesheet::StyleSheet as DOMStyleSheet; use crate::dom::virtualmethods::VirtualMethods; @@ -83,26 +81,9 @@ impl HTMLStyleElement { ) } - fn create_media_list(&self, mq_str: &str) -> MediaList { - if mq_str.is_empty() { - return MediaList::empty(); - } - - let window = self.owner_window(); - let doc = self.owner_document(); - let url_data = UrlExtraData(window.get_url().get_arc()); - let context = CssParserContext::new( - Origin::Author, - &url_data, - Some(CssRuleType::Media), - ParsingMode::DEFAULT, - doc.quirks_mode(), - /* namespaces = */ Default::default(), - window.css_error_reporter(), - None, - ); - let mut input = ParserInput::new(mq_str); - MediaList::parse(&context, &mut CssParser::new(&mut input)) + #[inline] + fn create_media_list(&self, mq_str: &str) -> StyleMediaList { + MediaList::parse_media_list(mq_str, &self.owner_window()) } pub(crate) fn parse_own_css(&self) { @@ -279,7 +260,7 @@ impl VirtualMethods for HTMLStyleElement { let media = stylesheet.media.write_with(&mut guard); match mutation { AttributeMutation::Set(_) => *media = self.create_media_list(&attr.value()), - AttributeMutation::Removed => *media = MediaList::empty(), + AttributeMutation::Removed => *media = StyleMediaList::empty(), }; self.owner_document().invalidate_stylesheets(); } |