Open Bug 1057057 Opened 11 years ago Updated 3 years ago

JS::ubi::Node should understand DOM structure

Categories

(Core :: DOM: Core & HTML, defect, P5)

defect

Tracking

()

People

(Reporter: jimb, Unassigned)

References

(Depends on 1 open bug, Blocks 3 open bugs)

Details

Attachments

(1 file)

JS::ubi::Node should be able to point to nsINode instances, and understand the parent, children, and sibling links. ubi::Nodes referring to JS shadows for nodes should have an outgoing edge to their nsINode. JS::ubi::Node is designed to be easily specialized to handle embedding types; the mechanisms are described here: https://hg.mozilla.org/mozilla-central/file/79ce51162e77/js/public/UbiNode.h#l70 To give each shadow an edge to its nsINode, we would need the JSClass hook described in bug 1056992.
Blocks: 1057093
Not that I fully understand ubi::Node, why does it need to specialize nsINode? Could it not operate on cyclecollectable objects? In case of nsISupports that would be rather simple, just QI to the right thing and then using Traverse you'd get all the outgoing edges. non-nsISupports objects might need some macro magic so that they give the cyclecollection participant.
Blocks: 1059139
If there's some reliable way to retrieve the cycle collector's edges, then we would definitely like to do that. However: - We want meaningful labels for edges; I don't know what the CC has in that department. - We need other inspection operations, like in-memory size. - Iterating over edges must be possible without causing GC or letting arbitrary JS run. QI can run JS.
The CC edge names are derived from C++ field name, so they are probably not too useful to the user. It also isn't going to report things the CC doesn't care about, like strings. The QI operations the CC requires for the callback don't run any JS, or the CC is going to have bad things happen.
I think JS::ubi::Node needs more data than the cycle collector, so we probably can't derive ubi::Node specializations from the CC information alone.
I think we should just extend traverse to cover the use cases ubi needs. Otherwise we pretty much end up having two copies of traverse. For naming, CC has a way to give nicer names, and we can add something new there too.
So if a generic CC based approach is needed, and the tools start from a JS view of the world, getting from JS to C++ could happen similar to http://mxr.mozilla.org/mozilla-central/source/xpcom/base/CycleCollectedJSRuntime.cpp?rev=f18e606357cd#618 and you could implement your own version of http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsCycleCollectionTraversalCallback.h?rev=6fdb8eb0faac#14
Priority: -- → P5
Depends on: 1474383
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: