mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Barebones media UI
This commit is contained in:
parent
4f6b86f9f5
commit
1c02fc94a8
11 changed files with 177 additions and 25 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue