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

Side by Side Diff: Source/bindings/v8/CustomElementConstructorBuilder.cpp

Issue 18789002: Implement Custom Elements' attributeChangedCallback. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Sync to tip. Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 PassRefPtr<CustomElementLifecycleCallbacks> CustomElementConstructorBuilder::cre ateCallbacks(Document* document) 143 PassRefPtr<CustomElementLifecycleCallbacks> CustomElementConstructorBuilder::cre ateCallbacks(Document* document)
144 { 144 {
145 ASSERT(!m_prototype.IsEmpty()); 145 ASSERT(!m_prototype.IsEmpty());
146 146
147 RefPtr<Document> protect(document); 147 RefPtr<Document> protect(document);
148 148
149 v8::TryCatch exceptionCatcher; 149 v8::TryCatch exceptionCatcher;
150 exceptionCatcher.SetVerbose(true); 150 exceptionCatcher.SetVerbose(true);
151 151
152 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 152 v8::Isolate* isolate = v8::Isolate::GetCurrent();
153 v8::Handle<v8::Value> createdValue = m_prototype->Get(v8String("createdCallb ack", isolate)); 153 v8::Handle<v8::Function> created = retrieveCallback(isolate, "createdCallbac k");
154 v8::Handle<v8::Function> attributeChanged = retrieveCallback(isolate, "attri buteChangedCallback");
154 155
155 v8::Handle<v8::Function> createdFunction; 156 return V8CustomElementLifecycleCallbacks::create(document, m_prototype, crea ted, attributeChanged);
156 if (!createdValue.IsEmpty() && createdValue->IsFunction()) 157 }
157 createdFunction = v8::Handle<v8::Function>::Cast(createdValue);
158 158
159 return V8CustomElementLifecycleCallbacks::create(document, m_prototype, crea tedFunction); 159 v8::Handle<v8::Function> CustomElementConstructorBuilder::retrieveCallback(v8::I solate* isolate, const char* name)
160 {
161 v8::Handle<v8::Value> value = m_prototype->Get(v8String(name, isolate));
162 if (value.IsEmpty() || !value->IsFunction())
163 return v8::Handle<v8::Function>();
164 return v8::Handle<v8::Function>::Cast(value);
160 } 165 }
161 166
162 bool CustomElementConstructorBuilder::createConstructor(Document* document, Cust omElementDefinition* definition) 167 bool CustomElementConstructorBuilder::createConstructor(Document* document, Cust omElementDefinition* definition)
163 { 168 {
164 ASSERT(!m_prototype.IsEmpty()); 169 ASSERT(!m_prototype.IsEmpty());
165 ASSERT(m_constructor.IsEmpty()); 170 ASSERT(m_constructor.IsEmpty());
166 ASSERT(document); 171 ASSERT(document);
167 172
168 v8::Isolate* isolate = m_context->GetIsolate(); 173 v8::Isolate* isolate = m_context->GetIsolate();
169 174
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; 290 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
286 RefPtr<Element> element = document->createElementNS(namespaceURI, name, mayb eType->IsNull() ? nullAtom : type, ec); 291 RefPtr<Element> element = document->createElementNS(namespaceURI, name, mayb eType->IsNull() ? nullAtom : type, ec);
287 if (ec) { 292 if (ec) {
288 setDOMException(ec, isolate); 293 setDOMException(ec, isolate);
289 return; 294 return;
290 } 295 }
291 v8SetReturnValue(args, toV8Fast(element.release(), args, document)); 296 v8SetReturnValue(args, toV8Fast(element.release(), args, document));
292 } 297 }
293 298
294 } // namespace WebCore 299 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/CustomElementConstructorBuilder.h ('k') | Source/bindings/v8/V8CustomElementLifecycleCallbacks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698