Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: Source/bindings/v8/CustomElementConstructorBuilder.cpp

Issue 17707002: Implement Custom Elements inserted and removed callbacks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/v8/CustomElementConstructorBuilder.cpp
diff --git a/Source/bindings/v8/CustomElementConstructorBuilder.cpp b/Source/bindings/v8/CustomElementConstructorBuilder.cpp
index 315ed0516da9b200ee5987952eecbb494281ae4b..8318dd5ee26936c74c526deb80ffd4cf0db970fe 100644
--- a/Source/bindings/v8/CustomElementConstructorBuilder.cpp
+++ b/Source/bindings/v8/CustomElementConstructorBuilder.cpp
@@ -140,17 +140,24 @@ PassRefPtr<CustomElementCallback> CustomElementConstructorBuilder::createCallbac
RefPtr<Document> protect(document);
+ v8::Handle<v8::Function> ready = retrieveCallback("readyCallback");
+ v8::Handle<v8::Function> inserted = retrieveCallback("insertedCallback");
+ v8::Handle<v8::Function> removed = retrieveCallback("removedCallback");
+
+ return V8CustomElementCallback::create(document, m_prototype, ready, inserted, removed);
+}
+
+v8::Handle<v8::Function> CustomElementConstructorBuilder::retrieveCallback(const char* name) const
+{
v8::TryCatch exceptionCatcher;
exceptionCatcher.SetVerbose(true);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::Handle<v8::Value> readyValue = m_prototype->Get(v8String("readyCallback", isolate));
-
- v8::Handle<v8::Function> readyFunction;
- if (!readyValue.IsEmpty() && readyValue->IsFunction())
- readyFunction = v8::Handle<v8::Function>::Cast(readyValue);
+ v8::Handle<v8::Value> value = m_prototype->Get(v8String(name, isolate));
abarth-chromium 2013/06/25 21:13:56 Would you be willing to add a test that hooks each
+ if (value.IsEmpty() || !value->IsFunction())
+ return v8::Handle<v8::Function>();
- return V8CustomElementCallback::create(document, m_prototype, readyFunction);
+ return v8::Handle<v8::Function>::Cast(value);
}
bool CustomElementConstructorBuilder::createConstructor(Document* document, CustomElementDefinition* definition)
@@ -277,12 +284,12 @@ static void constructCustomElement(const v8::FunctionCallbackInfo<v8::Value>& ar
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, maybeType);
ExceptionCode ec = 0;
- CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
RefPtr<Element> element = document->createElementNS(namespaceURI, name, maybeType->IsNull() ? nullAtom : type, ec);
if (ec) {
setDOMException(ec, isolate);
return;
}
+ CustomElementCallbackDispatcher::instance().dispatchReadyCallback(element.get());
v8SetReturnValue(args, toV8Fast(element.release(), args, document));
}

Powered by Google App Engine
This is Rietveld 408576698