Title: [150430] trunk/Source/WebCore
Revision
150430
Author
[email protected]
Date
2013-05-21 01:40:41 -0700 (Tue, 21 May 2013)

Log Message

Simplify Shadow DOM distribution code
https://bugs.webkit.org/show_bug.cgi?id=116454

Reviewed by Andreas Kling.
        
Remove code supporting nested insertion points and distributing to multiple insertion points.
    
* html/HTMLDetailsElement.cpp:
(DetailsContentElement):
        
    Make distribution to <details> and <summary> mutually exclusive.

* html/shadow/ContentDistributor.cpp:
(WebCore):
(WebCore::ContentDistributor::distribute):
(WebCore::ContentDistributor::invalidate):
(WebCore::ContentDistributor::distributeSelectionsTo):
* html/shadow/ContentDistributor.h:
* html/shadow/InsertionPoint.cpp:
(WebCore::resolveReprojection):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (150429 => 150430)


--- trunk/Source/WebCore/ChangeLog	2013-05-21 08:07:40 UTC (rev 150429)
+++ trunk/Source/WebCore/ChangeLog	2013-05-21 08:40:41 UTC (rev 150430)
@@ -1,3 +1,26 @@
+2013-05-20  Antti Koivisto  <[email protected]>
+
+        Simplify Shadow DOM distribution code
+        https://bugs.webkit.org/show_bug.cgi?id=116454
+
+        Reviewed by Andreas Kling.
+        
+        Remove code supporting nested insertion points and distributing to multiple insertion points.
+    
+        * html/HTMLDetailsElement.cpp:
+        (DetailsContentElement):
+        
+            Make distribution to <details> and <summary> mutually exclusive.
+
+        * html/shadow/ContentDistributor.cpp:
+        (WebCore):
+        (WebCore::ContentDistributor::distribute):
+        (WebCore::ContentDistributor::invalidate):
+        (WebCore::ContentDistributor::distributeSelectionsTo):
+        * html/shadow/ContentDistributor.h:
+        * html/shadow/InsertionPoint.cpp:
+        (WebCore::resolveReprojection):
+
 2013-05-21  Mihnea Ovidenie  <[email protected]>
 
         [CSSRegions] Constrain auto-height region computation in a different way

Modified: trunk/Source/WebCore/html/HTMLDetailsElement.cpp (150429 => 150430)


--- trunk/Source/WebCore/html/HTMLDetailsElement.cpp	2013-05-21 08:07:40 UTC (rev 150429)
+++ trunk/Source/WebCore/html/HTMLDetailsElement.cpp	2013-05-21 08:40:41 UTC (rev 150430)
@@ -51,6 +51,13 @@
         : HTMLContentElement(HTMLNames::webkitShadowContentTag, document)
     {
     }
+
+    virtual MatchType matchTypeFor(Node* node) OVERRIDE
+    {
+        if (node->isElementNode() && node == node->parentNode()->querySelector(summaryQuerySelector(), ASSERT_NO_EXCEPTION))
+            return NeverMatches;
+        return AlwaysMatches;
+    }
 };
 
 PassRefPtr<DetailsContentElement> DetailsContentElement::create(Document* document)

Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.cpp (150429 => 150430)


--- trunk/Source/WebCore/html/shadow/ContentDistributor.cpp	2013-05-21 08:07:40 UTC (rev 150429)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.cpp	2013-05-21 08:40:41 UTC (rev 150430)
@@ -125,23 +125,6 @@
     return m_nodeToInsertionPoint.get(key);
 }
 
-void ContentDistributor::populate(Node* node, ContentDistribution& pool)
-{
-    if (!isActiveInsertionPoint(node)) {
-        pool.append(node);
-        return;
-    }
-
-    InsertionPoint* insertionPoint = toInsertionPoint(node);
-    if (insertionPoint->hasDistribution()) {
-        for (size_t i = 0; i < insertionPoint->size(); ++i)
-            populate(insertionPoint->at(i), pool);
-    } else {
-        for (Node* fallbackNode = insertionPoint->firstChild(); fallbackNode; fallbackNode = fallbackNode->nextSibling())
-            pool.append(fallbackNode);
-    }
-}
-
 void ContentDistributor::distribute(Element* host)
 {
     ASSERT(needsDistribution());
@@ -150,13 +133,6 @@
 
     m_validity = Valid;
 
-    ContentDistribution pool;
-    for (Node* node = host->firstChild(); node; node = node->nextSibling())
-        populate(node, pool);
-
-    Vector<bool> distributed(pool.size());
-    distributed.fill(false);
-
     if (ShadowRoot* root = host->shadowRoot()) {
         if (ScopeContentDistribution* scope = root->scopeDistribution()) {
             const Vector<RefPtr<InsertionPoint> >& insertionPoints = scope->ensureInsertionPointList(root);
@@ -165,9 +141,7 @@
                 if (!point->isActive())
                     continue;
 
-                distributeSelectionsTo(point, pool, distributed);
-                if (ElementShadow* shadow = point->parentNode()->isElementNode() ? toElement(point->parentNode())->shadow() : 0)
-                    shadow->invalidateDistribution();
+                distributeSelectionsTo(point, host);
             }
         }
     }
@@ -184,15 +158,6 @@
             for (size_t i = 0; i < insertionPoints.size(); ++i) {
                 needsReattach = needsReattach || true;
                 insertionPoints[i]->clearDistribution();
-
-                // After insertionPoint's distribution is invalidated, its reprojection should also be invalidated.
-                if (!insertionPoints[i]->isActive())
-                    continue;
-
-                if (Element* parent = insertionPoints[i]->parentElement()) {
-                    if (ElementShadow* shadow = parent->shadow())
-                        shadow->invalidateDistribution();
-                }
             }
         }
     }
@@ -202,21 +167,18 @@
     return needsReattach;
 }
 
-void ContentDistributor::distributeSelectionsTo(InsertionPoint* insertionPoint, const ContentDistribution& pool, Vector<bool>& distributed)
+void ContentDistributor::distributeSelectionsTo(InsertionPoint* insertionPoint, Element* host)
 {
     ContentDistribution distribution;
 
-    for (size_t i = 0; i < pool.size(); ++i) {
-        if (distributed[i])
-            continue;
+    for (Node* child = host->firstChild(); child; child = child->nextSibling()) {
+        ASSERT(!child->isInsertionPoint());
 
-        if (insertionPoint->matchTypeFor(pool.nodes().at(i).get()) != InsertionPoint::AlwaysMatches)
+        if (insertionPoint->matchTypeFor(child) != InsertionPoint::AlwaysMatches)
             continue;
 
-        Node* child = pool.at(i).get();
         distribution.append(child);
         m_nodeToInsertionPoint.add(child, insertionPoint);
-        distributed[i] = true;
     }
 
     insertionPoint->setDistribution(distribution);

Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.h (150429 => 150430)


--- trunk/Source/WebCore/html/shadow/ContentDistributor.h	2013-05-21 08:07:40 UTC (rev 150429)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.h	2013-05-21 08:40:41 UTC (rev 150430)
@@ -100,7 +100,7 @@
 
     InsertionPoint* findInsertionPointFor(const Node* key) const;
 
-    void distributeSelectionsTo(InsertionPoint*, const ContentDistribution& pool, Vector<bool>& distributed);
+    void distributeSelectionsTo(InsertionPoint*, Element* host);
 
     void invalidateDistribution(Element* host);
     void didShadowBoundaryChange(Element* host);
@@ -110,7 +110,6 @@
 private:
     void distribute(Element* host);
     bool invalidate(Element* host);
-    void populate(Node*, ContentDistribution&);
 
     void setValidity(Validity validity) { m_validity = validity; }
     bool isValid() const { return m_validity == Valid; }

Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.cpp (150429 => 150430)


--- trunk/Source/WebCore/html/shadow/InsertionPoint.cpp	2013-05-21 08:07:40 UTC (rev 150429)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.cpp	2013-05-21 08:40:41 UTC (rev 150430)
@@ -197,23 +197,12 @@
 
 InsertionPoint* resolveReprojection(const Node* projectedNode)
 {
-    InsertionPoint* insertionPoint = 0;
-    const Node* current = projectedNode;
-
-    while (current) {
-        if (ElementShadow* shadow = shadowOfParentForDistribution(current)) {
-            if (ShadowRoot* root = current->containingShadowRoot())
-                ContentDistributor::ensureDistribution(root);
-            if (InsertionPoint* insertedTo = shadow->distributor().findInsertionPointFor(projectedNode)) {
-                current = insertedTo;
-                insertionPoint = insertedTo;
-                continue;
-            }
-        }
-        break;
+    if (ElementShadow* shadow = shadowOfParentForDistribution(projectedNode)) {
+        if (ShadowRoot* root = projectedNode->containingShadowRoot())
+            ContentDistributor::ensureDistribution(root);
+        return shadow->distributor().findInsertionPointFor(projectedNode);
     }
-
-    return insertionPoint;
+    return 0;
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to