dawn.node: Do not expose non-WebGPU interfaces at global scope.
This remove some interfaces like OffscreenCanvas from the global scope because dawn.node is not capable to usefully create them. The CTS uses the absence of these interfaces to skip tests when needed. Bug: dawn:1123 Change-Id: I6d57600ba6b41be58c541d1f8091e7e88781f04f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85364 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
63fe6e11cd
commit
60e5ab281c
|
@ -14,6 +14,10 @@
|
|||
|
||||
// An IDL file that provides stub definitions for dictionaries and interfaces
|
||||
// used by the webgpu.idl file
|
||||
//
|
||||
// The [LegacyNoInterfaceObject] annotation asks idlgen to not create a global constructor for
|
||||
// an interface. It is a real WebIDL annotation but we use it liberally here.
|
||||
// https://webidl.spec.whatwg.org/#LegacyNoInterfaceObject
|
||||
|
||||
dictionary EventInit {
|
||||
boolean bubbles = false;
|
||||
|
@ -21,25 +25,25 @@ dictionary EventInit {
|
|||
boolean composed = false;
|
||||
};
|
||||
|
||||
interface Navigator {
|
||||
[LegacyNoInterfaceObject] interface Navigator {
|
||||
readonly attribute DOMString vendorSub;
|
||||
readonly attribute DOMString productSub;
|
||||
readonly attribute DOMString vendor;
|
||||
};
|
||||
|
||||
interface Event {
|
||||
[LegacyNoInterfaceObject] interface Event {
|
||||
readonly attribute boolean bubbles;
|
||||
readonly attribute boolean cancelable;
|
||||
attribute boolean returnValue;
|
||||
};
|
||||
|
||||
interface WorkerNavigator{};
|
||||
[LegacyNoInterfaceObject] interface WorkerNavigator{};
|
||||
|
||||
interface EventListener {
|
||||
[LegacyNoInterfaceObject] interface EventListener {
|
||||
undefined handleEvent(Event event);
|
||||
};
|
||||
|
||||
interface EventTarget {
|
||||
[LegacyNoInterfaceObject] interface EventTarget {
|
||||
undefined addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options);
|
||||
undefined removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options);
|
||||
boolean dispatchEvent(Event event);
|
||||
|
@ -52,7 +56,7 @@ dictionary AddEventListenerOptions : EventListenerOptions {
|
|||
boolean once = false;
|
||||
};
|
||||
|
||||
interface HTMLVideoElement {
|
||||
[LegacyNoInterfaceObject] interface HTMLVideoElement {
|
||||
attribute unsigned long width;
|
||||
attribute unsigned long height;
|
||||
readonly attribute unsigned long videoWidth;
|
||||
|
@ -66,19 +70,19 @@ typedef(Int8Array or Int16Array or Int32Array or Uint8Array or Uint16Array or
|
|||
|
||||
typedef(ArrayBufferView or ArrayBuffer) BufferSource;
|
||||
|
||||
interface ImageBitmap {
|
||||
[LegacyNoInterfaceObject] interface ImageBitmap {
|
||||
readonly attribute unsigned long width;
|
||||
readonly attribute unsigned long height;
|
||||
};
|
||||
|
||||
interface HTMLCanvasElement {
|
||||
[LegacyNoInterfaceObject] interface HTMLCanvasElement {
|
||||
attribute unsigned long width;
|
||||
attribute unsigned long height;
|
||||
};
|
||||
|
||||
interface OffscreenCanvas {
|
||||
[LegacyNoInterfaceObject] interface OffscreenCanvas {
|
||||
attribute unsigned long width;
|
||||
attribute unsigned long height;
|
||||
};
|
||||
|
||||
interface EventHandler{};
|
||||
[LegacyNoInterfaceObject] interface EventHandler{};
|
||||
|
|
|
@ -56,11 +56,13 @@ namespace {
|
|||
void Initialize(Napi::Env env) {
|
||||
auto* wrapper = Wrappers::Init(env);
|
||||
auto global = env.Global();
|
||||
{{ range $ := .Declarations}}
|
||||
{{- range $ := .Declarations}}
|
||||
{{- if IsInterfaceOrNamespace $}}
|
||||
{{- if not (HasAnnotation $ "LegacyNoInterfaceObject")}}
|
||||
global.Set(Napi::String::New(env, "{{$.Name}}"), wrapper->{{$.Name}}_ctor.Value());
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
} // namespace interop
|
||||
|
|
|
@ -518,8 +518,13 @@ func findAnnotation(list []*ast.Annotation, name string) *ast.Annotation {
|
|||
}
|
||||
|
||||
func hasAnnotation(obj interface{}, name string) bool {
|
||||
if member, ok := obj.(*ast.Member); ok {
|
||||
return findAnnotation(member.Annotations, name) != nil
|
||||
switch obj := obj.(type) {
|
||||
case *ast.Member:
|
||||
return findAnnotation(obj.Annotations, name) != nil
|
||||
case *ast.Interface:
|
||||
return findAnnotation(obj.Annotations, name) != nil
|
||||
case *ast.Namespace:
|
||||
return findAnnotation(obj.Annotations, name) != nil
|
||||
}
|
||||
panic("Unhandled AST node type in hasAnnotation")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue