Skip to content

Conversation

zazabap
Copy link

@zazabap zazabap commented Aug 16, 2025

Requested by the issue in servo repository servo/servo#38105

Update the method to deal with mutable borrow hazard when using CanGc and RefCell::borrow_mut

@zazabap zazabap force-pushed the feature/update-CanGc branch from 14a4f3f to f00ab94 Compare August 16, 2025 13:10
- `GlobalScope`: can be obtained using `self.global()` on a `dom_struct`, or `GlobalScope::from_safe_context`
- `InRealm`: can be obtained as an argument to the generated trait method, using [this configuration file](https://github.com/servo/servo/blob/4a5ff01e060293721d10289ec56dbd4c58a0969e/components/script_bindings/codegen/Bindings.conf)
- `CanGc`: same as for `InRealm`.
- `CanGc`: same as for `InRealm` using the same configuration file. When working with `RefCall::borrow_mut` int methods that take a `CanGc` argument, please avoid mutable borrow hazard, using the implementation similar to [this example](https://github.com/servo/servo/blob/f19b2f6e848ad2b4b5fde8969958e37e76844faa/components/script/dom/response.rs#L455).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this requires more detail in a separate page that would be linked from this. What I'm imagining is:

  1. What does a CanGc argument mean?
  2. If I am calling a method that takes a CanGc argument, where do I get one?
  3. Risks of CanGc with RefCell::borrow_mut
  4. Patterns for avoiding mutable borrow hazards

I'm perfectly happy to write this, but let me know if you want to try!

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.

2 participants