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

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

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/CSSSelector.cpp ('k') | Source/core/css/CSSSelectorList.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSSelectorList.h
diff --git a/Source/core/css/CSSSelectorList.h b/Source/core/css/CSSSelectorList.h
index 320de3b4175db62f71e2688b7d710b5b5799d368..f90b28722973b7cd6e49f27490687566b52ed7c1 100644
--- a/Source/core/css/CSSSelectorList.h
+++ b/Source/core/css/CSSSelectorList.h
@@ -45,17 +45,17 @@ public:
bool isValid() const { return !!m_selectorArray; }
const CSSSelector* first() const { return m_selectorArray; }
- static const CSSSelector* next(const CSSSelector*);
- bool hasOneSelector() const { return m_selectorArray && !next(m_selectorArray); }
- const CSSSelector* selectorAt(size_t index) const { return &m_selectorArray[index]; }
+ static const CSSSelector* next(const CSSSelector&);
+ bool hasOneSelector() const { return m_selectorArray && !next(*m_selectorArray); }
+ const CSSSelector& selectorAt(size_t index) const { return m_selectorArray[index]; }
size_t indexOfNextSelectorAfter(size_t index) const
{
- const CSSSelector* current = selectorAt(index);
- current = next(current);
- if (!current)
+ const CSSSelector& current = selectorAt(index);
+ const CSSSelector* next = this->next(current);
+ if (!next)
return kNotFound;
- return current - m_selectorArray;
+ return next - m_selectorArray;
}
bool selectorsNeedNamespaceResolution();
@@ -77,12 +77,13 @@ private:
CSSSelector* m_selectorArray;
};
-inline const CSSSelector* CSSSelectorList::next(const CSSSelector* current)
+inline const CSSSelector* CSSSelectorList::next(const CSSSelector& current)
{
// Skip subparts of compound selectors.
- while (!current->isLastInTagHistory())
- current++;
- return current->isLastInSelectorList() ? 0 : current + 1;
+ const CSSSelector* last = &current;
+ while (!last->isLastInTagHistory())
+ last++;
+ return last->isLastInSelectorList() ? 0 : last + 1;
}
} // namespace WebCore
« no previous file with comments | « Source/core/css/CSSSelector.cpp ('k') | Source/core/css/CSSSelectorList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698