blob: d2e5cc29f9748702dc021b9e1421b2febf2a3bcb [file] [log] [blame]
darinb9481ed2006-03-20 02:57:59 +00001/*
darinb9481ed2006-03-20 02:57:59 +00002 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
darin@apple.com6b166602007-12-03 04:57:59 +00004 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
darinb9481ed2006-03-20 02:57:59 +00005 *
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
ddkilzerc8eccec2007-09-26 02:29:57 +000018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
darinb9481ed2006-03-20 02:57:59 +000020 *
21 */
22
eseidel8eddecf2007-01-16 00:49:43 +000023#ifndef HTMLNameCollection_h
24#define HTMLNameCollection_h
darinb9481ed2006-03-20 02:57:59 +000025
26#include "HTMLCollection.h"
kling@webkit.org04a91562012-01-01 00:56:01 +000027
28#include <wtf/text/AtomicString.h>
darinb9481ed2006-03-20 02:57:59 +000029
30namespace WebCore {
31
32class Document;
33
darin@apple.com6b166602007-12-03 04:57:59 +000034class HTMLNameCollection : public HTMLCollection {
darinb9481ed2006-03-20 02:57:59 +000035public:
rniwa@webkit.org4823cc12012-07-09 17:40:09 +000036 ~HTMLNameCollection();
37
rniwa@webkit.org068215b2013-05-07 00:20:05 +000038protected:
rniwa@webkit.org25c3d5e2012-11-27 19:58:46 +000039 HTMLNameCollection(Node*, CollectionType, const AtomicString& name);
darin@apple.com642f5002008-06-07 22:51:37 +000040
kling@webkit.org04a91562012-01-01 00:56:01 +000041 AtomicString m_name;
darinb9481ed2006-03-20 02:57:59 +000042};
43
rniwa@webkit.org068215b2013-05-07 00:20:05 +000044class WindowNameCollection : public HTMLNameCollection {
45public:
46 static PassRefPtr<WindowNameCollection> create(Node* document, CollectionType type, const AtomicString& name)
47 {
48 return adoptRef(new WindowNameCollection(document, type, name));
49 }
50
rniwa@webkit.orgc8bc2072013-08-12 21:50:06 +000051 bool nodeMatches(Element* element) const { return nodeMatches(element, m_name.impl()); }
rniwa@webkit.org068215b2013-05-07 00:20:05 +000052
53 static bool nodeMatchesIfIdAttributeMatch(Element*) { return true; }
54 static bool nodeMatchesIfNameAttributeMatch(Element*);
rniwa@webkit.orgc8bc2072013-08-12 21:50:06 +000055 static bool nodeMatches(Element*, const AtomicStringImpl*);
rniwa@webkit.org068215b2013-05-07 00:20:05 +000056
57private:
58 WindowNameCollection(Node* document, CollectionType type, const AtomicString& name)
59 : HTMLNameCollection(document, type, name)
60 {
61 ASSERT(type == WindowNamedItems);
62 }
63};
64
65class DocumentNameCollection : public HTMLNameCollection {
66public:
67 static PassRefPtr<DocumentNameCollection> create(Node* document, CollectionType type, const AtomicString& name)
68 {
69 return adoptRef(new DocumentNameCollection(document, type, name));
70 }
71
72 static bool nodeMatchesIfIdAttributeMatch(Element*);
73 static bool nodeMatchesIfNameAttributeMatch(Element*);
rniwa@webkit.orgc8bc2072013-08-12 21:50:06 +000074 bool nodeMatches(Element* element) const { return nodeMatches(element, m_name.impl()); }
rniwa@webkit.org068215b2013-05-07 00:20:05 +000075
rniwa@webkit.orgc8bc2072013-08-12 21:50:06 +000076 static bool nodeMatches(Element*, const AtomicStringImpl*);
rniwa@webkit.org068215b2013-05-07 00:20:05 +000077
78private:
79 DocumentNameCollection(Node* document, CollectionType type, const AtomicString& name)
80 : HTMLNameCollection(document, type, name)
81 {
82 ASSERT(type == DocumentNamedItems);
83 }
84};
85
darinb9481ed2006-03-20 02:57:59 +000086}
87
88#endif