Repository: servo/servo
File: components/script/dom/document_event_handler.rs (Rust)

Code before:

                // Update or remove the stored touch
                match event.event_type {
                    TouchEventType::Move => {
                        active[index] = Dom::from_ref(&*changed_touch);
                    },
                    TouchEventType::Up | TouchEventType::Cancel => {
                        active.swap_remove(index);
                        self.remove_pointer_id_for_touch(identifier);
                    },
                    TouchEventType::Down => unreachable!(),
                }
                (original_target, changed_touch)
            },
        };

        let touches = {
            let active = self.active_touch_points.borrow();
            TouchList::new(window, active.r(), can_gc)
        };

        let target_touches = {
            let active = self.active_touch_points.borrow();
            rooted_vec!(let mut filtered);
            filtered.extend(
                active
                    .iter()
                    .filter(|t| t.Target() == touch_dispatch_target)
                    .cloned(),
            );
            TouchList::new(window, filtered.r(), can_gc)
        };

        let changed_touches = TouchList::new(window, from_ref(&&*changed_touch), can_gc);

        let event_name = match event.event_type {
            TouchEventType::Down => "touchstart",
            TouchEventType::Move => "touchmove",
            TouchEventType::Up => "touchend",
            TouchEventType::Cancel => "touchcancel",
        };

        let touch_event = TouchEvent::new(
            window,
            DOMString::from(event_name),
            EventBubbles::Bubbles,
            EventCancelable::from(event.is_cancelable()),
            EventComposed::Composed,
            Some(window),
            0i32,
            &touches,

Review comment (suggestion):
```suggestion
                self.active_touch_points.borrow()
```

Code after:
                match event.event_type {
                    TouchEventType::Move => {
                        active_touch_points[index] = Dom::from_ref(&*touch_with_touchstart_target);
                    },
                    TouchEventType::Up | TouchEventType::Cancel => {
                        active_touch_points.swap_remove(index);
                        self.remove_pointer_id_for_touch(identifier);
                    },
                    TouchEventType::Down => unreachable!("Should have been handled above"),
                }
                (original_target, touch_with_touchstart_target)
            },
        };

        rooted_vec!(let mut target_touches);
        target_touches.extend(
            self.active_touch_points
                .borrow()
                .iter()
                .filter(|t| t.Target() == touch_dispatch_target)
                .cloned(),
        );

        let event_name = match event.event_type {
            TouchEventType::Down => "touchstart",
            TouchEventType::Move => "touchmove",
            TouchEventType::Up => "touchend",
            TouchEventType::Cancel => "touchcancel",
        };

        let touch_event = TouchEvent::new(
            window,
            DOMString::from(event_name),
            EventBubbles::Bubbles,
            EventCancelable::from(event.is_cancelable()),
            EventComposed::Composed,
            Some(window),
            0i32,
            &TouchList::new(window, self.active_touch_points.borrow().r(), can_gc),
            &TouchList::new(window, from_ref(&&*changed_touch), can_gc),
            &TouchList::new(window, target_touches.r(), can_gc),
            // FIXME: modifier keys
            false,
            false,
            false,
            false,
            can_gc,
        );
        let event = touch_event.upcast::<Event>();
        event.fire(&touch_dispatch_target, can_gc);
        event.flags().into()