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

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

Issue 14626005: Upgrade elements that are created before a custom element definition is registered (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Moar^2 better Created 7 years, 8 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/CustomElementHelpers.cpp
diff --git a/Source/bindings/v8/CustomElementHelpers.cpp b/Source/bindings/v8/CustomElementHelpers.cpp
index 674f4e97ef0ce62aca5b954088a12a4631b3fdf3..6c950a1c32cf2b664552f4f260b49f0aa0141ded 100644
--- a/Source/bindings/v8/CustomElementHelpers.cpp
+++ b/Source/bindings/v8/CustomElementHelpers.cpp
@@ -35,6 +35,7 @@
#include "HTMLNames.h"
#include "V8CustomElementConstructor.h"
#include "V8HTMLElementWrapperFactory.h"
+#include "bindings/v8/DOMDataStore.h"
#include "bindings/v8/DOMWrapperWorld.h"
#include "bindings/v8/ScriptController.h"
#include "core/dom/CustomElementRegistry.h"
@@ -242,6 +243,28 @@ const QualifiedName* CustomElementHelpers::findLocalName(v8::Handle<v8::Object>
return 0;
}
+void CustomElementHelpers::upgradeWrappers(ScriptExecutionContext* executionContext, const HashSet<Element*>& elements, const ScriptValue& prototype)
+{
+ if (elements.isEmpty())
+ return;
+
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Context> context = toV8Context(executionContext, mainThreadNormalWorld());
+ v8::Context::Scope scope(context);
+
+ v8::Handle<v8::Value> v8Prototype = prototype.v8Value();
+
+ for (HashSet<Element*>::const_iterator it = elements.begin(); it != elements.end(); ++it) {
+ v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperForMainWorld(*it);
+ if (wrapper.IsEmpty()) {
+ // The wrapper will be created with the right prototype when
+ // retrieved; we don't need to eagerly create the wrapper.
+ continue;
+ }
+ wrapper->SetPrototype(v8Prototype);
+ }
+}
+
void CustomElementHelpers::invokeReadyCallbackIfNeeded(Element* element, v8::Handle<v8::Context> context)
{
v8::Handle<v8::Value> wrapperValue = toV8(element, context->Global(), context->GetIsolate());

Powered by Google App Engine
This is Rietveld 408576698