1/*
2 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 *  Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
4 *
5 *  This library is free software; you can redistribute it and/or
6 *  modify it under the terms of the GNU Lesser General Public
7 *  License as published by the Free Software Foundation; either
8 *  version 2 of the License, or (at your option) any later version.
9 *
10 *  This library is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 *  Lesser General Public License for more details.
14 *
15 *  You should have received a copy of the GNU Lesser General Public
16 *  License along with this library; if not, write to the Free Software
17 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20#ifndef JSNodeFilterCondition_h
21#define JSNodeFilterCondition_h
22
23#include "NodeFilterCondition.h"
24#include <heap/Weak.h>
25#include <runtime/JSValue.h>
26#include <wtf/PassRefPtr.h>
27
28namespace WebCore {
29
30    class Node;
31    class NodeFilter;
32
33    class JSNodeFilterCondition : public NodeFilterCondition {
34    public:
35        static PassRefPtr<JSNodeFilterCondition> create(JSC::JSGlobalData& globalData, NodeFilter* owner, JSC::JSValue filter)
36        {
37            return adoptRef(new JSNodeFilterCondition(globalData, owner, filter));
38        }
39
40    private:
41        JSNodeFilterCondition(JSC::JSGlobalData&, NodeFilter* owner, JSC::JSValue filter);
42
43        virtual short acceptNode(ScriptState*, Node*) const;
44
45        class WeakOwner : public JSC::WeakHandleOwner {
46            virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
47        };
48        WeakOwner m_weakOwner;
49        mutable JSC::Weak<JSC::Unknown> m_filter;
50    };
51
52} // namespace WebCore
53
54#endif // JSNodeFilterCondition_h
55