Commits

ms2ger committed 35c0fc1

Fix include cycle.

  • Participants
  • Parent commits 38d62a5

Comments (0)

Files changed (1)

ListenerManager-ContextAllocPolicy

  using namespace mozilla;
  using dom::workers::events::ListenerManager;
  
-@@ -363,18 +363,18 @@ ListenerManager::DispatchEvent(JSContext
-   ListenerCollection* collection =
-     GetCollectionForType(&mCollectionHead,
-                          INTERNED_STRING_TO_JSID(aCx, eventType));
-   if (!collection) {
-     *aPreventDefaultCalled = false;
-     return true;
+@@ -312,16 +312,35 @@ ListenerManager::GetEventListener(JSCont
+         return true;
+       }
+     }
    }
- 
--  js::ContextAllocPolicy ap(aCx);
--  js::Vector<jsval, 10, js::ContextAllocPolicy> listeners(ap);
-+  js::ExternallyUsableContextAllocPolicy ap(aCx);
-+  js::Vector<jsval, 10, js::ExternallyUsableContextAllocPolicy> listeners(ap);
- 
-   for (PRCList* elem = PR_NEXT_LINK(&collection->mListenerHead);
-        elem != &collection->mListenerHead;
-        elem = PR_NEXT_LINK(elem)) {
-     Listener* listener = static_cast<Listener*>(elem);
- 
-     // Listeners that don't want untrusted events will be skipped if this is an
-     // untrusted event.
-diff --git a/js/src/jsalloc.h b/js/src/jsalloc.h
---- a/js/src/jsalloc.h
-+++ b/js/src/jsalloc.h
-@@ -111,11 +111,30 @@ class TempAllocPolicy
- 
-     void free_(void *p) {
-         js_free(p);
-     }
- 
-     JS_FRIEND_API(void) reportAllocOverflow() const;
- };
+   *aListenerVal = JSVAL_VOID;
+   return true;
+ }
  
 +class ExternallyUsableContextAllocPolicy
 +{
 +    }
 +    void *realloc_(void *p, size_t oldBytes, size_t bytes) {
 +        JSAutoRequest ar(cx);
-+        return JS_realloc(cx, bytes);
++        return JS_realloc(cx, p, bytes);
 +    }
 +    void free_(void *p) { JS_free(cx, p); }
 +    void reportAllocOverflow() const { JS_ReportAllocationOverflow(cx); }
 +};
 +
- } /* namespace js */
+ bool
+ ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
+                                JSObject* aEvent, bool* aPreventDefaultCalled)
+ {
+   if (!events::IsSupportedEventClass(aCx, aEvent)) {
+     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
+                          JSMSG_INCOMPATIBLE_METHOD,
+                          "EventTarget", "dispatchEvent", "Event object");
+@@ -363,18 +382,18 @@ ListenerManager::DispatchEvent(JSContext
+   ListenerCollection* collection =
+     GetCollectionForType(&mCollectionHead,
+                          INTERNED_STRING_TO_JSID(aCx, eventType));
+   if (!collection) {
+     *aPreventDefaultCalled = false;
+     return true;
+   }
  
- #endif /* jsalloc_h_ */
+-  js::ContextAllocPolicy ap(aCx);
+-  js::Vector<jsval, 10, js::ContextAllocPolicy> listeners(ap);
++  ExternallyUsableContextAllocPolicy ap(aCx);
++  js::Vector<jsval, 10, ExternallyUsableContextAllocPolicy> listeners(ap);
+ 
+   for (PRCList* elem = PR_NEXT_LINK(&collection->mListenerHead);
+        elem != &collection->mListenerHead;
+        elem = PR_NEXT_LINK(elem)) {
+     Listener* listener = static_cast<Listener*>(elem);
+ 
+     // Listeners that don't want untrusted events will be skipped if this is an
+     // untrusted event.