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

Unified Diff: sky/engine/core/css/SelectorChecker.cpp

Issue 840163003: Make SelectorChecker a const operation over element. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 | « sky/engine/core/css/SelectorChecker.h ('k') | sky/engine/core/dom/Element.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/css/SelectorChecker.cpp
diff --git a/sky/engine/core/css/SelectorChecker.cpp b/sky/engine/core/css/SelectorChecker.cpp
index 92959f4ec7c60882789abcee170514c184983b2d..69c6f8b3b3bb22d54e2db225f6d1711b4ff061ee 100644
--- a/sky/engine/core/css/SelectorChecker.cpp
+++ b/sky/engine/core/css/SelectorChecker.cpp
@@ -39,8 +39,11 @@
namespace blink {
-SelectorChecker::SelectorChecker(Document& document, Mode mode)
- : m_mode(mode)
+SelectorChecker::SelectorChecker()
+ : m_matchedAttributeSelector(false)
+ , m_matchedFocusSelector(false)
+ , m_matchedHoverSelector(false)
+ , m_matchedActiveSelector(false)
{
}
@@ -59,7 +62,7 @@ static bool scopeContainsLastMatchedElement(const SelectorChecker::SelectorCheck
return context.element == context.scope->shadowHost();
}
-bool SelectorChecker::match(const SelectorCheckingContext& context) const
+bool SelectorChecker::match(const SelectorCheckingContext& context)
{
// FIXME(sky): Get rid of SelectorCheckingContext.
SelectorCheckingContext matchContext(context);
@@ -160,7 +163,7 @@ static bool attributeValueMatches(const Attribute& attributeItem, CSSSelector::M
return true;
}
-static bool anyAttributeMatches(Element& element, CSSSelector::Match match, const CSSSelector& selector)
+static bool anyAttributeMatches(const Element& element, CSSSelector::Match match, const CSSSelector& selector)
{
const QualifiedName& selectorAttr = selector.attribute();
ASSERT(selectorAttr.localName() != starAtom); // Should not be possible from the CSS grammar.
@@ -186,10 +189,10 @@ static bool anyAttributeMatches(Element& element, CSSSelector::Match match, cons
return false;
}
-bool SelectorChecker::checkOne(const SelectorCheckingContext& context) const
+bool SelectorChecker::checkOne(const SelectorCheckingContext& context)
{
ASSERT(context.element);
- Element& element = *context.element;
+ const Element& element = *context.element;
ASSERT(context.selector);
const CSSSelector& selector = *context.selector;
@@ -208,8 +211,7 @@ bool SelectorChecker::checkOne(const SelectorCheckingContext& context) const
case CSSSelector::Begin:
case CSSSelector::End:
if (anyAttributeMatches(element, selector.match(), selector)) {
- if (m_mode == ResolvingStyle && context.elementStyle)
- context.elementStyle->setUnique();
+ m_matchedAttributeSelector = true;
return true;
}
return false;
@@ -224,10 +226,10 @@ bool SelectorChecker::checkOne(const SelectorCheckingContext& context) const
return false;
}
-bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context) const
+bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context)
{
ASSERT(context.element);
- Element& element = *context.element;
+ const Element& element = *context.element;
ASSERT(context.selector);
const CSSSelector& selector = *context.selector;
ASSERT(selector.match() == CSSSelector::PseudoClass);
@@ -235,24 +237,15 @@ bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context) c
// Normal element pseudo class checking.
switch (selector.pseudoType()) {
case CSSSelector::PseudoFocus:
- if (m_mode == ResolvingStyle) {
- if (context.elementStyle)
- context.elementStyle->setAffectedByFocus();
- }
+ m_matchedFocusSelector = true;
return matchesFocusPseudoClass(element);
case CSSSelector::PseudoHover:
- if (m_mode == ResolvingStyle) {
- if (context.elementStyle)
- context.elementStyle->setAffectedByHover();
- }
+ m_matchedHoverSelector = true;
return element.hovered();
case CSSSelector::PseudoActive:
- if (m_mode == ResolvingStyle) {
- if (context.elementStyle)
- context.elementStyle->setAffectedByActive();
- }
+ m_matchedActiveSelector = true;
return element.active();
case CSSSelector::PseudoLang:
@@ -271,8 +264,6 @@ bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context) c
case CSSSelector::PseudoHost:
{
- if (m_mode == SharingRules)
eseidel1 2015/01/09 02:04:17 Do we care about removal of this early-out?
- return true;
// :host only matches a shadow host when :host is in a shadow tree of the shadow host.
if (!context.scope)
return false;
« no previous file with comments | « sky/engine/core/css/SelectorChecker.h ('k') | sky/engine/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698