aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/shadowroot.rs
diff options
context:
space:
mode:
authorFernando Jiménez Moreno <ferjmoreno@gmail.com>2019-01-21 15:58:54 +0100
committerFernando Jiménez Moreno <ferjmoreno@gmail.com>2019-04-26 10:17:44 +0200
commit18ae0fcbd6af223f978a527d7d5039633d3c22ed (patch)
tree831606a4e647c47c2c27759f6d5c09454013c50b /components/script/dom/shadowroot.rs
parentcbcf21c2489521fbed29681ee59fbcdd90db2d80 (diff)
downloadservo-18ae0fcbd6af223f978a527d7d5039633d3c22ed.tar.gz
servo-18ae0fcbd6af223f978a527d7d5039633d3c22ed.zip
ShadowRoot interface
Diffstat (limited to 'components/script/dom/shadowroot.rs')
-rw-r--r--components/script/dom/shadowroot.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs
new file mode 100644
index 00000000000..bb3b646a9d2
--- /dev/null
+++ b/components/script/dom/shadowroot.rs
@@ -0,0 +1,40 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use crate::dom::documentfragment::DocumentFragment;
+use crate::dom::bindings::codegen::Bindings::ShadowRootBinding::ShadowRootBinding::ShadowRootMethods;
+use crate::dom::bindings::codegen::Bindings::ShadowRootBinding::ShadowRootMode;
+use crate::dom::bindings::root::{Dom, DomRoot};
+use crate::dom::document::Document;
+use crate::dom::element::Element;
+use dom_struct::dom_struct;
+
+// https://dom.spec.whatwg.org/#interface-shadowroot
+#[dom_struct]
+pub struct ShadowRoot {
+ document_fragment: DocumentFragment,
+ host: Dom<Element>,
+}
+
+impl ShadowRoot {
+ #[allow(dead_code)]
+ pub fn new_inherited(host: &Element, document: &Document) -> ShadowRoot {
+ ShadowRoot {
+ document_fragment: DocumentFragment::new_inherited(document),
+ host: Dom::from_ref(host),
+ }
+ }
+}
+
+impl ShadowRootMethods for ShadowRoot {
+ /// https://dom.spec.whatwg.org/#dom-shadowroot-mode
+ fn Mode(&self) -> ShadowRootMode {
+ ShadowRootMode::Closed
+ }
+
+ /// https://dom.spec.whatwg.org/#dom-shadowroot-host
+ fn Host(&self) -> DomRoot<Element> {
+ DomRoot::from_ref(&self.host)
+ }
+}