Skip to content

Commit 8cf9da4

Browse files
committed
Translate the Global attribute to "structural"
All APIs on `Windows` are tagged where `Window` has `[Global]`, and they all need to be structurally accessed rather than through a prototype.
1 parent c67582a commit 8cf9da4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

crates/webidl/src/util.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,18 @@ fn has_named_attribute(list: Option<&ExtendedAttributeList>, attribute: &str) ->
630630
})
631631
}
632632

633+
fn has_ident_attribute(list: Option<&ExtendedAttributeList>, ident: &str) -> bool {
634+
let list = match list {
635+
Some(list) => list,
636+
None => return false,
637+
};
638+
list.body.list.iter().any(|attr| match attr {
639+
ExtendedAttribute::Ident(id) => id.lhs_identifier.0 == ident,
640+
ExtendedAttribute::IdentList(id) => id.identifier.0 == ident,
641+
_ => false,
642+
})
643+
}
644+
633645
/// ChromeOnly is for things that are only exposed to privileged code in Firefox.
634646
pub fn is_chrome_only(ext_attrs: &Option<ExtendedAttributeList>) -> bool {
635647
has_named_attribute(ext_attrs.as_ref(), "ChromeOnly")
@@ -646,7 +658,8 @@ pub fn is_structural(
646658
container_attrs: Option<&ExtendedAttributeList>,
647659
) -> bool {
648660
has_named_attribute(item_attrs, "Unforgeable") ||
649-
has_named_attribute(container_attrs, "Unforgeable")
661+
has_named_attribute(container_attrs, "Unforgeable") ||
662+
has_ident_attribute(container_attrs, "Global")
650663
}
651664

652665
/// Whether a webidl object is marked as throwing.

0 commit comments

Comments
 (0)