Index: Source/bindings/v8/V8CustomElementCallback.cpp |
diff --git a/Source/bindings/v8/V8CustomElementCallback.cpp b/Source/bindings/v8/V8CustomElementCallback.cpp |
index 14917b107280c7c35b835a40ac447ea4a80a2af8..d5d0d1228e8a8cff09c0c3edd99aee00335a4908 100644 |
--- a/Source/bindings/v8/V8CustomElementCallback.cpp |
+++ b/Source/bindings/v8/V8CustomElementCallback.cpp |
@@ -40,11 +40,15 @@ |
namespace WebCore { |
-PassRefPtr<V8CustomElementCallback> V8CustomElementCallback::create(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Object> owner, v8::Handle<v8::Function> ready) |
+PassRefPtr<V8CustomElementCallback> V8CustomElementCallback::create(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Object> owner, v8::Handle<v8::Function> ready, v8::Handle<v8::Function> inserted, v8::Handle<v8::Function> removed) |
{ |
if (!ready.IsEmpty()) |
owner->SetHiddenValue(V8HiddenPropertyName::customElementReady(), ready); |
- return adoptRef(new V8CustomElementCallback(scriptExecutionContext, ready)); |
+ if (!inserted.IsEmpty()) |
+ owner->SetHiddenValue(V8HiddenPropertyName::customElementInserted(), inserted); |
+ if (!removed.IsEmpty()) |
+ owner->SetHiddenValue(V8HiddenPropertyName::customElementRemoved(), removed); |
+ return adoptRef(new V8CustomElementCallback(scriptExecutionContext, ready, inserted, removed)); |
} |
static void weakCallback(v8::Isolate*, v8::Persistent<v8::Function>*, ScopedPersistent<v8::Function>* handle) |
@@ -52,18 +56,39 @@ static void weakCallback(v8::Isolate*, v8::Persistent<v8::Function>*, ScopedPers |
handle->clear(); |
} |
-V8CustomElementCallback::V8CustomElementCallback(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Function> ready) |
- : CustomElementCallback(ready.IsEmpty() ? None : Ready) |
+V8CustomElementCallback::V8CustomElementCallback(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Function> ready, v8::Handle<v8::Function> inserted, v8::Handle<v8::Function> removed) |
+ : CustomElementCallback(CallbackType((ready.IsEmpty() ? None : Ready) | (inserted.IsEmpty() ? None : Inserted) | (removed.IsEmpty() ? None : Removed))) |
, ActiveDOMCallback(scriptExecutionContext) |
, m_world(DOMWrapperWorld::current()) |
, m_ready(ready) |
+ , m_inserted(inserted) |
+ , m_removed(removed) |
{ |
if (!m_ready.isEmpty()) |
m_ready.makeWeak(&m_ready, weakCallback); |
+ if (!m_inserted.isEmpty()) |
+ m_inserted.makeWeak(&m_inserted, weakCallback); |
+ if (!m_removed.isEmpty()) |
+ m_removed.makeWeak(&m_removed, weakCallback); |
} |
void V8CustomElementCallback::ready(Element* element) |
{ |
+ invoke(m_ready, element); |
+} |
+ |
+void V8CustomElementCallback::inserted(Element* element) |
+{ |
+ invoke(m_inserted, element); |
+} |
+ |
+void V8CustomElementCallback::removed(Element* element) |
+{ |
+ invoke(m_removed, element); |
+} |
+ |
+void V8CustomElementCallback::invoke(const ScopedPersistent<v8::Function>& callback, Element* element) |
+{ |
if (!canInvokeCallback()) |
return; |
@@ -76,8 +101,8 @@ void V8CustomElementCallback::ready(Element* element) |
v8::Context::Scope scope(context); |
v8::Isolate* isolate = context->GetIsolate(); |
- v8::Handle<v8::Function> callback = m_ready.newLocal(isolate); |
- if (callback.IsEmpty()) |
+ v8::Handle<v8::Function> localCallback = callback.newLocal(isolate); |
+ if (localCallback.IsEmpty()) |
return; |
v8::Handle<v8::Value> elementHandle = toV8(element, context->Global(), isolate); |
@@ -92,7 +117,7 @@ void V8CustomElementCallback::ready(Element* element) |
v8::TryCatch exceptionCatcher; |
exceptionCatcher.SetVerbose(true); |
- ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, 0, 0); |
+ ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), localCallback, receiver, 0, 0); |
} |
} // namespace WebCore |