OLD | NEW |
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 if (m_namespaceURI != nullAtom) { | 138 if (m_namespaceURI != nullAtom) { |
139 // Use the custom element type as the tag's local name. | 139 // Use the custom element type as the tag's local name. |
140 tagName = QualifiedName(nullAtom, customElementType, m_namespaceURI); | 140 tagName = QualifiedName(nullAtom, customElementType, m_namespaceURI); |
141 return true; | 141 return true; |
142 } | 142 } |
143 | 143 |
144 return false; | 144 return false; |
145 } | 145 } |
146 | 146 |
147 PassRefPtr<CustomElementLifecycleCallbacks> CustomElementConstructorBuilder::cre
ateCallbacks(Document* document) | 147 PassRefPtr<CustomElementLifecycleCallbacks> CustomElementConstructorBuilder::cre
ateCallbacks() |
148 { | 148 { |
149 ASSERT(!m_prototype.IsEmpty()); | 149 ASSERT(!m_prototype.IsEmpty()); |
150 | 150 |
151 RefPtr<Document> protect(document); | 151 RefPtr<ScriptExecutionContext> scriptExecutionContext = toScriptExecutionCon
text(m_context); |
152 | 152 |
153 v8::TryCatch exceptionCatcher; | 153 v8::TryCatch exceptionCatcher; |
154 exceptionCatcher.SetVerbose(true); | 154 exceptionCatcher.SetVerbose(true); |
155 | 155 |
156 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 156 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
157 v8::Handle<v8::Function> created = retrieveCallback(isolate, "createdCallbac
k"); | 157 v8::Handle<v8::Function> created = retrieveCallback(isolate, "createdCallbac
k"); |
158 v8::Handle<v8::Function> enteredDocument = retrieveCallback(isolate, "entere
dDocumentCallback"); | 158 v8::Handle<v8::Function> enteredDocument = retrieveCallback(isolate, "entere
dDocumentCallback"); |
159 v8::Handle<v8::Function> leftDocument = retrieveCallback(isolate, "leftDocum
entCallback"); | 159 v8::Handle<v8::Function> leftDocument = retrieveCallback(isolate, "leftDocum
entCallback"); |
160 v8::Handle<v8::Function> attributeChanged = retrieveCallback(isolate, "attri
buteChangedCallback"); | 160 v8::Handle<v8::Function> attributeChanged = retrieveCallback(isolate, "attri
buteChangedCallback"); |
161 | 161 |
162 return V8CustomElementLifecycleCallbacks::create(document, m_prototype, crea
ted, enteredDocument, leftDocument, attributeChanged); | 162 return V8CustomElementLifecycleCallbacks::create(scriptExecutionContext.get(
), m_prototype, created, enteredDocument, leftDocument, attributeChanged); |
163 } | 163 } |
164 | 164 |
165 v8::Handle<v8::Function> CustomElementConstructorBuilder::retrieveCallback(v8::I
solate* isolate, const char* name) | 165 v8::Handle<v8::Function> CustomElementConstructorBuilder::retrieveCallback(v8::I
solate* isolate, const char* name) |
166 { | 166 { |
167 v8::Handle<v8::Value> value = m_prototype->Get(v8String(name, isolate)); | 167 v8::Handle<v8::Value> value = m_prototype->Get(v8String(name, isolate)); |
168 if (value.IsEmpty() || !value->IsFunction()) | 168 if (value.IsEmpty() || !value->IsFunction()) |
169 return v8::Handle<v8::Function>(); | 169 return v8::Handle<v8::Function>(); |
170 return value.As<v8::Function>(); | 170 return value.As<v8::Function>(); |
171 } | 171 } |
172 | 172 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 311 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
312 RefPtr<Element> element = document->createElementNS(namespaceURI, tagName, m
aybeType->IsNull() ? nullAtom : type, ec); | 312 RefPtr<Element> element = document->createElementNS(namespaceURI, tagName, m
aybeType->IsNull() ? nullAtom : type, ec); |
313 if (ec) { | 313 if (ec) { |
314 setDOMException(ec, isolate); | 314 setDOMException(ec, isolate); |
315 return; | 315 return; |
316 } | 316 } |
317 v8SetReturnValue(args, toV8Fast(element.release(), args, document)); | 317 v8SetReturnValue(args, toV8Fast(element.release(), args, document)); |
318 } | 318 } |
319 | 319 |
320 } // namespace WebCore | 320 } // namespace WebCore |
OLD | NEW |