script/layout_dom/
servo_dangerous_style_shadow_root.rs1#![deny(missing_docs)]
6
7use std::fmt;
8
9use style::dom::TShadowRoot;
10use style::stylist::CascadeData;
11
12use crate::dom::bindings::root::LayoutDom;
13use crate::dom::shadowroot::ShadowRoot;
14use crate::layout_dom::{ServoDangerousStyleElement, ServoDangerousStyleNode};
15
16#[derive(Clone, Copy, PartialEq)]
20pub struct ServoDangerousStyleShadowRoot<'dom> {
21 shadow_root: LayoutDom<'dom, ShadowRoot>,
23}
24
25impl fmt::Debug for ServoDangerousStyleShadowRoot<'_> {
26 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27 self.as_node().fmt(f)
28 }
29}
30
31impl<'dom> From<LayoutDom<'dom, ShadowRoot>> for ServoDangerousStyleShadowRoot<'dom> {
32 fn from(shadow_root: LayoutDom<'dom, ShadowRoot>) -> Self {
33 Self { shadow_root }
34 }
35}
36
37impl<'dom> TShadowRoot for ServoDangerousStyleShadowRoot<'dom> {
38 type ConcreteNode = ServoDangerousStyleNode<'dom>;
39
40 fn as_node(&self) -> ServoDangerousStyleNode<'dom> {
41 self.shadow_root.upcast().into()
42 }
43
44 fn host(&self) -> ServoDangerousStyleElement<'dom> {
45 ServoDangerousStyleElement {
46 element: self.shadow_root.get_host_for_layout(),
47 }
48 }
49
50 fn style_data<'a>(&self) -> Option<&'a CascadeData>
51 where
52 Self: 'a,
53 {
54 Some(self.shadow_root.get_style_data_for_layout())
55 }
56}