#include "config.h"
#include "core/dom/SelectorQuery.h"
-#include "bindings/v8/ExceptionState.h"
+#include "bindings/core/v8/ExceptionState.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/SelectorChecker.h"
#include "core/css/SiblingTraversalStrategies.h"
#include "core/dom/shadow/ElementShadow.h"
#include "core/dom/shadow/ShadowRoot.h"
-namespace WebCore {
+namespace blink {
struct SingleElementSelectorQueryTrait {
typedef Element* OutputType;
};
struct AllElementsSelectorQueryTrait {
- typedef WillBeHeapVector<RefPtrWillBeMember<Node> > OutputType;
+ typedef WillBeHeapVector<RefPtrWillBeMember<Element> > OutputType;
static const bool shouldOnlyMatchFirstElement = false;
- ALWAYS_INLINE static void appendElement(OutputType& output, Node& element)
+ ALWAYS_INLINE static void appendElement(OutputType& output, Element& element)
{
output.append(&element);
}
{
SelectorChecker selectorChecker(element.document(), SelectorChecker::QueryingRules);
SelectorChecker::SelectorCheckingContext selectorCheckingContext(selector, &element, SelectorChecker::VisitedMatchDisabled);
- selectorCheckingContext.behaviorAtBoundary = SelectorChecker::StaysWithinTreeScope;
selectorCheckingContext.scope = !rootNode.isDocumentNode() ? &rootNode : 0;
+ if (selectorCheckingContext.scope)
+ selectorCheckingContext.contextFlags = SelectorChecker::ScopeContainsLastMatchedElement;
return selectorChecker.match(selectorCheckingContext, DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches;
}
return false;
}
-PassRefPtrWillBeRawPtr<StaticNodeList> SelectorDataList::queryAll(ContainerNode& rootNode) const
+PassRefPtrWillBeRawPtr<StaticElementList> SelectorDataList::queryAll(ContainerNode& rootNode) const
{
- WillBeHeapVector<RefPtrWillBeMember<Node> > result;
+ WillBeHeapVector<RefPtrWillBeMember<Element> > result;
execute<AllElementsSelectorQueryTrait>(rootNode, result);
- return StaticNodeList::adopt(result);
+ return StaticElementList::adopt(result);
}
PassRefPtrWillBeRawPtr<Element> SelectorDataList::queryFirst(ContainerNode& rootNode) const
if (const CSSSelector* idSelector = selectorForIdLookup(firstSelector)) {
const AtomicString& idToMatch = idSelector->value();
if (rootNode.treeScope().containsMultipleElementsWithId(idToMatch)) {
- const Vector<Element*>& elements = rootNode.treeScope().getAllElementsById(idToMatch);
+ const WillBeHeapVector<RawPtrWillBeMember<Element> >& elements = rootNode.treeScope().getAllElementsById(idToMatch);
size_t count = elements.size();
for (size_t i = 0; i < count; ++i) {
Element& element = *elements[i];
return m_selectors.matches(element);
}
-PassRefPtrWillBeRawPtr<StaticNodeList> SelectorQuery::queryAll(ContainerNode& rootNode) const
+PassRefPtrWillBeRawPtr<StaticElementList> SelectorQuery::queryAll(ContainerNode& rootNode) const
{
return m_selectors.queryAll(rootNode);
}