Diff
Modified: trunk/Source/WebCore/ChangeLog (156188 => 156189)
--- trunk/Source/WebCore/ChangeLog 2013-09-20 19:28:08 UTC (rev 156188)
+++ trunk/Source/WebCore/ChangeLog 2013-09-20 19:29:47 UTC (rev 156189)
@@ -1,5 +1,29 @@
2013-09-20 Benjamin Poulain <[email protected]>
+ Start cleaning the API of SelectorChecker
+ https://bugs.webkit.org/show_bug.cgi?id=121654
+
+ Reviewed by Antti Koivisto.
+
+ Make the matching mode internal.
+ Remove unused accessors.
+ Make isFrameFocused() internal.
+
+ * css/ElementRuleCollector.cpp:
+ (WebCore::ElementRuleCollector::ruleMatches):
+ * css/SelectorChecker.cpp:
+ (WebCore::SelectorChecker::matchRecursively):
+ (WebCore::SelectorChecker::checkOne):
+ (WebCore::isFrameFocused):
+ * css/SelectorChecker.h:
+ (WebCore::SelectorChecker::match):
+ * css/StyleResolver.h:
+ (WebCore::checkRegionSelector):
+ * dom/SelectorQuery.cpp:
+ (WebCore::SelectorDataList::selectorMatches):
+
+2013-09-20 Benjamin Poulain <[email protected]>
+
Remove SelectorChecker's CrossesBoundary boundary mode
https://bugs.webkit.org/show_bug.cgi?id=121653
Modified: trunk/Source/WebCore/css/ElementRuleCollector.cpp (156188 => 156189)
--- trunk/Source/WebCore/css/ElementRuleCollector.cpp 2013-09-20 19:28:08 UTC (rev 156188)
+++ trunk/Source/WebCore/css/ElementRuleCollector.cpp 2013-09-20 19:29:47 UTC (rev 156189)
@@ -374,8 +374,7 @@
context.pseudoId = m_pseudoStyleRequest.pseudoId;
context.scrollbar = m_pseudoStyleRequest.scrollbar;
context.scrollbarPart = m_pseudoStyleRequest.scrollbarPart;
- SelectorChecker::Match match = selectorChecker.match(context, dynamicPseudo);
- if (match != SelectorChecker::SelectorMatches)
+ if (!selectorChecker.match(context, dynamicPseudo))
return false;
if (m_pseudoStyleRequest.pseudoId != NOPSEUDO && m_pseudoStyleRequest.pseudoId != dynamicPseudo)
return false;
Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (156188 => 156189)
--- trunk/Source/WebCore/css/SelectorChecker.cpp 2013-09-20 19:28:08 UTC (rev 156188)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp 2013-09-20 19:29:47 UTC (rev 156189)
@@ -148,7 +148,7 @@
// * SelectorFailsLocally - the selector fails for the element e
// * SelectorFailsAllSiblings - the selector fails for e and any sibling of e
// * SelectorFailsCompletely - the selector fails for e and any sibling or ancestor of e
-SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext& context, PseudoId& dynamicPseudo) const
+SelectorChecker::Match SelectorChecker::matchRecursively(const SelectorCheckingContext& context, PseudoId& dynamicPseudo) const
{
// The first selector has to match.
if (!checkOne(context))
@@ -210,7 +210,7 @@
nextContext.isSubSelector = false;
nextContext.elementStyle = 0;
for (; nextContext.element; nextContext.element = nextContext.element->parentElement()) {
- Match match = this->match(nextContext, ignoreDynamicPseudo);
+ Match match = this->matchRecursively(nextContext, ignoreDynamicPseudo);
if (match == SelectorMatches || match == SelectorFailsCompletely)
return match;
if (nextContext.element == nextContext.scope && nextContext.behaviorAtBoundary != StaysWithinTreeScope)
@@ -224,7 +224,7 @@
return SelectorFailsCompletely;
nextContext.isSubSelector = false;
nextContext.elementStyle = 0;
- return match(nextContext, ignoreDynamicPseudo);
+ return matchRecursively(nextContext, ignoreDynamicPseudo);
case CSSSelector::DirectAdjacent:
if (m_mode == ResolvingStyle) {
@@ -236,7 +236,7 @@
return SelectorFailsAllSiblings;
nextContext.isSubSelector = false;
nextContext.elementStyle = 0;
- return match(nextContext, ignoreDynamicPseudo);
+ return matchRecursively(nextContext, ignoreDynamicPseudo);
case CSSSelector::IndirectAdjacent:
if (m_mode == ResolvingStyle) {
@@ -247,7 +247,7 @@
nextContext.isSubSelector = false;
nextContext.elementStyle = 0;
for (; nextContext.element; nextContext.element = nextContext.element->previousElementSibling()) {
- Match match = this->match(nextContext, ignoreDynamicPseudo);
+ Match match = this->matchRecursively(nextContext, ignoreDynamicPseudo);
if (match == SelectorMatches || match == SelectorFailsAllSiblings || match == SelectorFailsCompletely)
return match;
};
@@ -264,7 +264,7 @@
&& !(nextContext.hasScrollbarPseudo && nextContext.selector->m_match == CSSSelector::PseudoClass))
return SelectorFailsCompletely;
nextContext.isSubSelector = true;
- return match(nextContext, dynamicPseudo);
+ return matchRecursively(nextContext, dynamicPseudo);
case CSSSelector::ShadowDescendant:
{
@@ -277,7 +277,7 @@
nextContext.element = shadowHostNode;
nextContext.isSubSelector = false;
nextContext.elementStyle = 0;
- return match(nextContext, ignoreDynamicPseudo);
+ return matchRecursively(nextContext, ignoreDynamicPseudo);
}
}
@@ -591,7 +591,7 @@
subContext.isSubSelector = true;
PseudoId ignoreDynamicPseudo = NOPSEUDO;
for (subContext.selector = selector->selectorList()->first(); subContext.selector; subContext.selector = CSSSelectorList::next(subContext.selector)) {
- if (match(subContext, ignoreDynamicPseudo) == SelectorMatches)
+ if (matchRecursively(subContext, ignoreDynamicPseudo) == SelectorMatches)
return true;
}
}
@@ -789,7 +789,7 @@
PseudoId ignoreDynamicPseudo = NOPSEUDO;
const CSSSelector* const & selector = context.selector;
for (subContext.selector = selector->selectorList()->first(); subContext.selector; subContext.selector = CSSSelectorList::next(subContext.selector)) {
- if (match(subContext, ignoreDynamicPseudo) == SelectorMatches)
+ if (matchRecursively(subContext, ignoreDynamicPseudo) == SelectorMatches)
return true;
}
return false;
@@ -925,7 +925,7 @@
return linkMatchType;
}
-bool SelectorChecker::isFrameFocused(const Element* element)
+static bool isFrameFocused(const Element* element)
{
return element->document().frame() && element->document().frame()->selection().isFocusedAndActive();
}
Modified: trunk/Source/WebCore/css/SelectorChecker.h (156188 => 156189)
--- trunk/Source/WebCore/css/SelectorChecker.h 2013-09-20 19:28:08 UTC (rev 156188)
+++ trunk/Source/WebCore/css/SelectorChecker.h 2013-09-20 19:29:47 UTC (rev 156189)
@@ -43,8 +43,9 @@
class SelectorChecker {
WTF_MAKE_NONCOPYABLE(SelectorChecker);
+ enum Match { SelectorMatches, SelectorFailsLocally, SelectorFailsAllSiblings, SelectorFailsCompletely };
+
public:
- enum Match { SelectorMatches, SelectorFailsLocally, SelectorFailsAllSiblings, SelectorFailsCompletely };
enum VisitedMatchType { VisitedMatchDisabled, VisitedMatchEnabled };
enum Mode { ResolvingStyle = 0, CollectingRules, QueryingRules, SharingRules };
enum BehaviorAtBoundary { DoesNotCrossBoundary, StaysWithinTreeScope };
@@ -82,13 +83,11 @@
BehaviorAtBoundary behaviorAtBoundary;
};
- Match match(const SelectorCheckingContext&, PseudoId&) const;
- bool checkOne(const SelectorCheckingContext&) const;
+ bool match(const SelectorCheckingContext& context, PseudoId& pseudoId) const
+ {
+ return matchRecursively(context, pseudoId) == SelectorMatches;
+ }
- bool strictParsing() const { return m_strictParsing; }
-
- Mode mode() const { return m_mode; }
-
static bool tagMatches(const Element*, const QualifiedName&);
static bool isCommonPseudoClassSelector(const CSSSelector*);
static bool matchesFocusPseudoClass(const Element*);
@@ -98,10 +97,11 @@
static unsigned determineLinkMatchType(const CSSSelector*);
private:
+ Match matchRecursively(const SelectorCheckingContext&, PseudoId&) const;
+ bool checkOne(const SelectorCheckingContext&) const;
+
bool checkScrollbarPseudoClass(const SelectorCheckingContext&, Document*, const CSSSelector*) const;
- static bool isFrameFocused(const Element*);
-
bool m_strictParsing;
bool m_documentIsHTML;
Mode m_mode;
Modified: trunk/Source/WebCore/css/StyleResolver.h (156188 => 156189)
--- trunk/Source/WebCore/css/StyleResolver.h 2013-09-20 19:28:08 UTC (rev 156188)
+++ trunk/Source/WebCore/css/StyleResolver.h 2013-09-20 19:29:47 UTC (rev 156189)
@@ -653,7 +653,7 @@
for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) {
SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regionElement, SelectorChecker::VisitedMatchDisabled);
PseudoId ignoreDynamicPseudo = NOPSEUDO;
- if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo) == SelectorChecker::SelectorMatches)
+ if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo))
return true;
}
return false;
Modified: trunk/Source/WebCore/dom/SelectorQuery.cpp (156188 => 156189)
--- trunk/Source/WebCore/dom/SelectorQuery.cpp 2013-09-20 19:28:08 UTC (rev 156188)
+++ trunk/Source/WebCore/dom/SelectorQuery.cpp 2013-09-20 19:29:47 UTC (rev 156189)
@@ -64,7 +64,7 @@
selectorCheckingContext.behaviorAtBoundary = SelectorChecker::StaysWithinTreeScope;
selectorCheckingContext.scope = !rootNode->isDocumentNode() && rootNode->isContainerNode() ? toContainerNode(rootNode) : 0;
PseudoId ignoreDynamicPseudo = NOPSEUDO;
- return selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo) == SelectorChecker::SelectorMatches;
+ return selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo);
}
bool SelectorDataList::matches(Element* targetElement) const