Propagate CanGc arguments through callers in constructors (#35541)

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
This commit is contained in:
Auguste Baum 2025-02-20 17:17:45 +01:00 committed by GitHub
parent 5465bfc2af
commit 863d2ce871
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
260 changed files with 986 additions and 603 deletions

View file

@ -32,11 +32,11 @@ impl ANGLEInstancedArrays {
impl WebGLExtension for ANGLEInstancedArrays {
type Extension = Self;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<Self> {
reflect_dom_object(
Box::new(ANGLEInstancedArrays::new_inherited(ctx)),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -27,12 +27,8 @@ impl EXTBlendMinmax {
impl WebGLExtension for EXTBlendMinmax {
type Extension = Self;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
reflect_dom_object(
Box::new(Self::new_inherited()),
&*ctx.global(),
CanGc::note(),
)
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<Self> {
reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global(), can_gc)
}
fn spec() -> WebGLExtensionSpec {

View file

@ -27,11 +27,11 @@ impl EXTColorBufferHalfFloat {
impl WebGLExtension for EXTColorBufferHalfFloat {
type Extension = EXTColorBufferHalfFloat;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<EXTColorBufferHalfFloat> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<EXTColorBufferHalfFloat> {
reflect_dom_object(
Box::new(EXTColorBufferHalfFloat::new_inherited()),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -27,12 +27,8 @@ impl EXTFragDepth {
impl WebGLExtension for EXTFragDepth {
type Extension = Self;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
reflect_dom_object(
Box::new(Self::new_inherited()),
&*ctx.global(),
CanGc::note(),
)
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<Self> {
reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global(), can_gc)
}
fn spec() -> WebGLExtensionSpec {

View file

@ -27,12 +27,8 @@ impl EXTShaderTextureLod {
impl WebGLExtension for EXTShaderTextureLod {
type Extension = Self;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
reflect_dom_object(
Box::new(Self::new_inherited()),
&*ctx.global(),
CanGc::note(),
)
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<Self> {
reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global(), can_gc)
}
fn spec() -> WebGLExtensionSpec {

View file

@ -28,12 +28,8 @@ impl EXTTextureFilterAnisotropic {
impl WebGLExtension for EXTTextureFilterAnisotropic {
type Extension = EXTTextureFilterAnisotropic;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
reflect_dom_object(
Box::new(Self::new_inherited()),
&*ctx.global(),
CanGc::note(),
)
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<Self> {
reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global(), can_gc)
}
fn spec() -> WebGLExtensionSpec {

View file

@ -27,11 +27,11 @@ impl OESElementIndexUint {
impl WebGLExtension for OESElementIndexUint {
type Extension = Self;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<Self> {
reflect_dom_object(
Box::new(OESElementIndexUint::new_inherited()),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -27,11 +27,11 @@ impl OESStandardDerivatives {
impl WebGLExtension for OESStandardDerivatives {
type Extension = OESStandardDerivatives;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESStandardDerivatives> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<OESStandardDerivatives> {
reflect_dom_object(
Box::new(OESStandardDerivatives::new_inherited()),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -26,11 +26,11 @@ impl OESTextureFloat {
impl WebGLExtension for OESTextureFloat {
type Extension = OESTextureFloat;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESTextureFloat> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<OESTextureFloat> {
reflect_dom_object(
Box::new(OESTextureFloat::new_inherited()),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -25,11 +25,11 @@ impl OESTextureFloatLinear {
impl WebGLExtension for OESTextureFloatLinear {
type Extension = OESTextureFloatLinear;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESTextureFloatLinear> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<OESTextureFloatLinear> {
reflect_dom_object(
Box::new(OESTextureFloatLinear::new_inherited()),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -27,11 +27,11 @@ impl OESTextureHalfFloat {
impl WebGLExtension for OESTextureHalfFloat {
type Extension = OESTextureHalfFloat;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESTextureHalfFloat> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<OESTextureHalfFloat> {
reflect_dom_object(
Box::new(OESTextureHalfFloat::new_inherited()),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -26,11 +26,11 @@ impl OESTextureHalfFloatLinear {
impl WebGLExtension for OESTextureHalfFloatLinear {
type Extension = OESTextureHalfFloatLinear;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESTextureHalfFloatLinear> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<OESTextureHalfFloatLinear> {
reflect_dom_object(
Box::new(OESTextureHalfFloatLinear::new_inherited()),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -54,11 +54,11 @@ impl OESVertexArrayObjectMethods<crate::DomTypeHolder> for OESVertexArrayObject
impl WebGLExtension for OESVertexArrayObject {
type Extension = OESVertexArrayObject;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESVertexArrayObject> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<OESVertexArrayObject> {
reflect_dom_object(
Box::new(OESVertexArrayObject::new_inherited(ctx)),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -27,11 +27,11 @@ impl WEBGLColorBufferFloat {
impl WebGLExtension for WEBGLColorBufferFloat {
type Extension = WEBGLColorBufferFloat;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<WEBGLColorBufferFloat> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<WEBGLColorBufferFloat> {
reflect_dom_object(
Box::new(WEBGLColorBufferFloat::new_inherited()),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -27,11 +27,11 @@ impl WEBGLCompressedTextureETC1 {
impl WebGLExtension for WEBGLCompressedTextureETC1 {
type Extension = WEBGLCompressedTextureETC1;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<WEBGLCompressedTextureETC1> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<WEBGLCompressedTextureETC1> {
reflect_dom_object(
Box::new(WEBGLCompressedTextureETC1::new_inherited()),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -27,11 +27,11 @@ impl WEBGLCompressedTextureS3TC {
impl WebGLExtension for WEBGLCompressedTextureS3TC {
type Extension = WEBGLCompressedTextureS3TC;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<WEBGLCompressedTextureS3TC> {
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<WEBGLCompressedTextureS3TC> {
reflect_dom_object(
Box::new(WEBGLCompressedTextureS3TC::new_inherited()),
&*ctx.global(),
CanGc::note(),
can_gc,
)
}

View file

@ -9,6 +9,7 @@ use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::trace::JSTraceable;
use crate::dom::webglrenderingcontext::WebGLRenderingContext;
use crate::script_runtime::CanGc;
/// Trait implemented by WebGL extensions.
pub(crate) trait WebGLExtension: Sized
@ -19,7 +20,7 @@ where
type Extension;
/// Creates the DOM object of the WebGL extension.
fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self::Extension>;
fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<Self::Extension>;
/// Returns which WebGL spec is this extension written against.
fn spec() -> WebGLExtensionSpec;

View file

@ -12,6 +12,7 @@ use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::root::MutNullableDom;
use crate::dom::bindings::trace::JSTraceable;
use crate::dom::webglrenderingcontext::WebGLRenderingContext;
use crate::script_runtime::CanGc;
/// Trait used internally by WebGLExtensions to store and
/// handle the different WebGL extensions in a common list.
@ -57,7 +58,7 @@ where
let mut enabled = true;
let extension = self.extension.or_init(|| {
enabled = false;
T::new(ctx)
T::new(ctx, CanGc::note())
});
if !enabled {
self.enable(ext);