mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Relax attachShadow restrictions for user agent widgets
This commit is contained in:
parent
d77b9c6775
commit
67c90a0717
1 changed files with 11 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue