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

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: Feedback+test 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
« no previous file with comments | « Source/bindings/v8/CustomElementHelpers.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/CustomElementHelpers.cpp
diff --git a/Source/bindings/v8/CustomElementHelpers.cpp b/Source/bindings/v8/CustomElementHelpers.cpp
index ee25362c84aca44a5f55c3d7c43abfebf2bc73a5..f86ab7f2f1a57eee29b339d061e6e9d72b241661 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"
@@ -246,6 +247,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());
« no previous file with comments | « Source/bindings/v8/CustomElementHelpers.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698