Title: [128956] trunk/Source/WebCore
- Revision
- 128956
- Author
- [email protected]
- Date
- 2012-09-18 18:04:59 -0700 (Tue, 18 Sep 2012)
Log Message
[Refactoring] ContentDistributor::distributeSelectionsTo should not change ContentDistribution pool.
https://bugs.webkit.org/show_bug.cgi?id=96993
Reviewed by Dimitri Glazkov.
Since we would like to reuse ContentDistribution pool, it should not be updated in
ContentDistributor::distributeSelectionsTo. Instead, we should have Vector<bool> to indicate an element is
distributed or not.
No new tests, simple refactoring.
* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::distribute):
(WebCore::ContentDistributor::distributeSelectionsTo):
* html/shadow/ContentDistributor.h:
(ContentDistributor):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (128955 => 128956)
--- trunk/Source/WebCore/ChangeLog 2012-09-19 01:03:45 UTC (rev 128955)
+++ trunk/Source/WebCore/ChangeLog 2012-09-19 01:04:59 UTC (rev 128956)
@@ -1,3 +1,22 @@
+2012-09-18 Shinya Kawanaka <[email protected]>
+
+ [Refactoring] ContentDistributor::distributeSelectionsTo should not change ContentDistribution pool.
+ https://bugs.webkit.org/show_bug.cgi?id=96993
+
+ Reviewed by Dimitri Glazkov.
+
+ Since we would like to reuse ContentDistribution pool, it should not be updated in
+ ContentDistributor::distributeSelectionsTo. Instead, we should have Vector<bool> to indicate an element is
+ distributed or not.
+
+ No new tests, simple refactoring.
+
+ * html/shadow/ContentDistributor.cpp:
+ (WebCore::ContentDistributor::distribute):
+ (WebCore::ContentDistributor::distributeSelectionsTo):
+ * html/shadow/ContentDistributor.h:
+ (ContentDistributor):
+
2012-09-18 Byungwoo Lee <[email protected]>
Title string should be changed when document.title is set to ''.
Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.cpp (128955 => 128956)
--- trunk/Source/WebCore/html/shadow/ContentDistributor.cpp 2012-09-19 01:03:45 UTC (rev 128955)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.cpp 2012-09-19 01:04:59 UTC (rev 128956)
@@ -59,6 +59,8 @@
ContentDistribution pool;
for (Node* node = host->firstChild(); node; node = node->nextSibling())
pool.append(node);
+ Vector<bool> distributed(pool.size());
+ distributed.fill(false);
for (ShadowRoot* root = host->youngestShadowRoot(); root; root = root->olderShadowRoot()) {
for (Node* node = root; node; node = node->traverseNextNode(root)) {
@@ -69,7 +71,7 @@
continue;
ShadowRoot* older = root->olderShadowRoot();
if (point->doesSelectFromHostChildren())
- distributeSelectionsTo(point, pool);
+ distributeSelectionsTo(point, pool, distributed);
else if (older && !older->assignedTo()) {
distributeNodeChildrenTo(point, older);
older->setAssignedTo(point);
@@ -106,21 +108,22 @@
m_validity = Invalidated;
}
-void ContentDistributor::distributeSelectionsTo(InsertionPoint* insertionPoint, ContentDistribution& pool)
+void ContentDistributor::distributeSelectionsTo(InsertionPoint* insertionPoint, const ContentDistribution& pool, Vector<bool>& distributed)
{
ContentDistribution distribution;
ContentSelectorQuery query(insertionPoint);
for (size_t i = 0; i < pool.size(); ++i) {
+ if (distributed[i])
+ continue;
+
Node* child = pool[i].get();
- if (!child)
- continue;
if (!query.matches(child))
continue;
distribution.append(child);
m_nodeToInsertionPoint.add(child, insertionPoint);
- pool[i] = 0;
+ distributed[i] = true;
}
insertionPoint->setDistribution(distribution);
Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.h (128955 => 128956)
--- trunk/Source/WebCore/html/shadow/ContentDistributor.h 2012-09-19 01:03:45 UTC (rev 128955)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.h 2012-09-19 01:04:59 UTC (rev 128956)
@@ -69,7 +69,7 @@
bool needsDistribution() const;
bool needsInvalidation() const { return m_validity != Invalidated; }
- void distributeSelectionsTo(InsertionPoint*, ContentDistribution& pool);
+ void distributeSelectionsTo(InsertionPoint*, const ContentDistribution& pool, Vector<bool>& distributed);
void distributeNodeChildrenTo(InsertionPoint*, ContainerNode*);
void invalidateDistributionIn(ContentDistribution*);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes