Title: [128094] trunk/Source/WebCore
Revision
128094
Author
[email protected]
Date
2012-09-10 13:20:58 -0700 (Mon, 10 Sep 2012)

Log Message

[V8] Constructors try to handle errors that cannot occur
https://bugs.webkit.org/show_bug.cgi?id=96304

Patch by Adam Barth <[email protected]> on 2012-09-10
Reviewed by Kentaro Hara.

There's no reason for constructors to indirect through the Frame. Now
that we can reliably get the Document from the v8::Context, we can just
grab it without worrying about handling error conditions related to not
being able to find the Document.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateNamedConstructorCallback):
* bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
(WebCore::V8TestNamedConstructorConstructorCallback):
* bindings/v8/custom/V8AudioContextCustom.cpp:
(WebCore::V8AudioContext::constructorCallback):
* bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
(WebCore::v8HTMLImageElementConstructorCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (128093 => 128094)


--- trunk/Source/WebCore/ChangeLog	2012-09-10 20:09:45 UTC (rev 128093)
+++ trunk/Source/WebCore/ChangeLog	2012-09-10 20:20:58 UTC (rev 128094)
@@ -1,3 +1,24 @@
+2012-09-10  Adam Barth  <[email protected]>
+
+        [V8] Constructors try to handle errors that cannot occur
+        https://bugs.webkit.org/show_bug.cgi?id=96304
+
+        Reviewed by Kentaro Hara.
+
+        There's no reason for constructors to indirect through the Frame. Now
+        that we can reliably get the Document from the v8::Context, we can just
+        grab it without worrying about handling error conditions related to not
+        being able to find the Document.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateNamedConstructorCallback):
+        * bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
+        (WebCore::V8TestNamedConstructorConstructorCallback):
+        * bindings/v8/custom/V8AudioContextCustom.cpp:
+        (WebCore::V8AudioContext::constructorCallback):
+        * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
+        (WebCore::v8HTMLImageElementConstructorCallback):
+
 2012-09-10  Andrey Kosyakov  <[email protected]>
 
         Web Inspector: highlight of paint rectangles is broken

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (128093 => 128094)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-09-10 20:09:45 UTC (rev 128093)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-09-10 20:20:58 UTC (rev 128094)
@@ -2027,12 +2027,8 @@
     if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
         return args.Holder();
 
-    Frame* frame = currentFrame(BindingState::instance());
-    if (!frame)
-        return throwError(ReferenceError, "${implClassName} constructor associated frame is unavailable", args.GetIsolate());
+    Document* document = currentDocument(BindingState::instance());
 
-    Document* document = frame->document();
-
     // Make sure the document is added to the DOM Node map. Otherwise, the ${implClassName} instance
     // may end up being the only node in the map and get garbage-collected prematurely.
     toV8(document, args.Holder(), args.GetIsolate());

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


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp	2012-09-10 20:09:45 UTC (rev 128093)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp	2012-09-10 20:20:58 UTC (rev 128094)
@@ -53,12 +53,8 @@
     if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
         return args.Holder();
 
-    Frame* frame = currentFrame(BindingState::instance());
-    if (!frame)
-        return throwError(ReferenceError, "TestNamedConstructor constructor associated frame is unavailable", args.GetIsolate());
+    Document* document = currentDocument(BindingState::instance());
 
-    Document* document = frame->document();
-
     // Make sure the document is added to the DOM Node map. Otherwise, the TestNamedConstructor instance
     // may end up being the only node in the map and get garbage-collected prematurely.
     toV8(document, args.Holder(), args.GetIsolate());

Modified: trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp (128093 => 128094)


--- trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp	2012-09-10 20:09:45 UTC (rev 128093)
+++ trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp	2012-09-10 20:20:58 UTC (rev 128094)
@@ -49,14 +49,8 @@
     if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
         return args.Holder();
 
-    Frame* frame = currentFrame(BindingState::instance());
-    if (!frame)
-        return throwError(ReferenceError, "AudioContext constructor associated frame is unavailable", args.GetIsolate());
+    Document* document = currentDocument(BindingState::instance());
 
-    Document* document = frame->document();
-    if (!document)
-        return throwError(ReferenceError, "AudioContext constructor associated document is unavailable", args.GetIsolate());
-
     RefPtr<AudioContext> audioContext;
     
     if (!args.Length()) {

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp (128093 => 128094)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp	2012-09-10 20:09:45 UTC (rev 128093)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp	2012-09-10 20:20:58 UTC (rev 128094)
@@ -55,15 +55,8 @@
     if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
         return args.Holder();
 
-    // FIXME: We shouldn't need to go through the Frame to get the Document.
-    Frame* frame = currentFrame(BindingState::instance());
-    if (!frame)
-        return throwError(ReferenceError, "Image constructor associated frame is unavailable", args.GetIsolate());
+    Document* document = currentDocument(BindingState::instance());
 
-    Document* document = frame->document();
-    if (!document)
-        return throwError(ReferenceError, "Image constructor associated document is unavailable", args.GetIsolate());
-
     // Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance
     // may end up being the only node in the map and get garbage-collected prematurely.
     // FIXME: The correct way to do this would be to make HTMLImageElement derive from
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to