Chromium Code Reviews| Index: Source/core/dom/SelectorQuery.cpp |
| diff --git a/Source/core/dom/SelectorQuery.cpp b/Source/core/dom/SelectorQuery.cpp |
| index 6a5d428934d4258c09430f6dfa83f20f63bad1f4..71f709c09e718db0f1e8167245dc03c09a6fef54 100644 |
| --- a/Source/core/dom/SelectorQuery.cpp |
| +++ b/Source/core/dom/SelectorQuery.cpp |
| @@ -175,6 +175,17 @@ void SelectorDataList::collectElementsByClassName(ContainerNode& rootNode, const |
| } |
| } |
| +inline bool tagNameMatches(const QualifiedName& tagName, const Element& element) |
|
esprehn
2015/05/07 02:21:27
Can you add a comment for what this is about? (her
rune
2015/05/07 07:59:48
Done.
|
| +{ |
| + if (tagName == anyQName()) |
| + return true; |
| + if (element.hasLocalName(tagName.localName())) |
| + return true; |
| + if (element.isHTMLElement() || !element.document().isHTMLDocument()) |
| + return false; |
| + return equalIgnoringCase(tagName.localName(), element.localName()); |
| +} |
| + |
| template <typename SelectorQueryTrait> |
| void SelectorDataList::collectElementsByTagName(ContainerNode& rootNode, const QualifiedName& tagName, typename SelectorQueryTrait::OutputType& output) const |
| { |
| @@ -182,7 +193,7 @@ void SelectorDataList::collectElementsByTagName(ContainerNode& rootNode, const Q |
| // querySelector*() doesn't allow namespaces and throws before it gets |
| // here so we can ignore them. |
| ASSERT(tagName.namespaceURI() == starAtom); |
| - if (tagName == anyQName() || element.hasLocalName(tagName.localName())) { |
| + if (tagNameMatches(tagName, element)) { |
| SelectorQueryTrait::appendElement(output, element); |
| if (SelectorQueryTrait::shouldOnlyMatchFirstElement) |
| return; |