Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Unified Diff: Source/core/css/CSSSelectorList.cpp

Issue 149513011: Pass around CSSSelector by reference instead of pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/CSSSelectorList.h ('k') | Source/core/css/CSSStyleRule.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSSelectorList.cpp
diff --git a/Source/core/css/CSSSelectorList.cpp b/Source/core/css/CSSSelectorList.cpp
index a3b8bdc7c12204a55d3c95fa62911be1935292ed..26892fd5c916c43aa68191180768ca17da5d2ab0 100644
--- a/Source/core/css/CSSSelectorList.cpp
+++ b/Source/core/css/CSSSelectorList.cpp
@@ -112,7 +112,7 @@ String CSSSelectorList::selectorsText() const
{
StringBuilder result;
- for (const CSSSelector* s = first(); s; s = next(s)) {
+ for (const CSSSelector* s = first(); s; s = next(*s)) {
if (s != first())
result.append(", ");
result.append(s->selectorText());
@@ -122,20 +122,19 @@ String CSSSelectorList::selectorsText() const
}
template <typename Functor>
-static bool forEachTagSelector(Functor& functor, const CSSSelector* selector)
+static bool forEachTagSelector(Functor& functor, const CSSSelector& selector)
{
- ASSERT(selector);
-
+ const CSSSelector* current = &selector;
do {
- if (functor(selector))
+ if (functor(*current))
return true;
- if (const CSSSelectorList* selectorList = selector->selectorList()) {
- for (const CSSSelector* subSelector = selectorList->first(); subSelector; subSelector = CSSSelectorList::next(subSelector)) {
- if (forEachTagSelector(functor, subSelector))
+ if (const CSSSelectorList* selectorList = current->selectorList()) {
+ for (const CSSSelector* subSelector = selectorList->first(); subSelector; subSelector = CSSSelectorList::next(*subSelector)) {
+ if (forEachTagSelector(functor, *subSelector))
return true;
}
}
- } while ((selector = selector->tagHistory()));
+ } while ((current = current->tagHistory()));
return false;
}
@@ -143,8 +142,8 @@ static bool forEachTagSelector(Functor& functor, const CSSSelector* selector)
template <typename Functor>
static bool forEachSelector(Functor& functor, const CSSSelectorList* selectorList)
{
- for (const CSSSelector* selector = selectorList->first(); selector; selector = CSSSelectorList::next(selector)) {
- if (forEachTagSelector(functor, selector))
+ for (const CSSSelector* selector = selectorList->first(); selector; selector = CSSSelectorList::next(*selector)) {
+ if (forEachTagSelector(functor, *selector))
return true;
}
@@ -153,11 +152,11 @@ static bool forEachSelector(Functor& functor, const CSSSelectorList* selectorLis
class SelectorNeedsNamespaceResolutionFunctor {
public:
- bool operator()(const CSSSelector* selector)
+ bool operator()(const CSSSelector& selector)
{
- if (selector->m_match == CSSSelector::Tag && selector->tagQName().prefix() != nullAtom && selector->tagQName().prefix() != starAtom)
+ if (selector.m_match == CSSSelector::Tag && selector.tagQName().prefix() != nullAtom && selector.tagQName().prefix() != starAtom)
return true;
- if (selector->isAttributeSelector() && selector->attribute().prefix() != nullAtom && selector->attribute().prefix() != starAtom)
+ if (selector.isAttributeSelector() && selector.attribute().prefix() != nullAtom && selector.attribute().prefix() != starAtom)
return true;
return false;
}
@@ -171,9 +170,9 @@ bool CSSSelectorList::selectorsNeedNamespaceResolution()
class SelectorHasShadowDistributed {
public:
- bool operator()(const CSSSelector* selector)
+ bool operator()(const CSSSelector& selector)
{
- return selector->relationIsAffectedByPseudoContent();
+ return selector.relationIsAffectedByPseudoContent();
}
};
@@ -185,9 +184,9 @@ bool CSSSelectorList::hasShadowDistributedAt(size_t index) const
class SelectorHasCombinatorCrossingTreeBoundary {
public:
- bool operator()(const CSSSelector* selector)
+ bool operator()(const CSSSelector& selector)
{
- return selector->relation() == CSSSelector::ChildTree || selector->relation() == CSSSelector::DescendantTree;
+ return selector.relation() == CSSSelector::ChildTree || selector.relation() == CSSSelector::DescendantTree;
}
};
« no previous file with comments | « Source/core/css/CSSSelectorList.h ('k') | Source/core/css/CSSStyleRule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698