1504inline Document* Node::documentInternal() const
1505{
1506 if (!m_treeScope)
1507 return 0;
1508 return m_treeScope->rootDocument();
1509}
1510
1511inline Document* Node::document() const
1512{
1513 Document* document = documentInternal();
1514 // FIXME: below ASSERT is useful, but prevents the use of document() in the constructor or destructor
1515 // due to the virtual function call to nodeType().
1516 ASSERT(document || (nodeType() == DOCUMENT_TYPE_NODE && !inDocument()));
1517 return document;
1518}
1519