Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/architecture/web_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
- `SafeJSContext`: can be obtained using `GlobalScope::get_cx()`.
- `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!

- It is best to access them as early as possible, say at the top of the trait method implementation, and to pass them down(as ref for `GlobalScope`) as arguments, in the order described above(with any other needed argument coming in between `&GlobalScope` and `InRealm`).
2. This should give you a complete first draft.

Expand Down