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

Unified Diff: Source/core/dom/Element.cpp

Issue 531183003: bindings: Retires manual dispatching in createV8{HTML,SVG}Wrapper, etc. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added FIXME comments. Created 6 years, 3 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/core/dom/Element.h ('k') | Source/core/dom/Node.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 7f7a9a06ab6a6cc3ac920dbf1a2572a23eb3d8a8..474912b54c8a4017c0b495350d3fe5681082a69e 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -26,9 +26,12 @@
#include "config.h"
#include "core/dom/Element.h"
+#include "bindings/core/v8/DOMDataStore.h"
#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ExceptionMessages.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/V8DOMWrapper.h"
+#include "bindings/core/v8/V8PerContextData.h"
#include "core/CSSValueKeywords.h"
#include "core/SVGNames.h"
#include "core/XLinkNames.h"
@@ -3268,4 +3271,38 @@ void Element::trace(Visitor* visitor)
ContainerNode::trace(visitor);
}
+v8::Handle<v8::Object> Element::wrap(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+{
+ if (isCustomElement())
+ return wrapCustomElement(creationContext, isolate);
+ return ContainerNode::wrap(creationContext, isolate);
+}
+
+v8::Handle<v8::Object> Element::wrapCustomElement(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+{
+ ASSERT(!DOMDataStore::containsWrapperNonTemplate(this, isolate));
+
+ ASSERT(!creationContext.IsEmpty());
+ v8::Handle<v8::Context> context = creationContext->CreationContext();
+
+ if (!isUpgradedCustomElement() || DOMWrapperWorld::world(context).isIsolatedWorld())
+ return ContainerNode::wrap(creationContext, isolate);
+
+ V8PerContextData* perContextData = V8PerContextData::from(context);
+ if (!perContextData)
+ return v8::Handle<v8::Object>();
+
+ CustomElementBinding* binding = perContextData->customElementBinding(customElementDefinition());
+ const WrapperTypeInfo* wrapperType = wrapperTypeInfo();
+ v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, wrapperType, toInternalPointer(), isolate);
+ if (wrapper.IsEmpty())
+ return v8::Handle<v8::Object>();
+
+ wrapper->SetPrototype(binding->prototype());
+
+ wrapperType->refObject(toInternalPointer());
+ V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType, wrapper, isolate);
+ return wrapper;
+}
+
} // namespace blink
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Node.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698