/src/3rdparty/webkit/Source/WebCore/html/HTMLCollection.h

https://bitbucket.org/ultra_iter/qt-vtl · C Header · 87 lines · 44 code · 22 blank · 21 comment · 0 complexity · 7e383ce0a99f0f7d722aa257e2105802 MD5 · raw file

  1. /*
  2. * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  3. * (C) 1999 Antti Koivisto (koivisto@kde.org)
  4. * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public License
  17. * along with this library; see the file COPYING.LIB. If not, write to
  18. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19. * Boston, MA 02110-1301, USA.
  20. *
  21. */
  22. #ifndef HTMLCollection_h
  23. #define HTMLCollection_h
  24. #include "CollectionType.h"
  25. #include <wtf/RefCounted.h>
  26. #include <wtf/Forward.h>
  27. #include <wtf/HashMap.h>
  28. #include <wtf/Vector.h>
  29. namespace WebCore {
  30. class Element;
  31. class Node;
  32. class NodeList;
  33. struct CollectionCache;
  34. class HTMLCollection : public RefCounted<HTMLCollection> {
  35. public:
  36. static PassRefPtr<HTMLCollection> create(PassRefPtr<Node> base, CollectionType);
  37. virtual ~HTMLCollection();
  38. unsigned length() const;
  39. virtual Node* item(unsigned index) const;
  40. virtual Node* nextItem() const;
  41. virtual Node* namedItem(const AtomicString& name) const;
  42. virtual Node* nextNamedItem(const AtomicString& name) const; // In case of multiple items named the same way
  43. Node* firstItem() const;
  44. void namedItems(const AtomicString& name, Vector<RefPtr<Node> >&) const;
  45. PassRefPtr<NodeList> tags(const String&);
  46. Node* base() const { return m_base.get(); }
  47. CollectionType type() const { return m_type; }
  48. protected:
  49. HTMLCollection(PassRefPtr<Node> base, CollectionType, CollectionCache*);
  50. HTMLCollection(PassRefPtr<Node> base, CollectionType);
  51. CollectionCache* info() const { return m_info; }
  52. void resetCollectionInfo() const;
  53. mutable bool m_idsDone; // for nextNamedItem()
  54. private:
  55. virtual Element* itemAfter(Element*) const;
  56. virtual unsigned calcLength() const;
  57. virtual void updateNameCache() const;
  58. bool checkForNameMatch(Element*, bool checkName, const AtomicString& name) const;
  59. RefPtr<Node> m_base;
  60. CollectionType m_type;
  61. mutable CollectionCache* m_info;
  62. mutable bool m_ownsInfo;
  63. };
  64. } // namespace
  65. #endif