2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / WebCore / dom / EventNames.cpp
blob22a716dafbdf4b91e30a6534cef3306a0dc0310c
1 /*
2 * This file is part of the DOM implementation for KDE.
4 * Copyright (C) 2005 Apple Computer, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #include "config.h"
24 #include "EventNames.h"
26 #include <wtf/Threading.h>
28 #if ENABLE(WORKERS)
29 #include <wtf/ThreadSpecific.h>
30 using namespace WTF;
31 #endif
33 namespace WebCore {
35 #if ENABLE(WORKERS)
36 static ThreadSpecific<EventNames>* staticEventNames;
37 #else
38 static EventNames* staticEventNames;
39 #endif
41 #define INITIALIZE_EVENT_NAME(name) \
42 , name##Event(#name)
43 EventNames::EventNames()
44 : dummy(0)
45 DOM_EVENT_NAMES_FOR_EACH(INITIALIZE_EVENT_NAME)
49 EventNames& eventNames()
51 #if ENABLE(WORKERS)
52 return **staticEventNames;
53 #else
54 return *staticEventNames;
55 #endif
58 void EventNames::init()
60 if (!staticEventNames) {
61 // Initialization is not thread safe, so this function must be called from the main thread first.
62 ASSERT(isMainThread());
64 AtomicString::init();
66 #if ENABLE(WORKERS)
67 staticEventNames = new ThreadSpecific<EventNames>;
68 #else
69 staticEventNames = new EventNames;
70 #endif