Title: [206681] trunk/Source/WebCore
- Revision
- 206681
- Author
- [email protected]
- Date
- 2016-09-30 15:21:59 -0700 (Fri, 30 Sep 2016)
Log Message
[iOS] Allow sequence<Touch> input in TouchEvent constructor
https://bugs.webkit.org/show_bug.cgi?id=162806
<rdar://problem/28566429>
Reviewed by Ryosuke Niwa.
Allow sequence<Touch> input in TouchEvent constructor in addition to
TouchList objects. It is convenient for developers to pass arrays of
Touch objects.
No new tests, already covered by:
imported/w3c/web-platform-tests/touch-events/touch-touchevent-constructor.html
* bindings/js/JSDOMBinding.h:
(WebCore::toRefNativeArray):
(WebCore::toRefPtrNativeArray):
* bindings/js/JSDictionary.cpp:
(WebCore::JSDictionary::convertValue):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (206680 => 206681)
--- trunk/Source/WebCore/ChangeLog 2016-09-30 22:21:40 UTC (rev 206680)
+++ trunk/Source/WebCore/ChangeLog 2016-09-30 22:21:59 UTC (rev 206681)
@@ -1,3 +1,24 @@
+2016-09-30 Chris Dumez <[email protected]>
+
+ [iOS] Allow sequence<Touch> input in TouchEvent constructor
+ https://bugs.webkit.org/show_bug.cgi?id=162806
+ <rdar://problem/28566429>
+
+ Reviewed by Ryosuke Niwa.
+
+ Allow sequence<Touch> input in TouchEvent constructor in addition to
+ TouchList objects. It is convenient for developers to pass arrays of
+ Touch objects.
+
+ No new tests, already covered by:
+ imported/w3c/web-platform-tests/touch-events/touch-touchevent-constructor.html
+
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::toRefNativeArray):
+ (WebCore::toRefPtrNativeArray):
+ * bindings/js/JSDictionary.cpp:
+ (WebCore::JSDictionary::convertValue):
+
2016-09-30 Myles C. Maxfield <[email protected]>
Parse font-variation-settings
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (206680 => 206681)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2016-09-30 22:21:40 UTC (rev 206680)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2016-09-30 22:21:59 UTC (rev 206681)
@@ -309,7 +309,8 @@
RefPtr<JSC::Float32Array> toFloat32Array(JSC::JSValue);
RefPtr<JSC::Float64Array> toFloat64Array(JSC::JSValue);
-template<typename T, typename JSType> Vector<RefPtr<T>> toRefPtrNativeArray(JSC::ExecState*, JSC::JSValue);
+template<typename T, typename JSType> Vector<Ref<T>> toRefNativeArray(JSC::ExecState&, JSC::JSValue);
+template<typename T, typename JSType> Vector<RefPtr<T>> toRefPtrNativeArray(JSC::ExecState&, JSC::JSValue);
template<typename T> Vector<T> toNativeArray(JSC::ExecState&, JSC::JSValue);
bool hasIteratorMethod(JSC::ExecState&, JSC::JSValue);
@@ -812,6 +813,30 @@
}
};
+template<typename T, typename JST> inline Vector<Ref<T>> toRefNativeArray(JSC::ExecState& state, JSC::JSValue value)
+{
+ JSC::VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (!value.isObject()) {
+ throwSequenceTypeError(state, scope);
+ return { };
+ }
+
+ Vector<Ref<T>> result;
+ forEachInIterable(&state, value, [&result](JSC::VM& vm, JSC::ExecState* state, JSC::JSValue jsValue) {
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (jsValue.inherits(JST::info())) {
+ auto* object = JST::toWrapped(jsValue);
+ ASSERT(object);
+ result.append(*object);
+ } else
+ throwArrayElementTypeError(*state, scope);
+ });
+ return result;
+}
+
template<typename T, typename JST> Vector<RefPtr<T>> toRefPtrNativeArray(JSC::ExecState& exec, JSC::JSValue value)
{
JSC::VM& vm = exec.vm();
@@ -819,7 +844,7 @@
if (!value.isObject()) {
throwSequenceTypeError(exec, scope);
- return Vector<RefPtr<T>>();
+ return { };
}
Vector<RefPtr<T>> result;
Modified: trunk/Source/WebCore/bindings/js/JSDictionary.cpp (206680 => 206681)
--- trunk/Source/WebCore/bindings/js/JSDictionary.cpp 2016-09-30 22:21:40 UTC (rev 206680)
+++ trunk/Source/WebCore/bindings/js/JSDictionary.cpp 2016-09-30 22:21:59 UTC (rev 206681)
@@ -69,6 +69,7 @@
#endif
#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(TOUCH_EVENTS)
+#include "JSTouch.h"
#include "JSTouchList.h"
#endif
@@ -351,7 +352,7 @@
}
#endif
-#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(TOUCH_EVENTS)
+#if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<TouchList>& result)
{
result = JSTouchList::toWrapped(value);
@@ -358,6 +359,31 @@
}
#endif
+#if ENABLE(IOS_TOUCH_EVENTS)
+void JSDictionary::convertValue(JSC::ExecState* exec, JSC::JSValue value, RefPtr<TouchList>& result)
+{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSObject* object = value.getObject();
+ if (!object) {
+ result = nullptr;
+ return;
+ }
+
+ // Allow both TouchList and sequence<Touch> as input.
+ const ClassInfo* classInfo = object->classInfo();
+ if (classInfo == JSTouchList::info()) {
+ result = JSTouchList::toWrapped(value);
+ return;
+ }
+
+ auto touches = toRefNativeArray<Touch, JSTouch>(*exec, value);
+ RETURN_IF_EXCEPTION(scope, void());
+ result = TouchList::create(WTFMove(touches));
+}
+#endif
+
void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, JSC::JSFunction*& result)
{
result = jsDynamicCast<JSC::JSFunction*>(value);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes