Modified: trunk/Source/WebCore/ChangeLog (98065 => 98066)
--- trunk/Source/WebCore/ChangeLog 2011-10-21 05:14:06 UTC (rev 98065)
+++ trunk/Source/WebCore/ChangeLog 2011-10-21 05:43:00 UTC (rev 98066)
@@ -1,3 +1,15 @@
+2011-10-20 Adam Barth <aba...@webkit.org>
+
+ Attemp to fix a bunch of tests PLATFORM(MAC). We can't use a static
+ map because that's shared between threads (and events exist in worker
+ threads). It migh be better to add a thread-specific map, but we can
+ do that in another patch.
+
+ * bindings/js/JSEventCustom.cpp:
+ (WebCore::toJS):
+ * bindings/v8/custom/V8EventCustom.cpp:
+ (WebCore::toV8):
+
2011-10-20 Simon Fraser <simon.fra...@apple.com>
Hidden composited iframes cause infinite loop
Modified: trunk/Source/WebCore/bindings/js/JSEventCustom.cpp (98065 => 98066)
--- trunk/Source/WebCore/bindings/js/JSEventCustom.cpp 2011-10-21 05:14:06 UTC (rev 98065)
+++ trunk/Source/WebCore/bindings/js/JSEventCustom.cpp 2011-10-21 05:43:00 UTC (rev 98066)
@@ -48,17 +48,10 @@
return impl()->isClipboardEvent() ? toJS(exec, globalObject(), impl()->clipboardData()) : jsUndefined();
}
-#define DECLARE_EVENT_WRAPPER(interfaceName) \
- static JSDOMWrapper* create##interfaceName##Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event) \
- { \
- return CREATE_DOM_WRAPPER(exec, globalObject, interfaceName, event); \
- } \
+#define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \
+ if (eventNames().interfaceFor##interfaceName == desiredInterface) \
+ return CREATE_DOM_WRAPPER(exec, globalObject, interfaceName, event);
-DOM_EVENT_INTERFACES_FOR_EACH(DECLARE_EVENT_WRAPPER)
-
-#define ADD_WRAPPER_TO_MAP(interfaceName) \
- map.add(eventNames().interfaceFor##interfaceName.impl(), create##interfaceName##Wrapper);
-
JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event)
{
JSLock lock(SilenceAssertionsOnly);
@@ -70,18 +63,9 @@
if (wrapper)
return wrapper;
- typedef JSDOMWrapper* (*CreateEventWrapperFunction)(ExecState*, JSDOMGlobalObject*, Event*);
- typedef HashMap<WTF::AtomicStringImpl*, CreateEventWrapperFunction> FunctionMap;
+ String desiredInterface = event->interfaceName();
+ DOM_EVENT_INTERFACES_FOR_EACH(TRY_TO_WRAP_WITH_INTERFACE)
- DEFINE_STATIC_LOCAL(FunctionMap, map, ());
- if (map.isEmpty()) {
- DOM_EVENT_INTERFACES_FOR_EACH(ADD_WRAPPER_TO_MAP)
- }
-
- CreateEventWrapperFunction createWrapperFunction = map.get(event->interfaceName().impl());
- if (createWrapperFunction)
- return createWrapperFunction(exec, globalObject, event);
-
return CREATE_DOM_WRAPPER(exec, globalObject, Event, event);
}
Modified: trunk/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp (98065 => 98066)
--- trunk/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp 2011-10-21 05:14:06 UTC (rev 98065)
+++ trunk/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp 2011-10-21 05:43:00 UTC (rev 98066)
@@ -69,37 +69,23 @@
return v8::Undefined();
}
-#define DECLARE_EVENT_WRAPPER(interfaceName) \
- static v8::Handle<v8::Value> toV8##interfaceName(Event* event) \
- { \
- return toV8(static_cast<interfaceName*>(event)); \
- } \
+#define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \
+ if (eventNames().interfaceFor##interfaceName == desiredInterface) \
+ return toV8(static_cast<interfaceName*>(event));
-DOM_EVENT_INTERFACES_FOR_EACH(DECLARE_EVENT_WRAPPER)
-
-#define ADD_WRAPPER_TO_MAP(interfaceName) \
- map.add(eventNames().interfaceFor##interfaceName.impl(), toV8##interfaceName);
-
v8::Handle<v8::Value> toV8(Event* event)
{
if (!event)
return v8::Null();
- if (event->interfaceName() == eventNames().interfaceForEvent)
+ String desiredInterface = event->interfaceName();
+
+ // We need to check Event first to avoid infinite recursion.
+ if (eventNames().interfaceForEvent == desiredInterface)
return V8Event::wrap(event);
- typedef v8::Handle<v8::Value> (*ToV8Function)(Event*);
- typedef HashMap<WTF::AtomicStringImpl*, ToV8Function> FunctionMap;
+ DOM_EVENT_INTERFACES_FOR_EACH(TRY_TO_WRAP_WITH_INTERFACE)
- DEFINE_STATIC_LOCAL(FunctionMap, map, ());
- if (map.isEmpty()) {
- DOM_EVENT_INTERFACES_FOR_EACH(ADD_WRAPPER_TO_MAP)
- }
-
- ToV8Function specializedToV8 = map.get(event->interfaceName().impl());
- if (specializedToV8)
- return specializedToV8(event);
-
return V8Event::wrap(event);
}