Title: [132791] trunk/Source/WebCore
Revision
132791
Author
[email protected]
Date
2012-10-29 05:51:31 -0700 (Mon, 29 Oct 2012)

Log Message

[Refactoring] Use isActiveInsertionPoint() instead of isInsertionPoint()
https://bugs.webkit.org/show_bug.cgi?id=100459

Reviewed by Hajime Morita.

Checking InsertionPoint and its activeness with two if-statement is error-prone. We would like to
use a utility function which checks both at once.

We rewrite some lines with such function.

No new tests, simple refactoring.

* dom/ComposedShadowTreeWalker.cpp:
(WebCore::ComposedShadowTreeWalker::traverseNode):
* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::populate):
(WebCore::ContentDistributor::distribute):
(WebCore::ContentDistributor::distributeNodeChildrenTo):
* html/shadow/InsertionPoint.h:
(WebCore::isInsertionPoint): Since our convention is the argument of this kind of function should not be null,
we would like to make it similar to the other functions.
(WebCore::toInsertionPoint):
(WebCore::isLowerEncapsulationBoundary):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132790 => 132791)


--- trunk/Source/WebCore/ChangeLog	2012-10-29 12:48:06 UTC (rev 132790)
+++ trunk/Source/WebCore/ChangeLog	2012-10-29 12:51:31 UTC (rev 132791)
@@ -1,3 +1,29 @@
+2012-10-29  Shinya Kawanaka  <[email protected]> 
+
+        [Refactoring] Use isActiveInsertionPoint() instead of isInsertionPoint()
+        https://bugs.webkit.org/show_bug.cgi?id=100459
+
+        Reviewed by Hajime Morita.
+
+        Checking InsertionPoint and its activeness with two if-statement is error-prone. We would like to
+        use a utility function which checks both at once.
+
+        We rewrite some lines with such function.
+
+        No new tests, simple refactoring.
+
+        * dom/ComposedShadowTreeWalker.cpp:
+        (WebCore::ComposedShadowTreeWalker::traverseNode):
+        * html/shadow/ContentDistributor.cpp:
+        (WebCore::ContentDistributor::populate):
+        (WebCore::ContentDistributor::distribute):
+        (WebCore::ContentDistributor::distributeNodeChildrenTo):
+        * html/shadow/InsertionPoint.h:
+        (WebCore::isInsertionPoint): Since our convention is the argument of this kind of function should not be null,
+        we would like to make it similar to the other functions.
+        (WebCore::toInsertionPoint):
+        (WebCore::isLowerEncapsulationBoundary):
+
 2012-10-29  Patrick Dubroy  <[email protected]>
 
         Web Inspector: Fix vertical alignment in toolbar backgrounds and overflow button.

Modified: trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp (132790 => 132791)


--- trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp	2012-10-29 12:48:06 UTC (rev 132790)
+++ trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp	2012-10-29 12:51:31 UTC (rev 132791)
@@ -198,11 +198,9 @@
 Node* ComposedShadowTreeWalker::traverseNode(const Node* node, TraversalDirection direction)
 {
     ASSERT(node);
-    if (!isInsertionPoint(node))
+    if (!isActiveInsertionPoint(node))
         return const_cast<Node*>(node);
     const InsertionPoint* insertionPoint = toInsertionPoint(node);
-    if (!insertionPoint->isActive())
-        return const_cast<Node*>(node);
     if (Node* found = traverseDistributedNodes(direction == TraversalDirectionForward ? insertionPoint->first() : insertionPoint->last(), insertionPoint, direction))
         return found;
     return traverseLightChildren(node, direction);

Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.cpp (132790 => 132791)


--- trunk/Source/WebCore/html/shadow/ContentDistributor.cpp	2012-10-29 12:48:06 UTC (rev 132790)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.cpp	2012-10-29 12:51:31 UTC (rev 132791)
@@ -52,17 +52,12 @@
 
 void ContentDistributor::populate(Node* node, ContentDistribution& pool)
 {
-    if (!isInsertionPoint(node)) {
+    if (!isActiveInsertionPoint(node)) {
         pool.append(node);
         return;
     }
 
     InsertionPoint* insertionPoint = toInsertionPoint(node);
-    if (!insertionPoint->isActive()) {
-        pool.append(insertionPoint);
-        return;
-    }
-
     if (insertionPoint->hasDistribution()) {
         for (size_t i = 0; i < insertionPoint->size(); ++i)
             populate(insertionPoint->at(i), pool);
@@ -91,11 +86,9 @@
         HTMLShadowElement* firstActiveShadowInsertionPoint = 0;
 
         for (Node* node = root; node; node = node->traverseNextNode(root)) {
-            if (!isInsertionPoint(node))
+            if (!isActiveInsertionPoint(node))
                 continue;
             InsertionPoint* point = toInsertionPoint(node);
-            if (!point->isActive())
-                continue;
 
             if (isHTMLShadowElement(node)) {
                 if (!firstActiveShadowInsertionPoint)
@@ -179,7 +172,7 @@
 {
     ContentDistribution distribution;
     for (Node* node = containerNode->firstChild(); node; node = node->nextSibling()) {
-        if (isInsertionPoint(node) && toInsertionPoint(node)->isActive()) {
+        if (isActiveInsertionPoint(node)) {
             InsertionPoint* innerInsertionPoint = toInsertionPoint(node);
             if (innerInsertionPoint->hasDistribution()) {
                 for (size_t i = 0; i < innerInsertionPoint->size(); ++i) {

Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.h (132790 => 132791)


--- trunk/Source/WebCore/html/shadow/InsertionPoint.h	2012-10-29 12:48:06 UTC (rev 132790)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.h	2012-10-29 12:51:31 UTC (rev 132791)
@@ -86,9 +86,6 @@
 
 inline bool isInsertionPoint(const Node* node)
 {
-    if (!node)
-        return false;
-
     if (node->isHTMLElement() && toHTMLElement(node)->isInsertionPoint())
         return true;
 
@@ -97,13 +94,13 @@
 
 inline InsertionPoint* toInsertionPoint(Node* node)
 {
-    ASSERT(isInsertionPoint(node));
+    ASSERT(!node || isInsertionPoint(node));
     return static_cast<InsertionPoint*>(node);
 }
 
 inline const InsertionPoint* toInsertionPoint(const Node* node)
 {
-    ASSERT(isInsertionPoint(node));
+    ASSERT(!node || isInsertionPoint(node));
     return static_cast<const InsertionPoint*>(node);
 }
 
@@ -114,7 +111,7 @@
 
 inline bool isLowerEncapsulationBoundary(Node* node)
 {
-    if (!isInsertionPoint(node))
+    if (!node || !isInsertionPoint(node))
         return false;
     return toInsertionPoint(node)->isShadowBoundary();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to