-
Notifications
You must be signed in to change notification settings - Fork 182
DOMFS
Our goal is to enable C, C++ and Go programs running in Browsix to read and modify the page DOM. The DOM filesystem should be able to be mounted into the Browsix filesystem hierarchy. If the mountpoint for a DOMFS instance is /dom
, then /dom/html
would refer to the root HTML element.
For example, to show a count of the number of characters in a text field, the following shell command should work:
$ cat /dom/html/body/child-by-id/username-input/text | wc -c >/dom/html/body/child-by-id/char-count/text
Step 1 should be coming up with a mapping from the DOM (XML) to files and directories. For example, an <a href="example.com>link</a>
tag has both attributes like src="http://example.com" and _children_, a single
textfield with the content
link` in this case. Additionally, every node has an optional unique id attribute. In the example above, the hierarchy of DOM elements was navigated both by specifying tag names as well as ids.
A simple example of this mapping would be to represent each element in the DOM as a directory. This directory would have a file per attribute (To read the src
attribute of the <a>
tag above, you would open the file named src
), and a directory called children
with a subdirectory for each child. A slight complication is: what happens if an element has an attribute called children
?
After we have a documented mapping for how to represent the DOM as a filesystem, we can then implement this as a filesystem in BrowserFS.
JXON is a mapping between XML and JSON, which I think is very similar to what we are trying to do: https://developer.mozilla.org/en-US/docs/Archive/JXON (a JSON document much more regularly lends itself to a hierarchical representation, as it doesn't have attributes.