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

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

Issue 19002005: Share Custom Element registration contexts between related documents. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tweak the test to do lazy wrapping in both cases. 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
« no previous file with comments | « Source/bindings/v8/CustomElementConstructorBuilder.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « Source/bindings/v8/CustomElementConstructorBuilder.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698