Changeset 206681 in webkit
- Timestamp:
- Sep 30, 2016, 3:21:59 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206679 r206681 1 2016-09-30 Chris Dumez <cdumez@apple.com> 2 3 [iOS] Allow sequence<Touch> input in TouchEvent constructor 4 https://bugs.webkit.org/show_bug.cgi?id=162806 5 <rdar://problem/28566429> 6 7 Reviewed by Ryosuke Niwa. 8 9 Allow sequence<Touch> input in TouchEvent constructor in addition to 10 TouchList objects. It is convenient for developers to pass arrays of 11 Touch objects. 12 13 No new tests, already covered by: 14 imported/w3c/web-platform-tests/touch-events/touch-touchevent-constructor.html 15 16 * bindings/js/JSDOMBinding.h: 17 (WebCore::toRefNativeArray): 18 (WebCore::toRefPtrNativeArray): 19 * bindings/js/JSDictionary.cpp: 20 (WebCore::JSDictionary::convertValue): 21 1 22 2016-09-30 Myles C. Maxfield <mmaxfield@apple.com> 2 23 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.h
r206386 r206681 310 310 RefPtr<JSC::Float64Array> toFloat64Array(JSC::JSValue); 311 311 312 template<typename T, typename JSType> Vector<RefPtr<T>> toRefPtrNativeArray(JSC::ExecState*, JSC::JSValue); 312 template<typename T, typename JSType> Vector<Ref<T>> toRefNativeArray(JSC::ExecState&, JSC::JSValue); 313 template<typename T, typename JSType> Vector<RefPtr<T>> toRefPtrNativeArray(JSC::ExecState&, JSC::JSValue); 313 314 template<typename T> Vector<T> toNativeArray(JSC::ExecState&, JSC::JSValue); 314 315 bool hasIteratorMethod(JSC::ExecState&, JSC::JSValue); … … 813 814 }; 814 815 816 template<typename T, typename JST> inline Vector<Ref<T>> toRefNativeArray(JSC::ExecState& state, JSC::JSValue value) 817 { 818 JSC::VM& vm = state.vm(); 819 auto scope = DECLARE_THROW_SCOPE(vm); 820 821 if (!value.isObject()) { 822 throwSequenceTypeError(state, scope); 823 return { }; 824 } 825 826 Vector<Ref<T>> result; 827 forEachInIterable(&state, value, [&result](JSC::VM& vm, JSC::ExecState* state, JSC::JSValue jsValue) { 828 auto scope = DECLARE_THROW_SCOPE(vm); 829 830 if (jsValue.inherits(JST::info())) { 831 auto* object = JST::toWrapped(jsValue); 832 ASSERT(object); 833 result.append(*object); 834 } else 835 throwArrayElementTypeError(*state, scope); 836 }); 837 return result; 838 } 839 815 840 template<typename T, typename JST> Vector<RefPtr<T>> toRefPtrNativeArray(JSC::ExecState& exec, JSC::JSValue value) 816 841 { … … 820 845 if (!value.isObject()) { 821 846 throwSequenceTypeError(exec, scope); 822 return Vector<RefPtr<T>>();847 return { }; 823 848 } 824 849 -
trunk/Source/WebCore/bindings/js/JSDictionary.cpp
r206575 r206681 70 70 71 71 #if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(TOUCH_EVENTS) 72 #include "JSTouch.h" 72 73 #include "JSTouchList.h" 73 74 #endif … … 352 353 #endif 353 354 354 #if ENABLE( IOS_TOUCH_EVENTS) || ENABLE(TOUCH_EVENTS)355 #if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS) 355 356 void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<TouchList>& result) 356 357 { 357 358 result = JSTouchList::toWrapped(value); 359 } 360 #endif 361 362 #if ENABLE(IOS_TOUCH_EVENTS) 363 void JSDictionary::convertValue(JSC::ExecState* exec, JSC::JSValue value, RefPtr<TouchList>& result) 364 { 365 VM& vm = exec->vm(); 366 auto scope = DECLARE_THROW_SCOPE(vm); 367 368 JSObject* object = value.getObject(); 369 if (!object) { 370 result = nullptr; 371 return; 372 } 373 374 // Allow both TouchList and sequence<Touch> as input. 375 const ClassInfo* classInfo = object->classInfo(); 376 if (classInfo == JSTouchList::info()) { 377 result = JSTouchList::toWrapped(value); 378 return; 379 } 380 381 auto touches = toRefNativeArray<Touch, JSTouch>(*exec, value); 382 RETURN_IF_EXCEPTION(scope, void()); 383 result = TouchList::create(WTFMove(touches)); 358 384 } 359 385 #endif
Note:
See TracChangeset
for help on using the changeset viewer.