mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement element.shadowRoot
attribute (#34306)
* Implement Element.shadowRoot attribute Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Remove comments about shadowdom not being exposed for web content This is obviously not the case anymore. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
c5cf2621b6
commit
527e2d426d
15 changed files with 209 additions and 65 deletions
|
@ -36,7 +36,7 @@ pub enum IsUserAgentWidget {
|
|||
Yes,
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#interface-shadowroot
|
||||
/// <https://dom.spec.whatwg.org/#interface-shadowroot>
|
||||
#[dom_struct]
|
||||
pub struct ShadowRoot {
|
||||
document_fragment: DocumentFragment,
|
||||
|
@ -48,11 +48,14 @@ pub struct ShadowRoot {
|
|||
author_styles: DomRefCell<AuthorStyles<StyleSheetInDocument>>,
|
||||
stylesheet_list: MutNullableDom<StyleSheetList>,
|
||||
window: Dom<Window>,
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#dom-shadowroot-mode>
|
||||
mode: ShadowRootMode,
|
||||
}
|
||||
|
||||
impl ShadowRoot {
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
fn new_inherited(host: &Element, document: &Document) -> ShadowRoot {
|
||||
fn new_inherited(host: &Element, document: &Document, mode: ShadowRootMode) -> ShadowRoot {
|
||||
let document_fragment = DocumentFragment::new_inherited(document);
|
||||
let node = document_fragment.upcast::<Node>();
|
||||
node.set_flag(NodeFlags::IS_IN_SHADOW_TREE, true);
|
||||
|
@ -60,6 +63,7 @@ impl ShadowRoot {
|
|||
NodeFlags::IS_CONNECTED,
|
||||
host.upcast::<Node>().is_connected(),
|
||||
);
|
||||
|
||||
ShadowRoot {
|
||||
document_fragment,
|
||||
document_or_shadow_root: DocumentOrShadowRoot::new(document.window()),
|
||||
|
@ -68,12 +72,13 @@ impl ShadowRoot {
|
|||
author_styles: DomRefCell::new(AuthorStyles::new()),
|
||||
stylesheet_list: MutNullableDom::new(None),
|
||||
window: Dom::from_ref(document.window()),
|
||||
mode,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(host: &Element, document: &Document) -> DomRoot<ShadowRoot> {
|
||||
pub fn new(host: &Element, document: &Document, mode: ShadowRootMode) -> DomRoot<ShadowRoot> {
|
||||
reflect_dom_object(
|
||||
Box::new(ShadowRoot::new_inherited(host, document)),
|
||||
Box::new(ShadowRoot::new_inherited(host, document, mode)),
|
||||
document.window(),
|
||||
)
|
||||
}
|
||||
|
@ -226,7 +231,7 @@ impl ShadowRootMethods for ShadowRoot {
|
|||
|
||||
/// <https://dom.spec.whatwg.org/#dom-shadowroot-mode>
|
||||
fn Mode(&self) -> ShadowRootMode {
|
||||
ShadowRootMode::Closed
|
||||
self.mode
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#dom-shadowroot-host>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue