Skip to content

Commit ebab7d9

Browse files
afdwalexcrichton
authored andcommitted
Enable structural mode for all operations if there is a Global extended attribute on the interface
1 parent 9057941 commit ebab7d9

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

crates/web-sys/webidls/enabled/Window.webidl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
// interface XULControllers;
2626

2727
// http://www.whatwg.org/specs/web-apps/current-work/
28-
[PrimaryGlobal, LegacyUnenumerableNamedProperties, NeedResolve]
28+
[Global=Window,
29+
Exposed=Window,
30+
LegacyUnenumerableNamedProperties]
2931
/*sealed*/ interface Window : EventTarget {
3032
// the current browsing context
3133
[Unforgeable, Constant, StoreInSlot,

crates/webidl/src/first_pass.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub(crate) struct InterfaceData {
3232
/// Whether only partial interfaces were encountered
3333
pub(crate) partial: bool,
3434
pub(crate) operations: BTreeMap<OperationId, OperationData>,
35+
pub(crate) global: bool,
3536
}
3637

3738
#[derive(PartialEq, Eq, PartialOrd, Ord)]
@@ -185,6 +186,7 @@ impl FirstPass<()> for webidl::ast::NonPartialInterface {
185186
InterfaceData {
186187
partial: false,
187188
operations: Default::default(),
189+
global: false,
188190
},
189191
);
190192

@@ -213,6 +215,7 @@ impl FirstPass<()> for webidl::ast::PartialInterface {
213215
InterfaceData {
214216
partial: true,
215217
operations: Default::default(),
218+
global: false,
216219
},
217220
);
218221

@@ -269,6 +272,17 @@ impl<'b> FirstPass<&'b str> for webidl::ast::ExtendedAttribute {
269272
&rhs_arguments,
270273
)
271274
},
275+
webidl::ast::ExtendedAttribute::Identifier(
276+
webidl::ast::IdentifierExtendedAttribute { lhs, .. }
277+
)
278+
| webidl::ast::ExtendedAttribute::IdentifierList(
279+
webidl::ast::IdentifierListExtendedAttribute { lhs, .. }
280+
)
281+
if lhs == "Global" =>
282+
{
283+
record.interfaces.get_mut(self_name).unwrap().global = true;
284+
Ok(())
285+
}
272286
_ => Ok(())
273287
}
274288
}

crates/webidl/src/util.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,11 @@ impl<'a> FirstPassRecord<'a> {
656656
.map(|arg| (&*arg.name, &*arg.type_, arg.variadic)),
657657
ret,
658658
kind,
659-
false,
659+
self
660+
.interfaces
661+
.get(self_name)
662+
.map(|interface_data| interface_data.global)
663+
.unwrap_or(false),
660664
catch,
661665
doc_comment,
662666
)

0 commit comments

Comments
 (0)