Title: [207791] trunk/Source
Revision
207791
Author
cdu...@apple.com
Date
2016-10-24 17:16:29 -0700 (Mon, 24 Oct 2016)

Log Message

Reduce special handling for typed arrays in JSDOMConvert.h
https://bugs.webkit.org/show_bug.cgi?id=163907

Reviewed by Sam Weinig.

Reduce special handling for typed arrays in JSDOMConvert.h by adding a toWrapped() static
function on JSGenericTypedArrayView, similarly to other wrapper types.

Source/_javascript_Core:

* runtime/JSGenericTypedArrayView.h:
(JSC::JSGenericTypedArrayView::typedImpl):
(JSC::JSGenericTypedArrayView<Adaptor>::toWrapped):

Source/WebCore:

No new tests, no web-exposed behavior change.

* bindings/js/JSDOMConvert.h:
(WebCore::Converter<IDLInterface<JSC::GenericTypedArrayView<Adaptor>>>::convert): Deleted.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (207790 => 207791)


--- trunk/Source/_javascript_Core/ChangeLog	2016-10-25 00:11:38 UTC (rev 207790)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-10-25 00:16:29 UTC (rev 207791)
@@ -1,3 +1,17 @@
+2016-10-24  Chris Dumez  <cdu...@apple.com>
+
+        Reduce special handling for typed arrays in JSDOMConvert.h
+        https://bugs.webkit.org/show_bug.cgi?id=163907
+
+        Reviewed by Sam Weinig.
+
+        Reduce special handling for typed arrays in JSDOMConvert.h by adding a toWrapped() static
+        function on JSGenericTypedArrayView, similarly to other wrapper types.
+
+        * runtime/JSGenericTypedArrayView.h:
+        (JSC::JSGenericTypedArrayView::typedImpl):
+        (JSC::JSGenericTypedArrayView<Adaptor>::toWrapped):
+
 2016-10-24  Yusuke Suzuki  <utatane....@gmail.com>
 
         [DOMJIT][DFG] CallDOM never writes Stack

Modified: trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayView.h (207790 => 207791)


--- trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayView.h	2016-10-25 00:11:38 UTC (rev 207790)
+++ trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayView.h	2016-10-25 00:16:29 UTC (rev 207791)
@@ -225,10 +225,12 @@
     // then it will have thrown an exception.
     bool set(ExecState*, unsigned offset, JSObject*, unsigned objectOffset, unsigned length, CopyType type = CopyType::Unobservable);
     
-    PassRefPtr<typename Adaptor::ViewType> typedImpl()
+    RefPtr<typename Adaptor::ViewType> typedImpl()
     {
         return Adaptor::ViewType::create(buffer(), byteOffset(), length());
     }
+
+    static RefPtr<typename Adaptor::ViewType> toWrapped(JSValue);
     
     static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
     {
@@ -367,4 +369,10 @@
     return wrapper->typedImpl();
 }
 
+template<typename Adaptor>
+RefPtr<typename Adaptor::ViewType> JSGenericTypedArrayView<Adaptor>::toWrapped(JSValue value)
+{
+    return JSC::toNativeTypedView<Adaptor>(value);
+}
+
 } // namespace JSC

Modified: trunk/Source/WebCore/ChangeLog (207790 => 207791)


--- trunk/Source/WebCore/ChangeLog	2016-10-25 00:11:38 UTC (rev 207790)
+++ trunk/Source/WebCore/ChangeLog	2016-10-25 00:16:29 UTC (rev 207791)
@@ -1,3 +1,18 @@
+2016-10-24  Chris Dumez  <cdu...@apple.com>
+
+        Reduce special handling for typed arrays in JSDOMConvert.h
+        https://bugs.webkit.org/show_bug.cgi?id=163907
+
+        Reviewed by Sam Weinig.
+
+        Reduce special handling for typed arrays in JSDOMConvert.h by adding a toWrapped() static
+        function on JSGenericTypedArrayView, similarly to other wrapper types.
+
+        No new tests, no web-exposed behavior change.
+
+        * bindings/js/JSDOMConvert.h:
+        (WebCore::Converter<IDLInterface<JSC::GenericTypedArrayView<Adaptor>>>::convert): Deleted.
+
 2016-10-24  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r207783.

Modified: trunk/Source/WebCore/bindings/js/JSDOMConvert.h (207790 => 207791)


--- trunk/Source/WebCore/bindings/js/JSDOMConvert.h	2016-10-25 00:11:38 UTC (rev 207790)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvert.h	2016-10-25 00:16:29 UTC (rev 207791)
@@ -235,6 +235,12 @@
     using ToWrappedReturnType = RefPtr<ArrayBufferView>;
 };
 
+// Typed arrays support.
+template<typename Adaptor> struct JSDOMWrapperConverterTraits<JSC::GenericTypedArrayView<Adaptor>> {
+    using WrapperClass = JSC::JSGenericTypedArrayView<Adaptor>;
+    using ToWrappedReturnType = RefPtr<JSC::GenericTypedArrayView<Adaptor>>;
+};
+
 // MARK: -
 // MARK: Interface type
 
@@ -264,27 +270,6 @@
     }
 };
 
-// Typed arrays support.
-
-template<typename Adaptor> struct IDLInterface<JSC::GenericTypedArrayView<Adaptor>> : IDLType<Ref<JSC::GenericTypedArrayView<Adaptor>>> {
-    using RawType = JSC::GenericTypedArrayView<Adaptor>;
-    using NullableType = RefPtr<JSC::GenericTypedArrayView<Adaptor>>;
-};
-
-template<typename Adaptor> struct Converter<IDLInterface<JSC::GenericTypedArrayView<Adaptor>>> : DefaultConverter<IDLInterface<JSC::GenericTypedArrayView<Adaptor>>> {
-    using ReturnType = RefPtr<JSC::GenericTypedArrayView<Adaptor>>;
-
-    static ReturnType convert(JSC::ExecState& state, JSC::JSValue value)
-    {
-        JSC::VM& vm = state.vm();
-        auto scope = DECLARE_THROW_SCOPE(vm);
-        ReturnType object = JSC::toNativeTypedView<Adaptor>(value);
-        if (!object)
-            throwTypeError(&state, scope);
-        return object;
-    }
-};
-
 // MARK: -
 // MARK: Any type
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to