Chromium Code Reviews| Index: sky/engine/core/dom/shadow/ElementShadow.cpp |
| diff --git a/sky/engine/core/dom/shadow/ElementShadow.cpp b/sky/engine/core/dom/shadow/ElementShadow.cpp |
| index 7a577491540c6bb104da3b9576eb5a3659c68050..184546dc50edd3a35af25c2dcc8114b5cb5a87ee 100644 |
| --- a/sky/engine/core/dom/shadow/ElementShadow.cpp |
| +++ b/sky/engine/core/dom/shadow/ElementShadow.cpp |
| @@ -129,7 +129,8 @@ PassOwnPtr<ElementShadow> ElementShadow::create() |
| } |
| ElementShadow::ElementShadow() |
| - : m_needsDistributionRecalc(false) |
| + : m_shadowRoot(0) |
| + , m_needsDistributionRecalc(false) |
| , m_needsSelectFeatureSet(false) |
| { |
| } |
| @@ -146,13 +147,13 @@ ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost) |
| EventDispatchForbiddenScope assertNoEventDispatch; |
| ScriptForbiddenScope forbidScript; |
| - for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) |
| - root->lazyReattachIfAttached(); |
| + ASSERT(!m_shadowRoot); |
| RefPtr<ShadowRoot> shadowRoot = ShadowRoot::create(shadowHost.document()); |
| shadowRoot->setParentOrShadowHostNode(&shadowHost); |
| shadowRoot->setParentTreeScope(shadowHost.treeScope()); |
| - m_shadowRoots.push(shadowRoot.get()); |
| + m_shadowRoot = shadowRoot.get(); |
| + |
| setNeedsDistributionRecalc(); |
| shadowRoot->insertedInto(&shadowHost); |
| @@ -160,42 +161,40 @@ ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost) |
| return *shadowRoot; |
| } |
| -#if !ENABLE(OILPAN) |
| void ElementShadow::removeDetachedShadowRoots() |
|
ojan
2014/11/26 18:43:17
removedDetachedShadowRoot ?
esprehn
2014/11/26 18:54:23
done.
|
| { |
| // Dont protect this ref count. |
| Element* shadowHost = host(); |
| ASSERT(shadowHost); |
| - while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { |
| + if (RefPtr<ShadowRoot> oldRoot = m_shadowRoot) { |
| shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); |
| - m_shadowRoots.removeHead(); |
| + m_shadowRoot = 0; |
| oldRoot->setParentOrShadowHostNode(0); |
| oldRoot->setParentTreeScope(shadowHost->document()); |
| - oldRoot->setPrev(0); |
| - oldRoot->setNext(0); |
| } |
| } |
| -#endif |
| void ElementShadow::attach(const Node::AttachContext& context) |
| { |
| + if (!m_shadowRoot) |
| + return; |
| + |
| + ASSERT(m_shadowRoot->needsAttach()); |
| + |
| Node::AttachContext childrenContext(context); |
| childrenContext.resolvedStyle = 0; |
| - |
| - for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) { |
| - if (root->needsAttach()) |
| - root->attach(childrenContext); |
| - } |
| + m_shadowRoot->attach(childrenContext); |
| } |
| void ElementShadow::detach(const Node::AttachContext& context) |
| { |
| + if (!m_shadowRoot) |
| + return; |
| + |
| Node::AttachContext childrenContext(context); |
| childrenContext.resolvedStyle = 0; |
| - |
| - for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) |
| - root->detach(childrenContext); |
| + m_shadowRoot->detach(childrenContext); |
| } |
| void ElementShadow::setNeedsDistributionRecalc() |
| @@ -209,9 +208,9 @@ void ElementShadow::setNeedsDistributionRecalc() |
| bool ElementShadow::hasSameStyles(const ElementShadow* other) const |
| { |
| - ShadowRoot* root = youngestShadowRoot(); |
| - ShadowRoot* otherRoot = other->youngestShadowRoot(); |
| - while (root || otherRoot) { |
| + ShadowRoot* root = m_shadowRoot; |
| + ShadowRoot* otherRoot = other->shadowRoot(); |
| + if (root || otherRoot) { |
| if (!root || !otherRoot) |
| return false; |
| @@ -225,8 +224,6 @@ bool ElementShadow::hasSameStyles(const ElementShadow* other) const |
| if (toCSSStyleSheet(list->item(i))->contents() != toCSSStyleSheet(otherList->item(i))->contents()) |
| return false; |
| } |
| - root = root->olderShadowRoot(); |
| - otherRoot = otherRoot->olderShadowRoot(); |
| } |
| return true; |
| @@ -251,7 +248,7 @@ void ElementShadow::distribute() |
| host()->setNeedsStyleRecalc(SubtreeStyleChange); |
| DistributionPool pool(*host()); |
| - for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) { |
| + if (ShadowRoot* root = shadowRoot()) { |
| const Vector<RefPtr<InsertionPoint> >& insertionPoints = root->descendantInsertionPoints(); |
| for (size_t i = 0; i < insertionPoints.size(); ++i) { |
| InsertionPoint* point = insertionPoints[i].get(); |
| @@ -276,7 +273,7 @@ const SelectRuleFeatureSet& ElementShadow::ensureSelectFeatureSet() |
| return m_selectFeatures; |
| m_selectFeatures.clear(); |
| - for (ShadowRoot* root = oldestShadowRoot(); root; root = root->youngerShadowRoot()) |
| + if (ShadowRoot* root = shadowRoot()) |
| collectSelectFeatureSetFrom(*root); |
| m_needsSelectFeatureSet = false; |
| return m_selectFeatures; |