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 <heap/WeakInlines.h>
26#include <runtime/JSCInlines.h>
27#include <runtime/JSCJSValue.h>
28#include <wtf/PassRefPtr.h>
29
30namespace WebCore {
31
32    class Node;
33    class NodeFilter;
34
35    class JSNodeFilterCondition : public NodeFilterCondition {
36    public:
37        static PassRefPtr<JSNodeFilterCondition> create(JSC::VM& vm, NodeFilter* owner, JSC::JSValue filter)
38        {
39            return adoptRef(new JSNodeFilterCondition(vm, owner, filter));
40        }
41
42    private:
43        JSNodeFilterCondition(JSC::VM&, NodeFilter* owner, JSC::JSValue filter);
44
45        virtual short acceptNode(JSC::ExecState*, Node*) const;
46
47        class WeakOwner : public JSC::WeakHandleOwner {
48            virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&);
49        };
50        WeakOwner m_weakOwner;
51        mutable JSC::Weak<JSC::JSObject> m_filter;
52    };
53
54} // namespace WebCore
55
56#endif // JSNodeFilterCondition_h
57