| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #include "core/dom/Element.h" | 27 #include "core/dom/Element.h" |
| 28 #include "core/dom/LiveNodeList.h" | 28 #include "core/dom/LiveNodeList.h" |
| 29 #include "wtf/text/AtomicString.h" | 29 #include "wtf/text/AtomicString.h" |
| 30 | 30 |
| 31 namespace WebCore { | 31 namespace WebCore { |
| 32 | 32 |
| 33 // NodeList that limits to a particular tag. | 33 // NodeList that limits to a particular tag. |
| 34 class TagNodeList : public LiveNodeList { | 34 class TagNodeList : public LiveNodeList { |
| 35 public: | 35 public: |
| 36 static PassRefPtr<TagNodeList> create(PassRefPtr<Node> rootNode, const Atomi
cString& namespaceURI, const AtomicString& localName) | 36 static PassRefPtr<TagNodeList> create(PassRefPtr<ContainerNode> rootNode, co
nst AtomicString& namespaceURI, const AtomicString& localName) |
| 37 { | 37 { |
| 38 ASSERT(namespaceURI != starAtom); | 38 ASSERT(namespaceURI != starAtom); |
| 39 return adoptRef(new TagNodeList(rootNode, TagNodeListType, namespaceURI,
localName)); | 39 return adoptRef(new TagNodeList(rootNode, TagNodeListType, namespaceURI,
localName)); |
| 40 } | 40 } |
| 41 | 41 |
| 42 static PassRefPtr<TagNodeList> create(PassRefPtr<Node> rootNode, CollectionT
ype type, const AtomicString& localName) | 42 static PassRefPtr<TagNodeList> create(PassRefPtr<ContainerNode> rootNode, Co
llectionType type, const AtomicString& localName) |
| 43 { | 43 { |
| 44 ASSERT_UNUSED(type, type == TagNodeListType); | 44 ASSERT_UNUSED(type, type == TagNodeListType); |
| 45 return adoptRef(new TagNodeList(rootNode, TagNodeListType, starAtom, loc
alName)); | 45 return adoptRef(new TagNodeList(rootNode, TagNodeListType, starAtom, loc
alName)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual ~TagNodeList(); | 48 virtual ~TagNodeList(); |
| 49 | 49 |
| 50 protected: | 50 protected: |
| 51 TagNodeList(PassRefPtr<Node> rootNode, CollectionType, const AtomicString& n
amespaceURI, const AtomicString& localName); | 51 TagNodeList(PassRefPtr<ContainerNode> rootNode, CollectionType, const Atomic
String& namespaceURI, const AtomicString& localName); |
| 52 | 52 |
| 53 virtual bool nodeMatches(const Element&) const OVERRIDE; | 53 virtual bool nodeMatches(const Element&) const OVERRIDE; |
| 54 | 54 |
| 55 AtomicString m_namespaceURI; | 55 AtomicString m_namespaceURI; |
| 56 AtomicString m_localName; | 56 AtomicString m_localName; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class HTMLTagNodeList FINAL : public TagNodeList { | 59 class HTMLTagNodeList FINAL : public TagNodeList { |
| 60 public: | 60 public: |
| 61 static PassRefPtr<HTMLTagNodeList> create(PassRefPtr<Node> rootNode, Collect
ionType type, const AtomicString& localName) | 61 static PassRefPtr<HTMLTagNodeList> create(PassRefPtr<ContainerNode> rootNode
, CollectionType type, const AtomicString& localName) |
| 62 { | 62 { |
| 63 ASSERT_UNUSED(type, type == HTMLTagNodeListType); | 63 ASSERT_UNUSED(type, type == HTMLTagNodeListType); |
| 64 return adoptRef(new HTMLTagNodeList(rootNode, localName)); | 64 return adoptRef(new HTMLTagNodeList(rootNode, localName)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool nodeMatchesInlined(const Element&) const; | 67 bool nodeMatchesInlined(const Element&) const; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 HTMLTagNodeList(PassRefPtr<Node> rootNode, const AtomicString& localName); | 70 HTMLTagNodeList(PassRefPtr<ContainerNode> rootNode, const AtomicString& loca
lName); |
| 71 | 71 |
| 72 virtual bool nodeMatches(const Element&) const OVERRIDE; | 72 virtual bool nodeMatches(const Element&) const OVERRIDE; |
| 73 | 73 |
| 74 AtomicString m_loweredLocalName; | 74 AtomicString m_loweredLocalName; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 inline bool HTMLTagNodeList::nodeMatchesInlined(const Element& testNode) const | 77 inline bool HTMLTagNodeList::nodeMatchesInlined(const Element& testNode) const |
| 78 { | 78 { |
| 79 // Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#conce
pt-getelementsbytagname | 79 // Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#conce
pt-getelementsbytagname |
| 80 if (m_localName != starAtom) { | 80 if (m_localName != starAtom) { |
| 81 const AtomicString& localName = testNode.isHTMLElement() ? m_loweredLoca
lName : m_localName; | 81 const AtomicString& localName = testNode.isHTMLElement() ? m_loweredLoca
lName : m_localName; |
| 82 if (localName != testNode.localName()) | 82 if (localName != testNode.localName()) |
| 83 return false; | 83 return false; |
| 84 } | 84 } |
| 85 ASSERT(m_namespaceURI == starAtom); | 85 ASSERT(m_namespaceURI == starAtom); |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace WebCore | 89 } // namespace WebCore |
| 90 | 90 |
| 91 #endif // TagNodeList_h | 91 #endif // TagNodeList_h |
| OLD | NEW |