Commit dc90debf authored by shinyak@chromium.org's avatar shinyak@chromium.org

[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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@132791 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 22a7263a
2012-10-29 Shinya Kawanaka <shinyak@chromium.org>
[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 <dubroy@chromium.org>
Web Inspector: Fix vertical alignment in toolbar backgrounds and overflow button.
......@@ -198,11 +198,9 @@ Node* ComposedShadowTreeWalker::traverseSiblings(const Node* node, TraversalDire
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);
......
......@@ -52,17 +52,12 @@ InsertionPoint* ContentDistributor::findInsertionPointFor(const Node* key) const
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 @@ void ContentDistributor::distribute(Element* host)
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 @@ void ContentDistributor::distributeNodeChildrenTo(InsertionPoint* insertionPoint
{
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) {
......
......@@ -86,9 +86,6 @@ private:
inline bool isInsertionPoint(const Node* node)
{
if (!node)
return false;
if (node->isHTMLElement() && toHTMLElement(node)->isInsertionPoint())
return true;
......@@ -97,13 +94,13 @@ inline bool isInsertionPoint(const Node* node)
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 isActiveInsertionPoint(const Node* node)
inline bool isLowerEncapsulationBoundary(Node* node)
{
if (!isInsertionPoint(node))
if (!node || !isInsertionPoint(node))
return false;
return toInsertionPoint(node)->isShadowBoundary();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment