ShadowRoot needs guardRef() and guardDeref()
authorMORITA Hajime <morrita@google.com>
Sat, 23 Feb 2013 10:49:49 +0000 (10:49 +0000)
committerMORITA Hajime <morrita@google.com>
Sat, 23 Feb 2013 10:49:49 +0000 (10:49 +0000)
commitd5e189d8ff93db28bac2f5dac50d1e57ab9c207e
tree5322d07611526d3e8fba919c25f5d1d17ed0d89a
parentade2c3597cd51e2553a42f9e5a844bf372e3c037
ShadowRoot needs guardRef() and guardDeref()
https://bugs.webkit.org/show_bug.cgi?id=109777

Reviewed by Dimitri Glazkov.

This change moves m_guardRefCount from Document to TreeScope,
which allows ShadowRoot to be guarded by guardRef() mechanism as
Document. After r137524, Node referes TreeScope instead of
Document. This is natural consequence of the change: It no longer
makes sense to guardRef() Document pointer from Node.

Detail:

- Document::m_guardRefCount and related funcdtions are moved to TreeScope
- Document::removedLastRef is factored out into TreeScope::removedLastRefToScope(),
  TreeScope::dispose() and Docuent::dispose(). ShadowRoot also got its own dispose() implementation.
- Moved guardRef() and guardDeref() calls to TreeScope and Node.
  Note that there are two "guarded" TreeScope references. One is
  Node::m_treeScope and another is TreeScope::m_parentTreeScope.
  The guarded-ref management is now encapsulated in these two classes.

No new tests. Covered by existing tests.

* WebCore.exp.in:
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::~Document):
(WebCore::Document::dispose): Extracted from removedLastRef()
* dom/Document.h:
(WebCore::Node::isTreeScope):
(WebCore::Node::Node):
* dom/DocumentFragment.cpp:
(WebCore::DocumentFragment::DocumentFragment): Remove ASSERT() and move it to ...
(WebCore::DocumentFragment::create): ... here, to allow NULL document from ShadowRoot.
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::setTreeScope):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::ShadowRoot): Passed NULL document to superclass. This aligns what Document is doing.
(WebCore::ShadowRoot::dispose): Added.
* dom/ShadowRoot.h:
(ShadowRoot):
* dom/TreeScope.cpp:
(SameSizeAsTreeScope):
(WebCore::TreeScope::TreeScope):
(WebCore::TreeScope::~TreeScope):
(WebCore::TreeScope::dispose): Added.
(WebCore::TreeScope::setParentTreeScope):
(WebCore::TreeScope::deletionHasBegun):
(WebCore::TreeScope::beginDeletion):
(WebCore::TreeScope::refCount): Added.
* dom/TreeScope.h: Turned m_rootNode to Node* from ContainerNode* for Node::isTreeScope to be inlined.
(WebCore::TreeScope::guardRef): Pulled up from Document.
(WebCore::TreeScope::guardDeref): Ditto.
(WebCore::TreeScope::hasGuardRefCount): Added to hide m_guardRefCount.
(WebCore::TreeScope::deletionHasBegun): Added.
(WebCore::TreeScope::beginDeletion): Added.
(WebCore::TreeScope::removedLastRefToScope): Pulled up from Document.
* dom/TreeScopeAdopter.cpp:
(WebCore::TreeScopeAdopter::moveTreeToNewScope):
(WebCore::TreeScopeAdopter::moveNodeToNewDocument):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@143840 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/DocumentFragment.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/dom/TreeScope.cpp
Source/WebCore/dom/TreeScope.h
Source/WebCore/dom/TreeScopeAdopter.cpp
Source/WebCore/dom/TreeScopeAdopter.h