Skip to content

canvas: Change canvas to use JSContext instead of CanGc#42662

Merged
sagudev merged 2 commits intoservo:mainfrom
Narfinger:canvas-jscontext
Feb 17, 2026
Merged

canvas: Change canvas to use JSContext instead of CanGc#42662
sagudev merged 2 commits intoservo:mainfrom
Narfinger:canvas-jscontext

Conversation

@Narfinger
Copy link
Copy Markdown
Contributor

@Narfinger Narfinger commented Feb 16, 2026

This changes the methods in dom/canvas to use the new JSContext/&mut JSContext instead of CanGc.

Part of #40600

Signed-off-by: Narfinger Narfinger@users.noreply.github.com

Testing: This is a refactor, hence, compilation is the test.

@Narfinger
Copy link
Copy Markdown
Contributor Author

I mostly did this to understand the JSContext changes coming up.
I have two questions, though (@sagudev or @jdm):

  • I assume there is currently nothing for Constructor type methods?
  • deserialize needs a method from GlobalScope to &mut JSContext. Does this currently exist?
  • Is there anything else that I missed or did suboptimal?

@sagudev
Copy link
Copy Markdown
Member

sagudev commented Feb 16, 2026

I assume there is currently nothing for Constructor type methods?

Yes, I need to fix codegen for them. I will do this tomorrow.

deserialize needs a method from GlobalScope to &mut JSContext. Does this currently exist?

I think deserialize actually needs to get cx passed as arg.

Is there anything else that I missed or did suboptimal?

I will check it tomorrow.

@sagudev sagudev self-requested a review February 16, 2026 15:41
@sagudev
Copy link
Copy Markdown
Member

sagudev commented Feb 17, 2026

I fixed codegen for constructor in f623081 and this PR looks alright.

I think we should defer ImageData changes to after we pass cx in serialize.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
@Narfinger Narfinger marked this pull request as ready for review February 17, 2026 15:14
@Narfinger Narfinger requested a review from gterzian as a code owner February 17, 2026 15:14
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 17, 2026
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
@Narfinger
Copy link
Copy Markdown
Contributor Author

Ok done.
But I am still now quite sure how to handle the reflect_dom_object without can_gc.

@Narfinger Narfinger changed the title canvas: Change script to use JSContext instead of CanGc canvas: Change canvas to use JSContext instead of CanGc Feb 17, 2026
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Feb 17, 2026
@sagudev sagudev added this pull request to the merge queue Feb 17, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 17, 2026
@sagudev
Copy link
Copy Markdown
Member

sagudev commented Feb 17, 2026

Ok done. But I am still now quite sure how to handle the reflect_dom_object without can_gc.

Ah, I need to write methods that will take &mut JSContext.

Merged via the queue into servo:main with commit 45eb43c Feb 17, 2026
34 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 17, 2026
@Narfinger Narfinger deleted the canvas-jscontext branch February 18, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants