diff options
author | batu_hoang <55729155+longvatrong111@users.noreply.github.com> | 2025-03-20 01:58:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-19 17:58:16 +0000 |
commit | db74179dc89910113bbf5a188f3f628d1f2cbf58 (patch) | |
tree | 8e0a746f290aa9cbf1ce16c9005522fb62cd9031 /components/script/dom/shadowroot.rs | |
parent | 11d47558b3f8522bc2835c780489832d330046e0 (diff) | |
download | servo-db74179dc89910113bbf5a188f3f628d1f2cbf58.tar.gz servo-db74179dc89910113bbf5a188f3f628d1f2cbf58.zip |
Make Element::attach_shadow() and ShadowRoot closer to spec (#36024)
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Diffstat (limited to 'components/script/dom/shadowroot.rs')
-rw-r--r-- | components/script/dom/shadowroot.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs index 39383493873..0266170f770 100644 --- a/components/script/dom/shadowroot.rs +++ b/components/script/dom/shadowroot.rs @@ -82,6 +82,12 @@ pub(crate) struct ShadowRoot { /// <https://dom.spec.whatwg.org/#shadowroot-declarative> declarative: Cell<bool>, + + /// <https://dom.spec.whatwg.org/#shadowroot-serializable> + serializable: Cell<bool>, + + /// <https://dom.spec.whatwg.org/#shadowroot-delegates-focus> + delegates_focus: Cell<bool>, } impl ShadowRoot { @@ -117,6 +123,8 @@ impl ShadowRoot { slots: Default::default(), is_user_agent_widget: is_user_agent_widget == IsUserAgentWidget::Yes, declarative: Cell::new(false), + serializable: Cell::new(false), + delegates_focus: Cell::new(false), } } @@ -284,6 +292,22 @@ impl ShadowRoot { pub(crate) fn set_declarative(&self, declarative: bool) { self.declarative.set(declarative); } + + pub(crate) fn is_declarative(&self) -> bool { + self.declarative.get() + } + + pub(crate) fn shadow_root_mode(&self) -> ShadowRootMode { + self.mode + } + + pub(crate) fn set_serializable(&self, serializable: bool) { + self.serializable.set(serializable); + } + + pub(crate) fn set_delegates_focus(&self, delegates_focus: bool) { + self.delegates_focus.set(delegates_focus); + } } impl ShadowRootMethods<crate::DomTypeHolder> for ShadowRoot { @@ -349,11 +373,21 @@ impl ShadowRootMethods<crate::DomTypeHolder> for ShadowRoot { self.mode } + /// <https://dom.spec.whatwg.org/#dom-delegates-focus> + fn DelegatesFocus(&self) -> bool { + self.delegates_focus.get() + } + /// <https://dom.spec.whatwg.org/#dom-shadowroot-clonable> fn Clonable(&self) -> bool { self.clonable } + /// <https://dom.spec.whatwg.org/#dom-serializable> + fn Serializable(&self) -> bool { + self.serializable.get() + } + /// <https://dom.spec.whatwg.org/#dom-shadowroot-host> fn Host(&self) -> DomRoot<Element> { let host = self.host.get(); |