Switch from _ownerDocument to _nodeDocument; correct some confusion
Some of the comments in the source (probably inherited from domino, and
from earlier versions of the DOM spec) referred to ownerDocument being
non-null only when a node was actually added to a document. This is
incorrect. All nodes have a *node document* always, regardless of
whether they have been added to that document yet. The "owner document"
is almost always the same as the "node document" except in the case
of Document nodes, which are their own "node documents" but the spec
states that "owner document" should return null.
Most code is simpler and more efficient when it uses the "node document"
concept where we are guaranteed the Document exists and we don't have
to worry about a null case. So change the 'native' representation
to a node document and ensure it is always non-null by requiring it
in the Node constructor. Override ::getOwnerDocument() in Document
in order to have it return null, but all of our internal code can refer
to the _nodeDocument property directly for efficiency.
Note that this puts a circular reference in the Document object,
which might have reference counting implications. Our sibling lists
are also circular, so this is somewhat of a lost cause already.
We may have to add a Dodo-specific "_destroy()" method which a
caller can use to break all the circular references and guarantee
prompt reference-counted deallocation of a Document.