Skip to content

Consistently use Dom in native promise handlers #33604

@gterzian

Description

@gterzian

In the context of https://github.com/servo/servo/pull/33603/files#diff-09888dfa911f121670b8b905131455cf548d1816bf65bdeff76fb00f9e55e743R41

The "callbacks" for resolve and rejection of native promise handlers need to usually keep track of dom objects, and it's not clear what is the right primitive to use.

  • Dom may not be safe(mentioned by @jdm), but on the other hand the callbacks are stored on the dom_struct PromiseNativeHandler, so I though using a Dom inside a nested structure would be safe.
  • DomRoot is meant only for rooting on the stack. But it is actually currently used in the native body handlers
  • Trusted was suggested by @jdm, and it is what I chose to use in the above PR. But it is meant fro cross-thread sharing(using arc), while the promise always resolves on the same thread albeit asynchronously.

To me it appears that we should either confirm that using Dom is safe, or otherwise introduce a new Trusted variant for single-threaded usage.

Metadata

Metadata

Assignees

Labels

A-content/scriptRelated to the script threadE-less-complexStraightforward. Recommended for a new contributor.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions