Title: [150480] trunk/Source/WebCore
Revision
150480
Author
[email protected]
Date
2013-05-21 14:38:13 -0700 (Tue, 21 May 2013)

Log Message

Remove ScopeContentDistribution
https://bugs.webkit.org/show_bug.cgi?id=116576

Reviewed by Andreas Kling.

With maximum one ShadowRoot per Element this can be smashed into ContentDistributor.

* dom/ShadowRoot.cpp:
(WebCore):
* dom/ShadowRoot.h:
(WebCore):
* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::ContentDistributor):
(WebCore):
(WebCore::ContentDistributor::~ContentDistributor):
(WebCore::ContentDistributor::invalidateInsertionPointList):
(WebCore::ContentDistributor::ensureInsertionPointList):
(WebCore::ContentDistributor::distribute):
(WebCore::ContentDistributor::invalidate):
* html/shadow/ContentDistributor.h:
(WebCore):
(ContentDistributor):
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::InsertionPoint):
(WebCore::InsertionPoint::insertedInto):
(WebCore::InsertionPoint::removedFrom):
        
    Simplify insertion point list invalidation.

* html/shadow/InsertionPoint.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (150479 => 150480)


--- trunk/Source/WebCore/ChangeLog	2013-05-21 21:28:03 UTC (rev 150479)
+++ trunk/Source/WebCore/ChangeLog	2013-05-21 21:38:13 UTC (rev 150480)
@@ -1,3 +1,36 @@
+2013-05-21  Antti Koivisto  <[email protected]>
+
+        Remove ScopeContentDistribution
+        https://bugs.webkit.org/show_bug.cgi?id=116576
+
+        Reviewed by Andreas Kling.
+
+        With maximum one ShadowRoot per Element this can be smashed into ContentDistributor.
+
+        * dom/ShadowRoot.cpp:
+        (WebCore):
+        * dom/ShadowRoot.h:
+        (WebCore):
+        * html/shadow/ContentDistributor.cpp:
+        (WebCore::ContentDistributor::ContentDistributor):
+        (WebCore):
+        (WebCore::ContentDistributor::~ContentDistributor):
+        (WebCore::ContentDistributor::invalidateInsertionPointList):
+        (WebCore::ContentDistributor::ensureInsertionPointList):
+        (WebCore::ContentDistributor::distribute):
+        (WebCore::ContentDistributor::invalidate):
+        * html/shadow/ContentDistributor.h:
+        (WebCore):
+        (ContentDistributor):
+        * html/shadow/InsertionPoint.cpp:
+        (WebCore::InsertionPoint::InsertionPoint):
+        (WebCore::InsertionPoint::insertedInto):
+        (WebCore::InsertionPoint::removedFrom):
+        
+            Simplify insertion point list invalidation.
+
+        * html/shadow/InsertionPoint.h:
+
 2013-05-21  Zoltan Horvath  <[email protected]>
 
         [CSS Regions][CSS Exclusions] Multiple regions with shape-insides should respect positioned shapes and overflow

Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (150479 => 150480)


--- trunk/Source/WebCore/dom/ShadowRoot.cpp	2013-05-21 21:28:03 UTC (rev 150479)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp	2013-05-21 21:38:13 UTC (rev 150480)
@@ -39,7 +39,6 @@
 namespace WebCore {
 
 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope {
-    void* pointers[1];
     unsigned countersAndFlags[1];
 };
 
@@ -196,13 +195,4 @@
     setHasScopedHTMLStyleChild(m_numberOfStyles > 0);
 }
 
-ScopeContentDistribution* ShadowRoot::ensureScopeDistribution()
-{
-    if (m_scopeDistribution)
-        return m_scopeDistribution.get();
-
-    m_scopeDistribution = adoptPtr(new ScopeContentDistribution);
-    return m_scopeDistribution.get();
-}   
-
 }

Modified: trunk/Source/WebCore/dom/ShadowRoot.h (150479 => 150480)


--- trunk/Source/WebCore/dom/ShadowRoot.h	2013-05-21 21:28:03 UTC (rev 150479)
+++ trunk/Source/WebCore/dom/ShadowRoot.h	2013-05-21 21:38:13 UTC (rev 150480)
@@ -37,7 +37,6 @@
 namespace WebCore {
 
 class ElementShadow;
-class ScopeContentDistribution;
 
 class ShadowRoot FINAL : public DocumentFragment, public TreeScope {
 public:
@@ -77,10 +76,6 @@
     virtual void registerScopedHTMLStyleChild() OVERRIDE;
     virtual void unregisterScopedHTMLStyleChild() OVERRIDE;
 
-    ScopeContentDistribution* scopeDistribution() { return m_scopeDistribution.get(); }
-    const ScopeContentDistribution* scopeDistribution() const { return m_scopeDistribution.get(); }
-    ScopeContentDistribution* ensureScopeDistribution();
-
     ShadowRootType type() const { return static_cast<ShadowRootType>(m_type); }
 
     PassRefPtr<Node> cloneNode(bool, ExceptionCode&);
@@ -98,7 +93,6 @@
     // FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=88834
     bool isOrphan() const { return !host(); }
 
-    OwnPtr<ScopeContentDistribution> m_scopeDistribution;
     unsigned m_numberOfStyles : 28;
     unsigned m_applyAuthorStyles : 1;
     unsigned m_resetStyleInheritance : 1;

Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.cpp (150479 => 150480)


--- trunk/Source/WebCore/html/shadow/ContentDistributor.cpp	2013-05-21 21:28:03 UTC (rev 150479)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.cpp	2013-05-21 21:38:13 UTC (rev 150480)
@@ -35,18 +35,23 @@
 
 namespace WebCore {
 
-ScopeContentDistribution::ScopeContentDistribution()
+ContentDistributor::ContentDistributor()
     : m_insertionPointListIsValid(true)
+    , m_validity(Undetermined)
 {
 }
 
-void ScopeContentDistribution::invalidateInsertionPointList()
+ContentDistributor::~ContentDistributor()
 {
+}
+
+void ContentDistributor::invalidateInsertionPointList()
+{
     m_insertionPointListIsValid = false;
     m_insertionPointList.clear();
 }
 
-const Vector<RefPtr<InsertionPoint> >& ScopeContentDistribution::ensureInsertionPointList(ShadowRoot* shadowRoot)
+const Vector<RefPtr<InsertionPoint> >& ContentDistributor::ensureInsertionPointList(ShadowRoot* shadowRoot)
 {
     if (m_insertionPointListIsValid)
         return m_insertionPointList;
@@ -62,25 +67,6 @@
     return m_insertionPointList;
 }
 
-void ScopeContentDistribution::registerInsertionPoint(InsertionPoint*)
-{
-    invalidateInsertionPointList();
-}
-
-void ScopeContentDistribution::unregisterInsertionPoint(InsertionPoint*)
-{
-    invalidateInsertionPointList();
-}
-
-ContentDistributor::ContentDistributor()
-    : m_validity(Undetermined)
-{
-}
-
-ContentDistributor::~ContentDistributor()
-{
-}
-
 InsertionPoint* ContentDistributor::findInsertionPointFor(const Node* key) const
 {
     return m_nodeToInsertionPoint.get(key);
@@ -95,15 +81,13 @@
     m_validity = Valid;
 
     if (ShadowRoot* root = host->shadowRoot()) {
-        if (ScopeContentDistribution* scope = root->scopeDistribution()) {
-            const Vector<RefPtr<InsertionPoint> >& insertionPoints = scope->ensureInsertionPointList(root);
-            for (size_t i = 0; i < insertionPoints.size(); ++i) {
-                InsertionPoint* point = insertionPoints[i].get();
-                if (!point->isActive())
-                    continue;
+        const Vector<RefPtr<InsertionPoint> >& insertionPoints = ensureInsertionPointList(root);
+        for (size_t i = 0; i < insertionPoints.size(); ++i) {
+            InsertionPoint* point = insertionPoints[i].get();
+            if (!point->isActive())
+                continue;
 
-                distributeSelectionsTo(point, host);
-            }
+            distributeSelectionsTo(point, host);
         }
     }
 }
@@ -114,12 +98,10 @@
     bool needsReattach = (m_validity == Undetermined) || !m_nodeToInsertionPoint.isEmpty();
 
     if (ShadowRoot* root = host->shadowRoot()) {
-        if (ScopeContentDistribution* scope = root->scopeDistribution()) {
-            const Vector<RefPtr<InsertionPoint> >& insertionPoints = scope->ensureInsertionPointList(root);
-            for (size_t i = 0; i < insertionPoints.size(); ++i) {
-                needsReattach = needsReattach || true;
-                insertionPoints[i]->clearDistribution();
-            }
+        const Vector<RefPtr<InsertionPoint> >& insertionPoints = ensureInsertionPointList(root);
+        for (size_t i = 0; i < insertionPoints.size(); ++i) {
+            needsReattach = true;
+            insertionPoints[i]->clearDistribution();
         }
     }
 

Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.h (150479 => 150480)


--- trunk/Source/WebCore/html/shadow/ContentDistributor.h	2013-05-21 21:28:03 UTC (rev 150479)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.h	2013-05-21 21:38:13 UTC (rev 150480)
@@ -44,21 +44,6 @@
 class Node;
 class ShadowRoot;
 
-class ScopeContentDistribution {
-public:
-    ScopeContentDistribution();
-
-    void registerInsertionPoint(InsertionPoint*);
-    void unregisterInsertionPoint(InsertionPoint*);
-
-    void invalidateInsertionPointList();
-    const Vector<RefPtr<InsertionPoint> >& ensureInsertionPointList(ShadowRoot*);
-
-private:
-    bool m_insertionPointListIsValid;
-    Vector<RefPtr<InsertionPoint> > m_insertionPointList;
-};
-
 class ContentDistributor {
     WTF_MAKE_NONCOPYABLE(ContentDistributor);
 public:
@@ -72,6 +57,8 @@
     ContentDistributor();
     ~ContentDistributor();
 
+    void invalidateInsertionPointList();
+    
     InsertionPoint* findInsertionPointFor(const Node* key) const;
 
     void distributeSelectionsTo(InsertionPoint*, Element* host);
@@ -82,6 +69,8 @@
     static void ensureDistribution(ShadowRoot*);
 
 private:
+    const Vector<RefPtr<InsertionPoint> >& ensureInsertionPointList(ShadowRoot*);
+
     void distribute(Element* host);
     bool invalidate(Element* host);
 
@@ -90,7 +79,9 @@
     bool needsDistribution() const;
     bool needsInvalidation() const { return m_validity != Invalidated; }
 
+    Vector<RefPtr<InsertionPoint> > m_insertionPointList;
     HashMap<const Node*, RefPtr<InsertionPoint> > m_nodeToInsertionPoint;
+    bool m_insertionPointListIsValid;
     unsigned m_validity : 2;
 };
 

Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.cpp (150479 => 150480)


--- trunk/Source/WebCore/html/shadow/InsertionPoint.cpp	2013-05-21 21:28:03 UTC (rev 150479)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.cpp	2013-05-21 21:38:13 UTC (rev 150480)
@@ -43,7 +43,6 @@
 
 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document* document)
     : HTMLElement(tagName, document, CreateInsertionPoint)
-    , m_registeredWithShadowRoot(false)
     , m_hasDistribution(false)
 {
 }
@@ -119,10 +118,7 @@
     if (ShadowRoot* root = containingShadowRoot()) {
         if (ElementShadow* rootOwner = root->owner()) {
             rootOwner->distributor().didShadowBoundaryChange(root->host());
-            if (isActive() && !m_registeredWithShadowRoot && insertionPoint->treeScope()->rootNode() == root) {
-                m_registeredWithShadowRoot = true;
-                root->ensureScopeDistribution()->registerInsertionPoint(this);
-            }
+            rootOwner->distributor().invalidateInsertionPointList();
         }
     }
 
@@ -137,18 +133,14 @@
 
     // host can be null when removedFrom() is called from ElementShadow destructor.
     ElementShadow* rootOwner = root ? root->owner() : 0;
-    if (rootOwner)
+    if (rootOwner) {
         rootOwner->invalidateDistribution();
+        rootOwner->distributor().invalidateInsertionPointList();
+    }
 
     // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up.
     clearDistribution();
 
-    if (m_registeredWithShadowRoot && insertionPoint->treeScope()->rootNode() == root) {
-        ASSERT(root);
-        m_registeredWithShadowRoot = false;
-        root->ensureScopeDistribution()->unregisterInsertionPoint(this);
-    }
-
     HTMLElement::removedFrom(insertionPoint);
 }
 

Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.h (150479 => 150480)


--- trunk/Source/WebCore/html/shadow/InsertionPoint.h	2013-05-21 21:28:03 UTC (rev 150479)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.h	2013-05-21 21:38:13 UTC (rev 150480)
@@ -90,7 +90,6 @@
 
 private:
 
-    bool m_registeredWithShadowRoot;
     bool m_hasDistribution;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to