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

Unified Diff: Source/core/dom/Document.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/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 0ec2aedf6362028ee21c4ab765b5a47b96385d75..27e12a97076e7e5a244c41ef76d421476be62a84 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -29,11 +29,14 @@
#include "core/dom/Document.h"
#include "bindings/core/v8/CustomElementConstructorBuilder.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/ExceptionStatePlaceholder.h"
#include "bindings/core/v8/ScriptController.h"
+#include "bindings/core/v8/V8DOMWrapper.h"
+#include "bindings/core/v8/WindowProxy.h"
#include "core/HTMLElementFactory.h"
#include "core/HTMLNames.h"
#include "core/SVGElementFactory.h"
@@ -110,11 +113,11 @@
#include "core/events/ScopedEventQueue.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/frame/EventHandlerRegistry.h"
-#include "core/frame/LocalDOMWindow.h"
#include "core/frame/FrameConsole.h"
#include "core/frame/FrameHost.h"
#include "core/frame/FrameView.h"
#include "core/frame/History.h"
+#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
@@ -5743,6 +5746,39 @@ void Document::clearWeakMembers(Visitor* visitor)
m_axObjectCache->clearWeakMembers(visitor);
}
+v8::Handle<v8::Object> Document::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);
+
+ if (frame() && frame()->script().initializeMainWorld()) {
+ // initializeMainWorld may have created a wrapper for the object, retry from the start.
+ v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperNonTemplate(this, isolate);
+ if (!wrapper.IsEmpty())
+ return wrapper;
+ }
+
+ 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);
+
+ DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
+ if (world.isMainWorld() && frame())
+ frame()->script().windowProxy(world)->updateDocumentWrapper(wrapper);
+
+ return wrapper;
+}
+
void Document::trace(Visitor* visitor)
{
#if ENABLE(OILPAN)

Powered by Google App Engine
This is Rietveld 408576698