diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/dom/shadow')
5 files changed, 7 insertions, 65 deletions
diff --git a/chromium/third_party/WebKit/Source/core/dom/shadow/ContentDistributor.cpp b/chromium/third_party/WebKit/Source/core/dom/shadow/ContentDistributor.cpp index de321d98914..9bbccdc5711 100644 --- a/chromium/third_party/WebKit/Source/core/dom/shadow/ContentDistributor.cpp +++ b/chromium/third_party/WebKit/Source/core/dom/shadow/ContentDistributor.cpp @@ -33,6 +33,7 @@ #include "core/html/shadow/HTMLContentElement.h" #include "core/html/shadow/HTMLShadowElement.h" + namespace WebCore { void ContentDistribution::swap(ContentDistribution& other) @@ -156,6 +157,8 @@ InsertionPoint* ContentDistributor::findInsertionPointFor(const Node* key) const void ContentDistributor::populate(Node* node, Vector<Node*>& pool) { + node->lazyReattachIfAttached(); + if (!isActiveInsertionPoint(node)) { pool.append(node); return; @@ -224,14 +227,6 @@ void ContentDistributor::distribute(Element* host) if (ElementShadow* shadow = shadowOfParentForDistribution(shadowElement)) shadow->setNeedsDistributionRecalc(); } - - // Detach all nodes that were not distributed and have a renderer. - for (size_t i = 0; i < pool.size(); ++i) { - if (distributed[i]) - continue; - if (pool[i]->renderer()) - pool[i]->lazyReattachIfAttached(); - } } void ContentDistributor::distributeSelectionsTo(InsertionPoint* insertionPoint, const Vector<Node*>& pool, Vector<bool>& distributed) @@ -251,6 +246,7 @@ void ContentDistributor::distributeSelectionsTo(InsertionPoint* insertionPoint, distributed[i] = true; } + insertionPoint->lazyReattachIfAttached(); insertionPoint->setDistribution(distribution); } @@ -258,6 +254,7 @@ void ContentDistributor::distributeNodeChildrenTo(InsertionPoint* insertionPoint { ContentDistribution distribution; for (Node* node = containerNode->firstChild(); node; node = node->nextSibling()) { + node->lazyReattachIfAttached(); if (isActiveInsertionPoint(node)) { InsertionPoint* innerInsertionPoint = toInsertionPoint(node); if (innerInsertionPoint->hasDistribution()) { @@ -277,6 +274,7 @@ void ContentDistributor::distributeNodeChildrenTo(InsertionPoint* insertionPoint } } + insertionPoint->lazyReattachIfAttached(); insertionPoint->setDistribution(distribution); } diff --git a/chromium/third_party/WebKit/Source/core/dom/shadow/InsertionPoint.cpp b/chromium/third_party/WebKit/Source/core/dom/shadow/InsertionPoint.cpp index c00c3c90c01..b4626d77409 100644 --- a/chromium/third_party/WebKit/Source/core/dom/shadow/InsertionPoint.cpp +++ b/chromium/third_party/WebKit/Source/core/dom/shadow/InsertionPoint.cpp @@ -52,48 +52,6 @@ InsertionPoint::~InsertionPoint() { } -void InsertionPoint::setDistribution(ContentDistribution& distribution) -{ - if (shouldUseFallbackElements()) { - for (Node* child = firstChild(); child; child = child->nextSibling()) - child->lazyReattachIfAttached(); - } - - // Attempt not to reattach nodes that would be distributed to the exact same - // location by comparing the old and new distributions. - - size_t i = 0; - size_t j = 0; - - for ( ; i < m_distribution.size() && j < distribution.size(); ++i, ++j) { - if (m_distribution.size() < distribution.size()) { - // If the new distribution is larger than the old one, reattach all nodes in - // the new distribution that were inserted. - for ( ; j < distribution.size() && m_distribution.at(i) != distribution.at(j); ++j) - distribution.at(j)->lazyReattachIfAttached(); - } else if (m_distribution.size() > distribution.size()) { - // If the old distribution is larger than the new one, reattach all nodes in - // the old distribution that were removed. - for ( ; i < m_distribution.size() && m_distribution.at(i) != distribution.at(j); ++i) - m_distribution.at(i)->lazyReattachIfAttached(); - } else if (m_distribution.at(i) != distribution.at(j)) { - // If both distributions are the same length reattach both old and new. - m_distribution.at(i)->lazyReattachIfAttached(); - distribution.at(j)->lazyReattachIfAttached(); - } - } - - // If we hit the end of either list above we need to reattach all remaining nodes. - - for ( ; i < m_distribution.size(); ++i) - m_distribution.at(i)->lazyReattachIfAttached(); - - for ( ; j < distribution.size(); ++j) - distribution.at(j)->lazyReattachIfAttached(); - - m_distribution.swap(distribution); -} - void InsertionPoint::attach(const AttachContext& context) { for (size_t i = 0; i < m_distribution.size(); ++i) { diff --git a/chromium/third_party/WebKit/Source/core/dom/shadow/InsertionPoint.h b/chromium/third_party/WebKit/Source/core/dom/shadow/InsertionPoint.h index b7031292e6f..993ea347969 100644 --- a/chromium/third_party/WebKit/Source/core/dom/shadow/InsertionPoint.h +++ b/chromium/third_party/WebKit/Source/core/dom/shadow/InsertionPoint.h @@ -44,7 +44,7 @@ public: virtual ~InsertionPoint(); bool hasDistribution() const { return !m_distribution.isEmpty(); } - void setDistribution(ContentDistribution&); + void setDistribution(ContentDistribution& distribution) { m_distribution.swap(distribution); } void clearDistribution() { m_distribution.clear(); } bool isActive() const; diff --git a/chromium/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp b/chromium/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp index 1385db124da..a218b17f3a8 100644 --- a/chromium/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp +++ b/chromium/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp @@ -29,7 +29,6 @@ #include "bindings/v8/ExceptionState.h" #include "core/css/resolver/StyleResolver.h" -#include "core/dom/DocumentStyleSheetCollection.h" #include "core/dom/Text.h" #include "core/dom/shadow/ContentDistributor.h" #include "core/dom/shadow/ElementShadow.h" @@ -77,8 +76,6 @@ ShadowRoot::~ShadowRoot() ASSERT(!m_prev); ASSERT(!m_next); - documentInternal()->styleSheetCollection()->didRemoveShadowRoot(this); - // We cannot let ContainerNode destructor call willBeDeletedFrom() // for this ShadowRoot instance because TreeScope destructor // clears Node::m_treeScope thus ContainerNode is no longer able diff --git a/chromium/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h b/chromium/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h index 993fdb2efd2..3bfcc3dd49f 100644 --- a/chromium/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h +++ b/chromium/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h @@ -149,17 +149,6 @@ inline ShadowRoot* toShadowRoot(Node* node) return const_cast<ShadowRoot*>(toShadowRoot(static_cast<const Node*>(node))); } -inline const ShadowRoot* toShadowRoot(const TreeScope* treeScope) -{ - ASSERT_WITH_SECURITY_IMPLICATION(!treeScope || (treeScope->rootNode() && treeScope->rootNode()->isShadowRoot())); - return static_cast<const ShadowRoot*>(treeScope); -} - -inline ShadowRoot* toShadowRoot(TreeScope* treeScope) -{ - return const_cast<ShadowRoot*>(toShadowRoot(static_cast<const TreeScope*>(treeScope))); -} - } // namespace #endif |