2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
3 * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
5 * Copyright (C) 2009 Google, Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "DOMWrapperWorld.h"
25 #include "WebCoreBuiltinNames.h"
26 #include "WebCoreJSBuiltins.h"
27 #include <wtf/HashSet.h>
28 #include <wtf/RefPtr.h>
32 class JSVMClientData : public JSC::VM::ClientData {
33 WTF_MAKE_NONCOPYABLE(JSVMClientData); WTF_MAKE_FAST_ALLOCATED;
34 friend class VMWorldIterator;
37 explicit JSVMClientData(JSC::VM&);
39 virtual ~JSVMClientData();
41 WEBCORE_EXPORT static void initNormalWorld(JSC::VM*);
43 DOMWrapperWorld& normalWorld() { return *m_normalWorld; }
45 void getAllWorlds(Vector<Ref<DOMWrapperWorld>>&);
47 void rememberWorld(DOMWrapperWorld& world)
49 ASSERT(!m_worldSet.contains(&world));
50 m_worldSet.add(&world);
53 void forgetWorld(DOMWrapperWorld& world)
55 ASSERT(m_worldSet.contains(&world));
56 m_worldSet.remove(&world);
59 WebCoreBuiltinNames& builtinNames() { return m_builtinNames; }
60 JSBuiltinFunctions& builtinFunctions() { return m_builtinFunctions; }
62 JSC::Subspace& outputConstraintSpace() { return m_outputConstraintSpace; }
63 JSC::Subspace& globalObjectOutputConstraintSpace() { return m_globalObjectOutputConstraintSpace; }
65 template<typename Func>
66 void forEachOutputConstraintSpace(const Func& func)
68 func(m_outputConstraintSpace);
69 func(m_globalObjectOutputConstraintSpace);
73 HashSet<DOMWrapperWorld*> m_worldSet;
74 RefPtr<DOMWrapperWorld> m_normalWorld;
76 JSBuiltinFunctions m_builtinFunctions;
77 WebCoreBuiltinNames m_builtinNames;
79 JSC::JSDestructibleObjectSubspace m_outputConstraintSpace;
80 JSC::JSSegmentedVariableObjectSubspace m_globalObjectOutputConstraintSpace;
83 } // namespace WebCore