Commit 9b1e8417 authored by morrita@google.com's avatar morrita@google.com
Browse files

2011-01-17 MORITA Hajime <morrita@google.com>

        Reviewed by Dimitri Glazkov.

        ElementRareData::m_shadowRoot should not be RefPtr.
        https://bugs.webkit.org/show_bug.cgi?id=51914

        This change makes m_shadowRoot a raw pointer, as Node::m_parent is.
        This change is safe because shadow host pointer is stored as TreeShared::m_parent
        which prevents deletion unless set to null.

        No test, no behavioral change.

        * dom/Element.cpp:
        (WebCore::Element::shadowRoot):
        (WebCore::Element::setShadowRoot):
        (WebCore::Element::removeShadowRoot):
        * dom/ElementRareData.h:
        (WebCore::ElementRareData::ElementRareData):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75995 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7e42b490
2011-01-17 MORITA Hajime <morrita@google.com>
Reviewed by Dimitri Glazkov.
ElementRareData::m_shadowRoot should not be RefPtr.
https://bugs.webkit.org/show_bug.cgi?id=51914
This change makes m_shadowRoot a raw pointer, as Node::m_parent is.
This change is safe because shadow host pointer is stored as TreeShared::m_parent
which prevents deletion unless set to null.
No test, no behavioral change.
* dom/Element.cpp:
(WebCore::Element::shadowRoot):
(WebCore::Element::setShadowRoot):
(WebCore::Element::removeShadowRoot):
* dom/ElementRareData.h:
(WebCore::ElementRareData::ElementRareData):
2011-01-17 Maciej Stachowiak <mjs@apple.com>
 
Reviewed by Dan Bernstein.
......
......@@ -1084,7 +1084,7 @@ void Element::recalcStyle(StyleChange change)
Node* Element::shadowRoot()
{
return hasRareData() ? rareData()->m_shadowRoot.get() : 0;
return hasRareData() ? rareData()->m_shadowRoot : 0;
}
void Element::setShadowRoot(PassRefPtr<Node> node)
......@@ -1093,20 +1093,21 @@ void Element::setShadowRoot(PassRefPtr<Node> node)
// about compromising DOM tree integrity (eg. node being a parent of this). However,
// once we implement XBL2, we will have to add integrity checks here.
removeShadowRoot();
RefPtr<Node> newRoot = node;
if (!newRoot)
if (!node)
return;
ensureRareData()->m_shadowRoot = newRoot;
newRoot->setShadowHost(this);
ElementRareData* data = ensureRareData();
data->m_shadowRoot = node.leakRef();
data->m_shadowRoot->setShadowHost(this);
}
void Element::removeShadowRoot()
{
if (!hasRareData())
return;
if (RefPtr<Node> oldRoot = rareData()->m_shadowRoot.release()) {
if (ElementRareData* data = rareData()) {
if (!data->m_shadowRoot)
return;
RefPtr<Node> oldRoot = data->m_shadowRoot;
data->m_shadowRoot = 0;
document()->removeFocusedNodeOfSubtree(oldRoot.get());
oldRoot->setShadowHost(0);
if (oldRoot->inDocument())
......
......@@ -41,7 +41,7 @@ public:
IntSize m_minimumSizeForResizing;
RefPtr<RenderStyle> m_computedStyle;
RefPtr<Node> m_shadowRoot;
Node* m_shadowRoot;
OwnPtr<DatasetDOMStringMap> m_datasetDOMStringMap;
OwnPtr<ClassList> m_classList;
......@@ -54,6 +54,7 @@ inline IntSize defaultMinimumSizeForResizing()
inline ElementRareData::ElementRareData()
: m_minimumSizeForResizing(defaultMinimumSizeForResizing())
, m_shadowRoot(0)
{
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment