I’ll add the bellow section to https://github.com/mozilla/servo/wiki/JS-smart-pointers.
——————————————————————————————
When Servo creates a Rusty DOM object, the binding code creates a wrapper JSObject
which is created by SpiderMonkey, is correspond to each Rusty DOM Object. It’s produced and set to the Rusty object in FooBinding::Wrap
.
In FooBinding::Wrap
, the warpper JSObject gets the pointer for Rusty Object to itself. And the same time, the wrapper JSObject
are set to the Rusty Object’s Reflector
field (All Rusty DOM objects have dom::bindings::utils::Reflector
in their most basis field). These step are the “binding” work to create the relationship of both objects.