mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
script: Add can_gc to WebIDL dictionary constructors (#39195)
More progress on can_gc! Testing: Internal change only, shouldn't change behavior. Fixes: #38708 --------- Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
This commit is contained in:
parent
1b9dc3e672
commit
9584b9e57d
8 changed files with 26 additions and 17 deletions
|
@ -260,7 +260,7 @@ impl HTMLCanvasElement {
|
|||
let canvas =
|
||||
RootedHTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(DomRoot::from_ref(self));
|
||||
let size = self.get_size();
|
||||
let attrs = Self::get_gl_attributes(cx, options)?;
|
||||
let attrs = Self::get_gl_attributes(cx, options, can_gc)?;
|
||||
let context = WebGLRenderingContext::new(
|
||||
&window,
|
||||
&canvas,
|
||||
|
@ -293,7 +293,7 @@ impl HTMLCanvasElement {
|
|||
let canvas =
|
||||
RootedHTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(DomRoot::from_ref(self));
|
||||
let size = self.get_size();
|
||||
let attrs = Self::get_gl_attributes(cx, options)?;
|
||||
let attrs = Self::get_gl_attributes(cx, options, can_gc)?;
|
||||
let context = WebGL2RenderingContext::new(&window, &canvas, size, attrs, can_gc)?;
|
||||
*self.context_mode.borrow_mut() = Some(RenderingContext::WebGL2(Dom::from_ref(&*context)));
|
||||
Some(context)
|
||||
|
@ -338,9 +338,13 @@ impl HTMLCanvasElement {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_gl_attributes(cx: JSContext, options: HandleValue) -> Option<GLContextAttributes> {
|
||||
fn get_gl_attributes(
|
||||
cx: JSContext,
|
||||
options: HandleValue,
|
||||
can_gc: CanGc,
|
||||
) -> Option<GLContextAttributes> {
|
||||
unsafe {
|
||||
match WebGLContextAttributes::new(cx, options) {
|
||||
match WebGLContextAttributes::new(cx, options, can_gc) {
|
||||
Ok(ConversionResult::Success(attrs)) => Some(attrs.convert()),
|
||||
Ok(ConversionResult::Failure(error)) => {
|
||||
throw_type_error(*cx, &error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue