mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
Invalidate and flush shadow tree stylesheets where needed
This commit is contained in:
parent
18c1b8f690
commit
519cc2c317
8 changed files with 115 additions and 25 deletions
|
@ -13,8 +13,9 @@ use crate::dom::eventtarget::EventTarget;
|
|||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::htmllinkelement::{HTMLLinkElement, RequestGenerationId};
|
||||
use crate::dom::node::{document_from_node, window_from_node};
|
||||
use crate::dom::node::{document_from_node, shadow_root_from_node, window_from_node};
|
||||
use crate::dom::performanceresourcetiming::InitiatorType;
|
||||
use crate::dom::shadowroot::ShadowRoot;
|
||||
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
||||
use cssparser::SourceLocation;
|
||||
use encoding_rs::UTF_8;
|
||||
|
@ -81,6 +82,7 @@ pub struct StylesheetContext {
|
|||
data: Vec<u8>,
|
||||
/// The node document for elem when the load was initiated.
|
||||
document: Trusted<Document>,
|
||||
shadow_root: Option<Trusted<ShadowRoot>>,
|
||||
origin_clean: bool,
|
||||
/// A token which must match the generation id of the `HTMLLinkElement` for it to load the stylesheet.
|
||||
/// This is ignored for `HTMLStyleElement` and imports.
|
||||
|
@ -187,7 +189,11 @@ impl FetchResponseListener for StylesheetContext {
|
|||
},
|
||||
}
|
||||
|
||||
document.invalidate_stylesheets();
|
||||
if let Some(ref shadow_root) = self.shadow_root {
|
||||
shadow_root.root().invalidate_stylesheets();
|
||||
} else {
|
||||
document.invalidate_stylesheets();
|
||||
}
|
||||
|
||||
// FIXME: Revisit once consensus is reached at:
|
||||
// https://github.com/whatwg/html/issues/1142
|
||||
|
@ -264,6 +270,7 @@ impl<'a> StylesheetLoader<'a> {
|
|||
integrity_metadata: String,
|
||||
) {
|
||||
let document = document_from_node(self.elem);
|
||||
let shadow_root = shadow_root_from_node(self.elem).map(|sr| Trusted::new(&*sr));
|
||||
let gen = self
|
||||
.elem
|
||||
.downcast::<HTMLLinkElement>()
|
||||
|
@ -275,6 +282,7 @@ impl<'a> StylesheetLoader<'a> {
|
|||
metadata: None,
|
||||
data: vec![],
|
||||
document: Trusted::new(&*document),
|
||||
shadow_root,
|
||||
origin_clean: true,
|
||||
request_generation_id: gen,
|
||||
resource_timing: ResourceFetchTiming::new(ResourceTimingType::Resource),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue