Barebones media UI

This commit is contained in:
Fernando Jiménez Moreno 2019-04-05 10:50:01 +02:00
parent 4f6b86f9f5
commit 1c02fc94a8
11 changed files with 177 additions and 25 deletions

View file

@ -24,6 +24,7 @@ use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
use net_traits::ReferrerPolicy;
use servo_arc::Arc;
use servo_url::ServoUrl;
use std::cell::Cell;
use style::media_queries::MediaList;
use style::parser::ParserContext as CssParserContext;
@ -111,10 +112,22 @@ impl HTMLStyleElement {
let mq =
Arc::new(shared_lock.wrap(MediaList::parse(&context, &mut CssParser::new(&mut input))));
let loader = StylesheetLoader::for_element(self.upcast());
let (url, origin) = if let Some(shadow_root) = self
.upcast::<Node>()
.containing_shadow_root() {
if shadow_root.is_user_agent_widget() {
(ServoUrl::parse(&format!("chrome://{:?}", window.get_url().to_string())).unwrap(), Origin::UserAgent)
} else {
(window.get_url(), Origin::Author)
}
} else {
(window.get_url(), Origin::Author)
};
let sheet = Stylesheet::from_str(
&data,
window.get_url(),
Origin::Author,
url,
origin,
mq,
shared_lock,
Some(&loader),