diff options
author | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-02-21 17:30:32 +0100 |
---|---|---|
committer | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-04-26 11:31:17 +0200 |
commit | 67c90a0717c792c646f14d9a56d97fca3bd92305 (patch) | |
tree | 1bda9876231e5cbb46278e35e6d64885f99edd61 /components/script/dom/element.rs | |
parent | d77b9c6775d181168f245faf8620fe6e2b7ec096 (diff) | |
download | servo-67c90a0717c792c646f14d9a56d97fca3bd92305.tar.gz servo-67c90a0717c792c646f14d9a56d97fca3bd92305.zip |
Relax attachShadow restrictions for user agent widgets
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r-- | components/script/dom/element.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 313ca6111a3..9d92f196a77 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -250,6 +250,13 @@ impl FromStr for AdjacentPosition { } } +/// Whether a shadow root hosts an User Agent widget. +#[derive(PartialEq)] +pub enum IsUserAgentWidget { + No, + Yes, +} + // // Element methods // @@ -451,7 +458,7 @@ impl Element { /// https://dom.spec.whatwg.org/#dom-element-attachshadow /// XXX This is not exposed to web content yet. It is meant to be used /// for UA widgets only. - pub fn attach_shadow(&self) -> Fallible<DomRoot<ShadowRoot>> { + pub fn attach_shadow(&self, is_ua_widget: IsUserAgentWidget) -> Fallible<DomRoot<ShadowRoot>> { // Step 1. if self.namespace != ns!(html) { return Err(Error::NotSupported); @@ -477,6 +484,8 @@ impl Element { &local_name!("p") | &local_name!("section") | &local_name!("span") => {}, + &local_name!("video") | &local_name!("audio") + if is_ua_widget == IsUserAgentWidget::Yes => {}, _ => return Err(Error::NotSupported), }; @@ -2658,7 +2667,7 @@ impl ElementMethods for Element { // to test partial Shadow DOM support for UA widgets. // https://dom.spec.whatwg.org/#dom-element-attachshadow fn AttachShadow(&self) -> Fallible<DomRoot<ShadowRoot>> { - self.attach_shadow() + self.attach_shadow(IsUserAgentWidget::No) } } |