Title: [134811] trunk/Source/WebCore
Revision
134811
Author
[email protected]
Date
2012-11-15 12:01:20 -0800 (Thu, 15 Nov 2012)

Log Message

[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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134810 => 134811)


--- trunk/Source/WebCore/ChangeLog	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/ChangeLog	2012-11-15 20:01:20 UTC (rev 134811)
@@ -1,3 +1,42 @@
+2012-11-15  Adam Barth  <[email protected]>
+
+        [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  <[email protected]>
 
         Unreviewed, rolling out r134800 and r134805.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (134810 => 134811)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-11-15 20:01:20 UTC (rev 134811)
@@ -884,7 +884,7 @@
 {
     INC_STATS(\"DOM.$interfaceName.constructors._get\");
     v8::Handle<v8::Value> data = ""
-    ASSERT(data->IsExternal() || data->IsNumber());
+    ASSERT(data->IsExternal());
     V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
     if (!perContextData)
         return v8Undefined();
@@ -2937,7 +2937,7 @@
 
     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 @@
     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 @@
     // 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") {

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp (134810 => 134811)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp	2012-11-15 20:01:20 UTC (rev 134811)
@@ -126,7 +126,7 @@
     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;

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (134810 => 134811)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-11-15 20:01:20 UTC (rev 134811)
@@ -1027,7 +1027,7 @@
 {
     INC_STATS("DOM.TestObj.constructors._get");
     v8::Handle<v8::Value> data = ""
-    ASSERT(data->IsExternal() || data->IsNumber());
+    ASSERT(data->IsExternal());
     V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
     if (!perContextData)
         return v8Undefined();

Modified: trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp (134810 => 134811)


--- trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp	2012-11-15 20:01:20 UTC (rev 134811)
@@ -97,7 +97,7 @@
         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;

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (134810 => 134811)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-11-15 20:01:20 UTC (rev 134811)
@@ -691,7 +691,7 @@
         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 @@
     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 @@
 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;

Modified: trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp (134810 => 134811)


--- trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp	2012-11-15 20:01:20 UTC (rev 134811)
@@ -111,13 +111,7 @@
         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);
 }

Modified: trunk/Source/WebCore/bindings/v8/V8DOMConfiguration.h (134810 => 134811)


--- trunk/Source/WebCore/bindings/v8/V8DOMConfiguration.h	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/v8/V8DOMConfiguration.h	2012-11-15 20:01:20 UTC (rev 134811)
@@ -66,7 +66,7 @@
         (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);
     }

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp (134810 => 134811)


--- trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp	2012-11-15 20:01:20 UTC (rev 134811)
@@ -176,7 +176,7 @@
         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)

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp (134810 => 134811)


--- trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp	2012-11-15 20:01:20 UTC (rev 134811)
@@ -158,8 +158,7 @@
     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,10 +171,8 @@
 
     v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
     ASSERT(object->InternalFieldCount() >= v8DefaultWrapperInternalFieldCount);
+    ASSERT(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
 
-    v8::Handle<v8::Value> wrapper = object->GetInternalField(v8DOMWrapperObjectIndex);
-    ASSERT_UNUSED(wrapper, wrapper->IsNumber() || wrapper->IsExternal());
-
     WrapperTypeInfo* typeInfo = static_cast<WrapperTypeInfo*>(object->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex));
     return typeInfo == type;
 }

Modified: trunk/Source/WebCore/bindings/v8/V8EventListenerList.h (134810 => 134811)


--- trunk/Source/WebCore/bindings/v8/V8EventListenerList.h	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/v8/V8EventListenerList.h	2012-11-15 20:01:20 UTC (rev 134811)
@@ -70,7 +70,7 @@
             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 @@
 
         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;
     }

Modified: trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp (134810 => 134811)


--- trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp	2012-11-15 20:01:20 UTC (rev 134811)
@@ -153,7 +153,7 @@
     }
 
     // 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;

Modified: trunk/Source/WebCore/bindings/v8/WrapperTypeInfo.h (134810 => 134811)


--- trunk/Source/WebCore/bindings/v8/WrapperTypeInfo.h	2012-11-15 19:59:56 UTC (rev 134810)
+++ trunk/Source/WebCore/bindings/v8/WrapperTypeInfo.h	2012-11-15 20:01:20 UTC (rev 134811)
@@ -63,7 +63,7 @@
 
         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());
         }
         
         
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to