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

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. 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/Document.h ('k') | Source/core/dom/DocumentFragment.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 39bdbdc2d5f0a5290b2ddd970a7c00a912fe2d8f..866bdeda65440203d03980fc24b8636800b622c3 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"
@@ -5755,6 +5758,34 @@ 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();
+
+ 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);
+
+ 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)
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentFragment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698