[V8] We shouldn't call deprecated V8 APIs
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2012 20:01:20 +0000 (20:01 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2012 20:01:20 +0000 (20:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102407

Reviewed by Eric Seidel.

This patch was written by Sven Panne on the V8 team. He would prefer
that we not call deprecated V8 APIs. This patch updates these call
sites to more modern idioms.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateConstructorGetter):
(GenerateImplementation):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjV8Internal::TestObjConstructorGetter):
* bindings/v8/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::addListener):
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::setContextDebugId):
(WebCore::ScriptController::contextDebugId):
* bindings/v8/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::objectByHeapObjectId):
    - This code doesn't seem to do anything anymore.
* bindings/v8/V8DOMConfiguration.h:
(WebCore::V8DOMConfiguration::configureAttribute):
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::setInjectedScriptContextDebugId):
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::maybeDOMWrapper):
(WebCore::V8DOMWrapper::isWrapperOfType):
* bindings/v8/V8EventListenerList.h:
(WebCore::V8EventListenerList::doFindWrapper):
(WebCore::V8EventListenerList::findOrCreateWrapper):
* bindings/v8/WorkerContextExecutionProxy.cpp:
(WebCore::WorkerContextExecutionProxy::initializeIfNeeded):
* bindings/v8/WrapperTypeInfo.h:
(WebCore::WrapperTypeInfo::unwrap):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134811 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
Source/WebCore/bindings/v8/PageScriptDebugServer.cpp
Source/WebCore/bindings/v8/ScriptController.cpp
Source/WebCore/bindings/v8/ScriptProfiler.cpp
Source/WebCore/bindings/v8/V8DOMConfiguration.h
Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
Source/WebCore/bindings/v8/V8DOMWrapper.cpp
Source/WebCore/bindings/v8/V8EventListenerList.h
Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
Source/WebCore/bindings/v8/WrapperTypeInfo.h

index dda203e..74630f1 100644 (file)
@@ -1,3 +1,42 @@
+2012-11-15  Adam Barth  <abarth@webkit.org>
+
+        [V8] We shouldn't call deprecated V8 APIs
+        https://bugs.webkit.org/show_bug.cgi?id=102407
+
+        Reviewed by Eric Seidel.
+
+        This patch was written by Sven Panne on the V8 team. He would prefer
+        that we not call deprecated V8 APIs. This patch updates these call
+        sites to more modern idioms.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateConstructorGetter):
+        (GenerateImplementation):
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::TestObjV8Internal::TestObjConstructorGetter):
+        * bindings/v8/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::addListener):
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::setContextDebugId):
+        (WebCore::ScriptController::contextDebugId):
+        * bindings/v8/ScriptProfiler.cpp:
+        (WebCore::ScriptProfiler::objectByHeapObjectId):
+            - This code doesn't seem to do anything anymore.
+        * bindings/v8/V8DOMConfiguration.h:
+        (WebCore::V8DOMConfiguration::configureAttribute):
+        * bindings/v8/V8DOMWindowShell.cpp:
+        (WebCore::setInjectedScriptContextDebugId):
+        * bindings/v8/V8DOMWrapper.cpp:
+        (WebCore::V8DOMWrapper::maybeDOMWrapper):
+        (WebCore::V8DOMWrapper::isWrapperOfType):
+        * bindings/v8/V8EventListenerList.h:
+        (WebCore::V8EventListenerList::doFindWrapper):
+        (WebCore::V8EventListenerList::findOrCreateWrapper):
+        * bindings/v8/WorkerContextExecutionProxy.cpp:
+        (WebCore::WorkerContextExecutionProxy::initializeIfNeeded):
+        * bindings/v8/WrapperTypeInfo.h:
+        (WebCore::WrapperTypeInfo::unwrap):
+
 2012-11-15  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r134800 and r134805.
index fdbb3af..e73c319 100644 (file)
@@ -884,7 +884,7 @@ static v8::Handle<v8::Value> ${interfaceName}ConstructorGetter(v8::Local<v8::Str
 {
     INC_STATS(\"DOM.$interfaceName.constructors._get\");
     v8::Handle<v8::Value> data = info.Data();
-    ASSERT(data->IsExternal() || data->IsNumber());
+    ASSERT(data->IsExternal());
     V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
     if (!perContextData)
         return v8Undefined();
@@ -2937,7 +2937,7 @@ END
 
     my $access_check = "";
     if ($dataNode->extendedAttributes->{"CheckSecurity"} && !($interfaceName eq "DOMWindow")) {
-        $access_check = "instance->SetAccessCheckCallbacks(V8${interfaceName}::namedSecurityCheck, V8${interfaceName}::indexedSecurityCheck, v8::External::Wrap(&V8${interfaceName}::info));";
+        $access_check = "instance->SetAccessCheckCallbacks(V8${interfaceName}::namedSecurityCheck, V8${interfaceName}::indexedSecurityCheck, v8::External::New(&V8${interfaceName}::info));";
     }
 
     # For the DOMWindow interface, generate the shadow object template
@@ -2949,7 +2949,7 @@ static v8::Persistent<v8::ObjectTemplate> ConfigureShadowObjectTemplate(v8::Pers
     V8DOMConfiguration::batchConfigureAttributes(templ, v8::Handle<v8::ObjectTemplate>(), shadowAttrs, WTF_ARRAY_LENGTH(shadowAttrs));
 
     // Install a security handler with V8.
-    templ->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::External::Wrap(&V8DOMWindow::info));
+    templ->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::External::New(&V8DOMWindow::info));
     templ->SetInternalFieldCount(V8DOMWindow::internalFieldCount);
     return templ;
 }
@@ -3088,7 +3088,7 @@ END
     // Set access check callbacks, but turned off initially.
     // When a context is detached from a frame, turn on the access check.
     // Turning on checks also invalidates inline caches of the object.
-    instance->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::External::Wrap(&V8DOMWindow::info), false);
+    instance->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::External::New(&V8DOMWindow::info), false);
 END
     }
     if ($interfaceName eq "HTMLDocument") {
index 283bf57..41b576d 100644 (file)
@@ -126,7 +126,7 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestActiveDOMObjectTempla
     v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
     UNUSED_PARAM(instance); // In some cases, it will not be used.
     UNUSED_PARAM(proto); // In some cases, it will not be used.
-    instance->SetAccessCheckCallbacks(V8TestActiveDOMObject::namedSecurityCheck, V8TestActiveDOMObject::indexedSecurityCheck, v8::External::Wrap(&V8TestActiveDOMObject::info));
+    instance->SetAccessCheckCallbacks(V8TestActiveDOMObject::namedSecurityCheck, V8TestActiveDOMObject::indexedSecurityCheck, v8::External::New(&V8TestActiveDOMObject::info));
 
     // Custom Signature 'excitingFunction'
     const int excitingFunctionArgc = 1;
index 5607210..a229be3 100644 (file)
@@ -1027,7 +1027,7 @@ static v8::Handle<v8::Value> TestObjConstructorGetter(v8::Local<v8::String> name
 {
     INC_STATS("DOM.TestObj.constructors._get");
     v8::Handle<v8::Value> data = info.Data();
-    ASSERT(data->IsExternal() || data->IsNumber());
+    ASSERT(data->IsExternal());
     V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
     if (!perContextData)
         return v8Undefined();
index e0e7121..65e4837 100644 (file)
@@ -97,7 +97,7 @@ void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* pag
         return;
     v8::Handle<v8::Context> context = shell->context();
     v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScripts")));
-    v8::Handle<v8::Value> argv[] = { context->GetData() };
+    v8::Handle<v8::Value> argv[] = { context->GetEmbedderData(0) };
     v8::Handle<v8::Value> value;
     {
         V8RecursionScope::MicrotaskSuppression scope;
index b5306ba..0ea050d 100644 (file)
@@ -691,7 +691,7 @@ bool ScriptController::setContextDebugId(int debugId)
         return false;
     v8::HandleScope scope;
     v8::Handle<v8::Context> context = m_windowShell->context();
-    if (!context->GetData()->IsUndefined())
+    if (!context->GetEmbedderData(0)->IsUndefined())
         return false;
 
     v8::Context::Scope contextScope(context);
@@ -699,7 +699,7 @@ bool ScriptController::setContextDebugId(int debugId)
     char buffer[32];
     snprintf(buffer, sizeof(buffer), "page,%d", debugId);
     buffer[31] = 0;
-    context->SetData(v8::String::New(buffer));
+    context->SetEmbedderData(0, v8::String::New(buffer));
 
     return true;
 }
@@ -707,9 +707,9 @@ bool ScriptController::setContextDebugId(int debugId)
 int ScriptController::contextDebugId(v8::Handle<v8::Context> context)
 {
     v8::HandleScope scope;
-    if (!context->GetData()->IsString())
+    if (!context->GetEmbedderData(0)->IsString())
         return -1;
-    v8::String::AsciiValue ascii(context->GetData());
+    v8::String::AsciiValue ascii(context->GetEmbedderData(0));
     char* comma = strnstr(*ascii, ",", ascii.length());
     if (!comma)
         return -1;
index ff57c3c..959f982 100644 (file)
@@ -111,13 +111,7 @@ ScriptObject ScriptProfiler::objectByHeapObjectId(unsigned id)
         return ScriptObject();
 
     v8::Handle<v8::Object> object = value.As<v8::Object>();
-    if (object->InternalFieldCount() >= v8DefaultWrapperInternalFieldCount) {
-        v8::Handle<v8::Value> wrapper = object->GetInternalField(v8DOMWrapperObjectIndex);
-        // Skip wrapper boilerplates which are like regular wrappers but don't have
-        // native object.
-        if (!wrapper.IsEmpty() && wrapper->IsUndefined())
-            return ScriptObject();
-    }
+
     ScriptState* scriptState = ScriptState::forContext(object->CreationContext());
     return ScriptObject(scriptState, object);
 }
index 6fb5f5e..5222436 100644 (file)
@@ -66,7 +66,7 @@ public:
         (attribute.onPrototype ? prototype : instance)->SetAccessor(v8::String::NewSymbol(attribute.name),
                                                                     attribute.getter,
                                                                     attribute.setter,
-                                                                    v8::External::Wrap(attribute.data),
+                                                                    v8::External::New(attribute.data),
                                                                     attribute.settings,
                                                                     attribute.attribute);
     }
index 506e78f..adac9e8 100644 (file)
@@ -176,7 +176,7 @@ static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContex
         snprintf(buffer, sizeof(buffer), "injected");
     else
         snprintf(buffer, sizeof(buffer), "injected,%d", debugId);
-    targetContext->SetData(v8::String::New(buffer));
+    targetContext->SetEmbedderData(0, v8::String::New(buffer));
 }
 
 PassOwnPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame, PassRefPtr<DOMWrapperWorld> world)
index 92bf84f..f6efc88 100644 (file)
@@ -158,8 +158,7 @@ bool V8DOMWrapper::maybeDOMWrapper(v8::Handle<v8::Value> value)
     ASSERT(object->InternalFieldCount() >= v8DefaultWrapperInternalFieldCount);
 
     v8::HandleScope scope;
-    v8::Handle<v8::Value> wrapper = object->GetInternalField(v8DOMWrapperObjectIndex);
-    ASSERT(wrapper->IsNumber() || wrapper->IsExternal());
+    ASSERT(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
 
     return true;
 }
@@ -172,9 +171,7 @@ bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, WrapperTypeInfo*
 
     v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
     ASSERT(object->InternalFieldCount() >= v8DefaultWrapperInternalFieldCount);
-
-    v8::Handle<v8::Value> wrapper = object->GetInternalField(v8DOMWrapperObjectIndex);
-    ASSERT_UNUSED(wrapper, wrapper->IsNumber() || wrapper->IsExternal());
+    ASSERT(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
 
     WrapperTypeInfo* typeInfo = static_cast<WrapperTypeInfo*>(object->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex));
     return typeInfo == type;
index eea2213..45246b0 100644 (file)
@@ -70,7 +70,7 @@ namespace WebCore {
             v8::Local<v8::Value> listener = object->GetHiddenValue(wrapperProperty);
             if (listener.IsEmpty())
                 return 0;
-            return static_cast<V8EventListener*>(v8::External::Unwrap(listener));
+            return static_cast<V8EventListener*>(v8::External::Cast(*listener)->Value());
         }
 
         static inline v8::Handle<v8::String> getHiddenProperty(bool isAttribute)
@@ -95,7 +95,7 @@ namespace WebCore {
 
         PassRefPtr<V8EventListener> wrapperPtr = WrapperType::create(object, isAttribute, WorldContextHandle(UseCurrentWorld));
         if (wrapperPtr)
-            object->SetHiddenValue(wrapperProperty, v8::External::Wrap(wrapperPtr.get()));
+            object->SetHiddenValue(wrapperProperty, v8::External::New(wrapperPtr.get()));
 
         return wrapperPtr;
     }
index 5065ad8..97cef89 100644 (file)
@@ -153,7 +153,7 @@ bool WorkerContextExecutionProxy::initializeIfNeeded()
     }
 
     // Set DebugId for the new context.
-    context->SetData(v8::String::New("worker"));
+    context->SetEmbedderData(0, v8::String::New("worker"));
 
     // Create a new JS object and use it as the prototype for the shadow global object.
     WrapperTypeInfo* contextType = &V8DedicatedWorkerContext::info;
index ebec2de..be6cda2 100644 (file)
@@ -63,7 +63,7 @@ namespace WebCore {
 
         static WrapperTypeInfo* unwrap(v8::Handle<v8::Value> typeInfoWrapper)
         {
-            return reinterpret_cast<WrapperTypeInfo*>(v8::External::Unwrap(typeInfoWrapper));
+            return reinterpret_cast<WrapperTypeInfo*>(v8::External::Cast(*typeInfoWrapper)->Value());
         }