2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2000 Frederik Holljen (frederik.holljen@hig.no)
4 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
5 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2004, 2008, 2009 Apple Inc. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
28 #include "DOMWrapperWorld.h"
29 #include "NodeFilterCondition.h"
30 #include <wtf/RefPtr.h>
34 class NodeFilter : public RefCounted<NodeFilter> {
37 * The following constants are returned by the acceptNode()
47 * These are the available values for the whatToShow parameter.
48 * They are the same as the set of possible types for Node, and
49 * their values are derived by using a bit position corresponding
50 * to the value of NodeType for the equivalent node type.
53 SHOW_ALL = 0xFFFFFFFF,
54 SHOW_ELEMENT = 0x00000001,
55 SHOW_ATTRIBUTE = 0x00000002,
56 SHOW_TEXT = 0x00000004,
57 SHOW_CDATA_SECTION = 0x00000008,
58 SHOW_ENTITY_REFERENCE = 0x00000010,
59 SHOW_ENTITY = 0x00000020,
60 SHOW_PROCESSING_INSTRUCTION = 0x00000040,
61 SHOW_COMMENT = 0x00000080,
62 SHOW_DOCUMENT = 0x00000100,
63 SHOW_DOCUMENT_TYPE = 0x00000200,
64 SHOW_DOCUMENT_FRAGMENT = 0x00000400,
65 SHOW_NOTATION = 0x00000800
68 static PassRefPtr<NodeFilter> create(PassRefPtr<NodeFilterCondition> condition)
70 return adoptRef(new NodeFilter(condition));
73 static PassRefPtr<NodeFilter> create()
75 return adoptRef(new NodeFilter());
78 short acceptNode(ScriptState*, Node*) const;
80 // Do not call these functions. They are just scaffolding to support the Objective-C bindings.
81 // They operate in the main thread normal world, and they swallow JS exceptions.
82 short acceptNode(Node* node) const { return acceptNode(scriptStateFromNode(mainThreadNormalWorld(), node), node); }
84 void setCondition(PassRefPtr<NodeFilterCondition> condition) { ASSERT(!m_condition); m_condition = condition; }
87 NodeFilter(PassRefPtr<NodeFilterCondition> condition) : m_condition(condition) { }
90 RefPtr<NodeFilterCondition> m_condition;
93 } // namespace WebCore
95 #endif // NodeFilter_h