Title: [122555] trunk/Source/WebCore
Revision
122555
Author
[email protected]
Date
2012-07-13 02:38:50 -0700 (Fri, 13 Jul 2012)

Log Message

[V8Bindings] Implement generalised method to validates that the passed object is a sequence type.
https://bugs.webkit.org/show_bug.cgi?id=91056

Patch by Vineet Chaudhary <[email protected]> on 2012-07-13
Reviewed by Kentaro Hara.

Currently the V8 implementation validates that the passed object is a sequence type only
for MessagePort in V8Utilities::extractTransferables().
There should be generalised method for other types too.
Spec URL: http://www.w3.org/TR/2012/WD-WebIDL-20120207/#es-sequence

No new test, Just refactoring. There should be no behavioral changes.

* bindings/v8/V8Binding.h:
(WebCore::toV8Sequence): Added implementation of toV8Sequence().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (122554 => 122555)


--- trunk/Source/WebCore/ChangeLog	2012-07-13 09:20:49 UTC (rev 122554)
+++ trunk/Source/WebCore/ChangeLog	2012-07-13 09:38:50 UTC (rev 122555)
@@ -1,3 +1,20 @@
+2012-07-13  Vineet Chaudhary  <[email protected]>
+
+        [V8Bindings] Implement generalised method to validates that the passed object is a sequence type.
+        https://bugs.webkit.org/show_bug.cgi?id=91056
+
+        Reviewed by Kentaro Hara.
+
+        Currently the V8 implementation validates that the passed object is a sequence type only
+        for MessagePort in V8Utilities::extractTransferables().
+        There should be generalised method for other types too.
+        Spec URL: http://www.w3.org/TR/2012/WD-WebIDL-20120207/#es-sequence
+
+        No new test, Just refactoring. There should be no behavioral changes.
+
+        * bindings/v8/V8Binding.h:
+        (WebCore::toV8Sequence): Added implementation of toV8Sequence().
+
 2012-07-13  Zeno Albisser  <[email protected]>
 
         [Qt][WK2] Implement GraphicsSurface for Linux/GLX.

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (122554 => 122555)


--- trunk/Source/WebCore/bindings/v8/V8Binding.h	2012-07-13 09:20:49 UTC (rev 122554)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h	2012-07-13 09:38:50 UTC (rev 122555)
@@ -34,6 +34,7 @@
 #include "BindingSecurity.h"
 #include "DOMDataStore.h"
 #include "PlatformString.h"
+#include "V8BindingMacros.h"
 #include "V8DOMWrapper.h"
 #include "V8GCController.h"
 #include "V8HiddenPropertyName.h"
@@ -439,6 +440,31 @@
         return result;
     }
 
+    // Validates that the passed object is a sequence type per WebIDL spec
+    // http://www.w3.org/TR/2012/WD-WebIDL-20120207/#es-sequence
+    inline v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value> value, uint32_t& length)
+    {
+        if (!value->IsObject()) {
+            V8Proxy::throwTypeError();
+            return v8::Local<v8::Value>();
+        }
+
+        v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(value));
+        v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
+
+        EXCEPTION_BLOCK(v8::Local<v8::Value>, lengthValue, object->Get(v8::String::New("length")));
+
+        if (lengthValue->IsUndefined() || lengthValue->IsNull()) {
+            V8Proxy::throwTypeError();
+            return v8::Local<v8::Value>();
+        }
+
+        EXCEPTION_BLOCK(uint32_t, sequenceLength, lengthValue->Int32Value());
+        length = sequenceLength;
+
+        return v8Value;
+    }
+
     // Enables caching v8 wrappers created for WTF::StringImpl.  Currently this cache requires
     // all the calls (both to convert WTF::String to v8::String and to GC the handle)
     // to be performed on the main thread.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to