Title: [109611] trunk/Source/WebCore
Revision
109611
Author
a...@chromium.org
Date
2012-03-02 13:45:10 -0800 (Fri, 02 Mar 2012)

Log Message

[V8] Bindings for node always check if they are a Document.
https://bugs.webkit.org/show_bug.cgi?id=79947

Reviewed by Adam Barth.

This changes the generated bindings code to only generate the Document code for the Document wrappers.

No new tests. Covered by existing tests.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateToV8Converters):
* bindings/scripts/test/V8/V8Float64Array.cpp:
(WebCore::V8Float64Array::wrapSlow):
* bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
(WebCore::V8TestActiveDOMObject::wrapSlow):
* bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:
(WebCore::V8TestCustomNamedGetter::wrapSlow):
* bindings/scripts/test/V8/V8TestEventConstructor.cpp:
(WebCore::V8TestEventConstructor::wrapSlow):
* bindings/scripts/test/V8/V8TestEventTarget.cpp:
(WebCore::V8TestEventTarget::wrapSlow):
* bindings/scripts/test/V8/V8TestInterface.cpp:
(WebCore::V8TestInterface::wrapSlow):
* bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
(WebCore::V8TestMediaQueryListListener::wrapSlow):
* bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
(WebCore::V8TestNamedConstructor::wrapSlow):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::V8TestObj::wrapSlow):
* bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
(WebCore::V8TestSerializedScriptValueInterface::wrapSlow):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109610 => 109611)


--- trunk/Source/WebCore/ChangeLog	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/ChangeLog	2012-03-02 21:45:10 UTC (rev 109611)
@@ -1,3 +1,37 @@
+2012-03-02  Erik Arvidsson  <a...@chromium.org>
+
+        [V8] Bindings for node always check if they are a Document.
+        https://bugs.webkit.org/show_bug.cgi?id=79947
+
+        Reviewed by Adam Barth.
+
+        This changes the generated bindings code to only generate the Document code for the Document wrappers.
+
+        No new tests. Covered by existing tests.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateToV8Converters):
+        * bindings/scripts/test/V8/V8Float64Array.cpp:
+        (WebCore::V8Float64Array::wrapSlow):
+        * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
+        (WebCore::V8TestActiveDOMObject::wrapSlow):
+        * bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:
+        (WebCore::V8TestCustomNamedGetter::wrapSlow):
+        * bindings/scripts/test/V8/V8TestEventConstructor.cpp:
+        (WebCore::V8TestEventConstructor::wrapSlow):
+        * bindings/scripts/test/V8/V8TestEventTarget.cpp:
+        (WebCore::V8TestEventTarget::wrapSlow):
+        * bindings/scripts/test/V8/V8TestInterface.cpp:
+        (WebCore::V8TestInterface::wrapSlow):
+        * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
+        (WebCore::V8TestMediaQueryListListener::wrapSlow):
+        * bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
+        (WebCore::V8TestNamedConstructor::wrapSlow):
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::V8TestObj::wrapSlow):
+        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
+        (WebCore::V8TestSerializedScriptValueInterface::wrapSlow):
+
 2012-03-02  Igor Oliveira  <igo...@sisa.samsung.com>
 
         animation-timing-function falls back to ease when overriding animation-name

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (109610 => 109611)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-03-02 21:45:10 UTC (rev 109611)
@@ -3037,21 +3037,28 @@
 v8::Handle<v8::Object> ${className}::wrapSlow(${nativeType}* impl)
 {
     v8::Handle<v8::Object> wrapper;
-    V8Proxy* proxy = 0;
 END
 
+    my $proxyInit;
     if (IsNodeSubType($dataNode)) {
-        push(@implContent, <<END);
-    if (impl->document()) {
-        proxy = V8Proxy::retrieve(impl->document()->frame());
-        if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl)) {
-            if (proxy->windowShell()->context().IsEmpty() && proxy->windowShell()->initContextIfNeeded()) {
-                // initContextIfNeeded may have created a wrapper for the object, retry from the start.
-                return ${className}::wrap(impl);
-            }
+        $proxyInit = "V8Proxy::retrieve(impl->document()->frame())";
+        # DocumentType nodes are the only nodes that may have a NULL document.
+        if ($interfaceName eq "DocumentType") {
+            $proxyInit = "impl->document() ? $proxyInit : 0";
         }
+    } else {
+        $proxyInit = "0";
     }
+    push(@implContent, <<END);
+    V8Proxy* proxy = $proxyInit;
+END
 
+    if (IsSubType($dataNode, "Document")) {
+        push(@implContent, <<END);
+    if (proxy && proxy->windowShell()->context().IsEmpty() && proxy->windowShell()->initContextIfNeeded()) {
+        // initContextIfNeeded may have created a wrapper for the object, retry from the start.
+        return ${className}::wrap(impl);
+    }
 END
     }
 
@@ -3093,7 +3100,7 @@
     }
 
     push(@implContent, <<END);
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 END
     push(@implContent, "\n    impl->ref();\n") if IsRefPtrType($interfaceName);

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp (109610 => 109611)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp	2012-03-02 21:45:10 UTC (rev 109611)
@@ -125,7 +125,7 @@
     v8::Handle<v8::Object> wrapper;
     V8Proxy* proxy = 0;
     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 
     impl->ref();

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


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp	2012-03-02 21:45:10 UTC (rev 109611)
@@ -179,7 +179,7 @@
     // Exit the node's context if it was entered.
     if (!context.IsEmpty())
         context->Exit();
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 
     impl->ref();

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp (109610 => 109611)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp	2012-03-02 21:45:10 UTC (rev 109611)
@@ -115,7 +115,7 @@
     v8::Handle<v8::Object> wrapper;
     V8Proxy* proxy = 0;
     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 
     impl->ref();

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp (109610 => 109611)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp	2012-03-02 21:45:10 UTC (rev 109611)
@@ -150,7 +150,7 @@
     v8::Handle<v8::Object> wrapper;
     V8Proxy* proxy = 0;
     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 
     impl->ref();

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp (109610 => 109611)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp	2012-03-02 21:45:10 UTC (rev 109611)
@@ -178,7 +178,7 @@
     v8::Handle<v8::Object> wrapper;
     V8Proxy* proxy = 0;
     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 
     impl->ref();

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (109610 => 109611)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2012-03-02 21:45:10 UTC (rev 109611)
@@ -311,7 +311,7 @@
     v8::Handle<v8::Object> wrapper;
     V8Proxy* proxy = 0;
     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 
     impl->ref();

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp (109610 => 109611)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp	2012-03-02 21:45:10 UTC (rev 109611)
@@ -115,7 +115,7 @@
     v8::Handle<v8::Object> wrapper;
     V8Proxy* proxy = 0;
     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 
     impl->ref();

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp (109610 => 109611)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp	2012-03-02 21:45:10 UTC (rev 109611)
@@ -160,7 +160,7 @@
     v8::Handle<v8::Object> wrapper;
     V8Proxy* proxy = 0;
     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 
     impl->ref();

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


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-03-02 21:45:10 UTC (rev 109611)
@@ -2093,7 +2093,7 @@
     v8::Handle<v8::Object> wrapper;
     V8Proxy* proxy = 0;
     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 
     impl->ref();

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp (109610 => 109611)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp	2012-03-02 21:40:54 UTC (rev 109610)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp	2012-03-02 21:45:10 UTC (rev 109611)
@@ -197,7 +197,7 @@
     v8::Handle<v8::Object> wrapper;
     V8Proxy* proxy = 0;
     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
-    if (wrapper.IsEmpty())
+    if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 
     impl->ref();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to