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

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

Issue 478243002: bindings: Adds virtual ScriptWrappable::wrap method. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced and sent out to the code review. Created 6 years, 4 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/core/dom/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index 86b776ca6635bcd78088e9361e474924b4363aff..8f226ba50fede047c861061b82a1d40ab33de024 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -25,8 +25,10 @@
#include "config.h"
#include "core/dom/Node.h"
+#include "bindings/core/v8/DOMDataStore.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptCallStackFactory.h"
+#include "bindings/core/v8/V8DOMWrapper.h"
#include "core/HTMLNames.h"
#include "core/XMLNames.h"
#include "core/accessibility/AXObjectCache.h"
@@ -75,6 +77,7 @@
#include "core/events/WheelEvent.h"
#include "core/frame/EventHandlerRegistry.h"
#include "core/frame/LocalFrame.h"
+#include "core/frame/Settings.h"
#include "core/html/HTMLAnchorElement.h"
#include "core/html/HTMLDialogElement.h"
#include "core/html/HTMLFrameOwnerElement.h"
@@ -82,7 +85,6 @@
#include "core/page/ContextMenuController.h"
#include "core/page/EventHandler.h"
#include "core/page/Page.h"
-#include "core/frame/Settings.h"
#include "core/rendering/FlowThreadController.h"
#include "core/rendering/RenderBox.h"
#include "core/svg/graphics/SVGImage.h"
@@ -2466,6 +2468,27 @@ unsigned Node::lengthOfContents() const
return 0;
}
+v8::Handle<v8::Object> Node::wrap(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+{
+ ASSERT(!DOMDataStore::containsWrapperNonTemplate(this, isolate));
+
+ const WrapperTypeInfo* wrapperType = wrapperTypeInfo();
+
+ // Might be a XXXConstructor::wrapperTypeInfo instead of an
+ // XXX::wrapperTypeInfo. These will both have the same object de-ref
+ // functions, though, so use that as the basis of the check.
+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(typeInfo()->derefObjectFunction == wrapperType->derefObjectFunction);
+
+ v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, wrapperType, toInternalPointer(), isolate);
+ if (UNLIKELY(wrapper.IsEmpty()))
+ return wrapper;
+
+ wrapperType->installConditionallyEnabledProperties(wrapper, isolate);
+ wrapperType->refObject(toInternalPointer());
+ V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType, wrapper, isolate, WrapperConfiguration::Dependent);
+ return wrapper;
+}
+
} // namespace blink
#ifndef NDEBUG

Powered by Google App Engine
This is Rietveld 408576698