Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / dom / NodeFilter.h
1 /*
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.
7  *
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.
12  *
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.
17  *
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.
22  *
23  */
24
25 #ifndef NodeFilter_h
26 #define NodeFilter_h
27
28 #include "bindings/core/v8/ScriptWrappable.h"
29 #include "core/dom/NodeFilterCondition.h"
30 #include "platform/heap/Handle.h"
31 #include "wtf/RefPtr.h"
32
33 namespace blink {
34
35 class NodeFilter final : public RefCountedWillBeGarbageCollected<NodeFilter>, public ScriptWrappable {
36     DEFINE_WRAPPERTYPEINFO();
37 public:
38     /**
39      * The following constants are returned by the acceptNode()
40      * method:
41      */
42     enum {
43         FILTER_ACCEPT = 1,
44         FILTER_REJECT = 2,
45         FILTER_SKIP   = 3
46     };
47
48     /**
49      * These are the available values for the whatToShow parameter.
50      * They are the same as the set of possible types for Node, and
51      * their values are derived by using a bit position corresponding
52      * to the value of NodeType for the equivalent node type.
53      */
54     enum {
55         SHOW_ALL                       = 0xFFFFFFFF,
56         SHOW_ELEMENT                   = 0x00000001,
57         SHOW_ATTRIBUTE                 = 0x00000002,
58         SHOW_TEXT                      = 0x00000004,
59         SHOW_CDATA_SECTION             = 0x00000008,
60         SHOW_ENTITY_REFERENCE          = 0x00000010,
61         SHOW_ENTITY                    = 0x00000020,
62         SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
63         SHOW_COMMENT                   = 0x00000080,
64         SHOW_DOCUMENT                  = 0x00000100,
65         SHOW_DOCUMENT_TYPE             = 0x00000200,
66         SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
67         SHOW_NOTATION                  = 0x00000800
68     };
69
70     static PassRefPtrWillBeRawPtr<NodeFilter> create(PassRefPtrWillBeRawPtr<NodeFilterCondition> condition)
71     {
72         return adoptRefWillBeNoop(new NodeFilter(condition));
73     }
74
75     static PassRefPtrWillBeRawPtr<NodeFilter> create()
76     {
77         return adoptRefWillBeNoop(new NodeFilter());
78     }
79
80     short acceptNode(Node*, ExceptionState&) const;
81
82     void setCondition(PassRefPtrWillBeRawPtr<NodeFilterCondition> condition)
83     {
84         m_condition = condition;
85     }
86
87     void trace(Visitor*);
88
89 private:
90     explicit NodeFilter(PassRefPtrWillBeRawPtr<NodeFilterCondition> condition) : m_condition(condition) { }
91
92     NodeFilter() { }
93
94     RefPtrWillBeMember<NodeFilterCondition> m_condition;
95 };
96
97 } // namespace blink
98
99 #endif // NodeFilter_h