- Revision
- 143858
- Author
- [email protected]
- Date
- 2013-02-23 22:18:41 -0800 (Sat, 23 Feb 2013)
Log Message
SelectorChecker should not know about SelectorCheckerFastPath.
https://bugs.webkit.org/show_bug.cgi?id=110663
Both SelectorChecker and it's speedy cousin unfortunately include each other.
Luckily, the particular way in which SelectorQuery uses SelectorChecker yields
to a fairly simple decoupling. Now only the cousin knows of SelectorChecker.
Reviewed by Antti Koivisto.
No new functionality, covered by existing tests.
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matches): Removed.
* css/SelectorChecker.h:
(SelectorChecker): Updated the decls to remove fast-path flag.
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::selectorMatches): Added a helper just for SelectorQuery.
(WebCore::SelectorDataList::matches): Changed the callsite to use new helper.
(WebCore::SelectorDataList::execute): Ditto.
* dom/SelectorQuery.h:
(SelectorDataList): Updated decls.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (143857 => 143858)
--- trunk/Source/WebCore/ChangeLog 2013-02-24 05:31:10 UTC (rev 143857)
+++ trunk/Source/WebCore/ChangeLog 2013-02-24 06:18:41 UTC (rev 143858)
@@ -1,3 +1,27 @@
+2013-02-23 Dimitri Glazkov <[email protected]>
+
+ SelectorChecker should not know about SelectorCheckerFastPath.
+ https://bugs.webkit.org/show_bug.cgi?id=110663
+
+ Both SelectorChecker and it's speedy cousin unfortunately include each other.
+ Luckily, the particular way in which SelectorQuery uses SelectorChecker yields
+ to a fairly simple decoupling. Now only the cousin knows of SelectorChecker.
+
+ Reviewed by Antti Koivisto.
+
+ No new functionality, covered by existing tests.
+
+ * css/SelectorChecker.cpp:
+ (WebCore::SelectorChecker::matches): Removed.
+ * css/SelectorChecker.h:
+ (SelectorChecker): Updated the decls to remove fast-path flag.
+ * dom/SelectorQuery.cpp:
+ (WebCore::SelectorDataList::selectorMatches): Added a helper just for SelectorQuery.
+ (WebCore::SelectorDataList::matches): Changed the callsite to use new helper.
+ (WebCore::SelectorDataList::execute): Ditto.
+ * dom/SelectorQuery.h:
+ (SelectorDataList): Updated decls.
+
2013-02-23 Eric Carlson <[email protected]>
[Mac] user preference caption style applied incorrectly
Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (143857 => 143858)
--- trunk/Source/WebCore/css/SelectorChecker.cpp 2013-02-24 05:31:10 UTC (rev 143857)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp 2013-02-24 06:18:41 UTC (rev 143858)
@@ -50,7 +50,6 @@
#include "RenderStyle.h"
#include "ScrollableArea.h"
#include "ScrollbarTheme.h"
-#include "SelectorCheckerFastPath.h"
#include "ShadowRoot.h"
#include "SiblingTraversalStrategies.h"
#include "StyledElement.h"
@@ -71,19 +70,6 @@
{
}
-bool SelectorChecker::matches(const CSSSelector* selector, Element* element, bool isFastCheckableSelector) const
-{
- if (isFastCheckableSelector && !element->isSVGElement()) {
- SelectorCheckerFastPath selectorCheckerFastPath(selector, element);
- if (!selectorCheckerFastPath.matchesRightmostSelector(VisitedMatchDisabled))
- return false;
- return selectorCheckerFastPath.matches();
- }
-
- PseudoId ignoreDynamicPseudo = NOPSEUDO;
- return match(SelectorCheckingContext(selector, element, SelectorChecker::VisitedMatchDisabled), ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorMatches;
-}
-
// Recursive check of selectors and combinators
// It can return 4 different values:
// * SelectorMatches - the selector matches the element e
Modified: trunk/Source/WebCore/css/SelectorChecker.h (143857 => 143858)
--- trunk/Source/WebCore/css/SelectorChecker.h 2013-02-24 05:31:10 UTC (rev 143857)
+++ trunk/Source/WebCore/css/SelectorChecker.h 2013-02-24 06:18:41 UTC (rev 143858)
@@ -82,7 +82,6 @@
BehaviorAtBoundary behaviorAtBoundary;
};
- bool matches(const CSSSelector*, Element*, bool isFastCheckableSelector = false) const;
template<typename SiblingTraversalStrategy>
Match match(const SelectorCheckingContext&, PseudoId&, const SiblingTraversalStrategy&) const;
template<typename SiblingTraversalStrategy>
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (143857 => 143858)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2013-02-24 05:31:10 UTC (rev 143857)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2013-02-24 06:18:41 UTC (rev 143858)
@@ -2115,9 +2115,12 @@
return false;
SelectorChecker selectorChecker(document(), SelectorChecker::QueryingRules);
- for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
- if (selectorChecker.matches(s, regionElement))
+ 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, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches)
return true;
+ }
return false;
}
Modified: trunk/Source/WebCore/dom/SelectorQuery.cpp (143857 => 143858)
--- trunk/Source/WebCore/dom/SelectorQuery.cpp 2013-02-24 05:31:10 UTC (rev 143857)
+++ trunk/Source/WebCore/dom/SelectorQuery.cpp 2013-02-24 06:18:41 UTC (rev 143858)
@@ -31,6 +31,7 @@
#include "Document.h"
#include "SelectorChecker.h"
#include "SelectorCheckerFastPath.h"
+#include "SiblingTraversalStrategies.h"
#include "StaticNodeList.h"
#include "StyledElement.h"
@@ -49,14 +50,28 @@
m_selectors.uncheckedAppend(SelectorData(selector, SelectorCheckerFastPath::canUse(selector)));
}
+inline bool SelectorDataList::selectorMatches(const SelectorData& selectorData, Element* element) const
+{
+ if (selectorData.isFastCheckable && !element->isSVGElement()) {
+ SelectorCheckerFastPath selectorCheckerFastPath(selectorData.selector, element);
+ if (!selectorCheckerFastPath.matchesRightmostSelector(SelectorChecker::VisitedMatchDisabled))
+ return false;
+ return selectorCheckerFastPath.matches();
+ }
+
+ SelectorChecker selectorChecker(element->document(), SelectorChecker::ResolvingStyle);
+ SelectorChecker::SelectorCheckingContext selectorCheckingContext(selectorData.selector, element, SelectorChecker::VisitedMatchDisabled);
+ PseudoId ignoreDynamicPseudo = NOPSEUDO;
+ return selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches;
+}
+
bool SelectorDataList::matches(Element* targetElement) const
{
ASSERT(targetElement);
- SelectorChecker selectorChecker(targetElement->document(), SelectorChecker::ResolvingStyle);
unsigned selectorCount = m_selectors.size();
for (unsigned i = 0; i < selectorCount; ++i) {
- if (selectorChecker.matches(m_selectors[i].selector, targetElement, m_selectors[i].isFastCheckable))
+ if (selectorMatches(m_selectors[i], targetElement))
return true;
}
@@ -107,15 +122,13 @@
template <bool firstMatchOnly>
void SelectorDataList::execute(Node* rootNode, Vector<RefPtr<Node> >& matchedElements) const
{
- SelectorChecker selectorChecker(rootNode->document(), SelectorChecker::QueryingRules);
-
if (canUseIdLookup(rootNode)) {
ASSERT(m_selectors.size() == 1);
const CSSSelector* selector = m_selectors[0].selector;
Element* element = rootNode->treeScope()->getElementById(selector->value());
if (!element || !(isTreeScopeRoot(rootNode) || element->isDescendantOf(rootNode)))
return;
- if (selectorChecker.matches(m_selectors[0].selector, element, m_selectors[0].isFastCheckable))
+ if (selectorMatches(m_selectors[0], element))
matchedElements.append(element);
return;
}
@@ -127,7 +140,7 @@
if (n->isElementNode()) {
Element* element = static_cast<Element*>(n);
for (unsigned i = 0; i < selectorCount; ++i) {
- if (selectorChecker.matches(m_selectors[i].selector, element, m_selectors[i].isFastCheckable)) {
+ if (selectorMatches(m_selectors[i], element)) {
matchedElements.append(element);
if (firstMatchOnly)
return;
Modified: trunk/Source/WebCore/dom/SelectorQuery.h (143857 => 143858)
--- trunk/Source/WebCore/dom/SelectorQuery.h 2013-02-24 05:31:10 UTC (rev 143857)
+++ trunk/Source/WebCore/dom/SelectorQuery.h 2013-02-24 06:18:41 UTC (rev 143858)
@@ -55,6 +55,7 @@
bool isFastCheckable;
};
+ bool selectorMatches(const SelectorData&, Element*) const;
bool canUseIdLookup(Node* rootNode) const;
template <bool firstMatchOnly>
void execute(Node* rootNode, Vector<RefPtr<Node> >&) const;