@@ -91,13 +91,15 @@ pub fn strings_in(cx: &mut FunctionContext, vals: &[Handle<JsValue>]) -> Vec<Str
9191}
9292
9393pub fn strings_at_key ( cx : & mut FunctionContext , obj : & Handle < JsObject > , attr : & str ) -> Result < Vec < String > , Throw > {
94- let array = obj. get ( cx, attr) ?. downcast :: < JsArray , _ > ( cx) . or_throw ( cx) ?. to_vec ( cx) ?;
95- Ok ( strings_in ( cx, & array) )
94+ let array: Handle < JsArray > = obj. get ( cx, attr) ?;
95+ let list = array. to_vec ( cx) ?;
96+ Ok ( strings_in ( cx, & list) )
9697}
9798
9899pub fn string_for_key ( cx : & mut FunctionContext , obj : & Handle < JsObject > , attr : & str ) -> Result < String , Throw > {
99100 let key = cx. string ( attr) ;
100- match obj. get ( cx, key) ?. downcast :: < JsString , _ > ( cx) {
101+ let val: Handle < JsValue > = obj. get ( cx, key) ?;
102+ match val. downcast :: < JsString , _ > ( cx) {
101103 Ok ( s) => Ok ( s. value ( cx) ) ,
102104 Err ( _e) => cx. throw_type_error ( format ! ( "Exptected a string for \" {}\" " , attr) )
103105 }
@@ -191,7 +193,8 @@ pub fn bool_arg(cx: &mut FunctionContext, idx: usize, attr:&str) -> Result<bool,
191193
192194pub fn float_for_key ( cx : & mut FunctionContext , obj : & Handle < JsObject > , attr : & str ) -> Result < f32 , Throw > {
193195 let key = cx. string ( attr) ;
194- match obj. get ( cx, key) ?. downcast :: < JsNumber , _ > ( cx) {
196+ let val: Handle < JsValue > = obj. get ( cx, key) ?;
197+ match val. downcast :: < JsNumber , _ > ( cx) {
195198 Ok ( num) => Ok ( num. value ( cx) as f32 ) ,
196199 Err ( _e) => cx. throw_type_error ( format ! ( "Exptected a numerical value for \" {}\" " , attr) )
197200 }
@@ -303,7 +306,7 @@ pub fn color_in<'a>(cx: &mut FunctionContext<'a>, val: Handle<'a, JsValue>) -> O
303306 }
304307
305308 if let Ok ( obj) = val. downcast :: < JsObject , _ > ( cx) {
306- if let Ok ( attr) = obj. get ( cx, "toString" ) {
309+ if let Ok ( attr) = obj. get :: < JsValue , _ , _ > ( cx, "toString" ) {
307310 if let Ok ( to_string) = attr. downcast :: < JsFunction , _ > ( cx) {
308311 let args: Vec < Handle < JsValue > > = vec ! [ ] ;
309312 if let Ok ( result) = to_string. call ( cx, obj, args) {
@@ -446,26 +449,26 @@ pub fn filter_arg(cx: &mut FunctionContext, idx: usize) -> Result<(String, Vec<F
446449 let arg = cx. argument :: < JsObject > ( idx as i32 ) ?;
447450 let canonical = string_for_key ( cx, & arg, "canonical" ) ?;
448451
449- let obj = arg. get ( cx, "filters" ) ? . downcast_or_throw :: < JsObject , _ > ( cx ) ?;
452+ let obj: Handle < JsObject > = arg. get ( cx, "filters" ) ?;
450453 let keys = obj. get_own_property_names ( cx) ?. to_vec ( cx) ?;
451454 let mut filters = vec ! [ ] ;
452455 for ( name, key) in strings_in ( cx, & keys) . iter ( ) . zip ( keys) {
453456 match name. as_str ( ) {
454457 "drop-shadow" => {
455- let values = obj. get ( cx , key ) ? . downcast_or_throw :: < JsArray , _ > ( cx) ?;
458+ let values = obj. get :: < JsArray , _ , _ > ( cx, key ) ?;
456459 let nums = values. to_vec ( cx) ?;
457460 let dims = floats_in ( cx, & nums) ;
458- let color_str = values. get ( cx , 3 ) ? . downcast_or_throw :: < JsString , _ > ( cx) ?. value ( cx) ;
461+ let color_str = values. get :: < JsString , _ , _ > ( cx, 3 ) ?. value ( cx) ;
459462 if let Some ( color) = css_to_color ( cx, & color_str) {
460463 filters. push ( FilterSpec :: Shadow {
461464 offset : Point :: new ( dims[ 0 ] , dims[ 1 ] ) , blur : dims[ 2 ] , color
462465 } ) ;
463466 }
464467 } ,
465468 _ => {
466- let value = obj. get ( cx , key ) ? . downcast_or_throw :: < JsNumber , _ > ( cx) ?. value ( cx) ;
469+ let value = obj. get :: < JsNumber , _ , _ > ( cx, key ) ?. value ( cx) as f32 ;
467470 filters. push ( FilterSpec :: Plain {
468- name : name. to_string ( ) , value : value as f32
471+ name : name. to_string ( ) , value
469472 } )
470473 }
471474 }
0 commit comments