diff options
Diffstat (limited to 'Source/WebCore/dom/Document.h')
-rw-r--r-- | Source/WebCore/dom/Document.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h index b63618492..2014dcd84 100644 --- a/Source/WebCore/dom/Document.h +++ b/Source/WebCore/dom/Document.h @@ -1539,20 +1539,48 @@ private: // Put these methods here, because they require the Document definition, but we really want to inline them. +inline TreeScope* Node::treeScope() const +{ + return m_treeScope == TreeScope::nullInstance() ? 0 : m_treeScope; +} + +inline void Node::setTreeScope(TreeScope* scope) +{ + m_treeScope = scope ? scope : TreeScope::nullInstance(); + setFlag(!m_treeScope->isDocumentScope(), InShadowTree); +} + +inline Document* Node::documentInternal() const +{ + if (getFlag(InShadowTree)) + return m_treeScope->rootDocument(); + return static_cast<Document*>(m_treeScope); +} + +inline Document* Node::document() const +{ + Document* document = documentInternal(); + // FIXME: below ASSERT is useful, but prevents the use of document() in the constructor or destructor + // due to the virtual function call to nodeType(). + ASSERT(document || (nodeType() == DOCUMENT_TYPE_NODE && !inDocument())); + return document; +} + inline bool Node::isDocumentNode() const { - return this == m_document; + return this == documentInternal(); } inline Node::Node(Document* document, ConstructionType type) : m_nodeFlags(type) - , m_document(document) + , m_treeScope(0) , m_previous(0) , m_next(0) , m_renderer(0) { if (document) document->guardRef(); + setTreeScope(document); #if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS) trackForDebugging(); #endif |