aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/stylesheet_loader.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-04-29 08:38:50 -0400
committerGitHub <noreply@github.com>2019-04-29 08:38:50 -0400
commit799490a02e9bea575bf34c39f045ef0883539f05 (patch)
tree278cada683564db36997cf3f96c92513b89c3096 /components/script/stylesheet_loader.rs
parentd58ea974baff1b51a43d2e2bf4b287ff11991a8d (diff)
parent37e88e77cdf00e3555599dd4004d03548bd95dcf (diff)
downloadservo-799490a02e9bea575bf34c39f045ef0883539f05.tar.gz
servo-799490a02e9bea575bf34c39f045ef0883539f05.zip
Auto merge of #22743 - ferjm:shadowdom, r=emilio
Partial ShadowDOM support This is just an early WIP, not to take it very seriously yet. - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] These changes fix #22719 - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22743) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/stylesheet_loader.rs')
-rw-r--r--components/script/stylesheet_loader.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs
index 61c89b35f80..69975c7803b 100644
--- a/components/script/stylesheet_loader.rs
+++ b/components/script/stylesheet_loader.rs
@@ -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::{containing_shadow_root, document_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 = containing_shadow_root(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),