Repository: servo/servo
File: components/webdriver_server/actions.rs (Rust)

Code before:
                key_actions.into_iter().map(ActionItem::Key).collect()
            },
            ActionsType::Pointer {
                parameters,
                actions: pointer_actions,
            } => {
                let pointer_ids = self.session().unwrap().pointer_ids();
                // Get or create a pointer input source with subtype, and other iterms
                // set to default values.
                self.input_state_table_mut()
                    .entry(id)
                    .or_insert(InputSourceState::Pointer(PointerInputState::new(
                        parameters.pointer_type,
                        pointer_ids,
                        0.0,
                        0.0,
                    )));
                pointer_actions
                    .into_iter()
                    .map(ActionItem::Pointer)
                    .collect()
            },
            ActionsType::Wheel {
                actions: wheel_actions,
            } => {
                self.input_state_table_mut()
                    .entry(id)
                    .or_insert(InputSourceState::Wheel);
                wheel_actions.into_iter().map(ActionItem::Wheel).collect()
            },
        }
    }

    fn input_state_table_mut(&mut self) -> &mut HashMap<String, InputSourceState> {
        &mut self.session_mut().unwrap().input_state_table
    }

    fn get_pointer_input_state_mut(&mut self, source_id: &str) -> &mut PointerInputState {
        let InputSourceState::Pointer(pointer_input_state) =
            self.input_state_table_mut().get_mut(source_id).unwrap()
        else {
            unreachable!();
        };
        pointer_input_state
    }

    fn get_pointer_input_state(&self, source_id: &str) -> &PointerInputState {
        let InputSourceState::Pointer(pointer_input_state) = self
            .session()
            .unwrap()
            .input_state_table

Review comment (suggestion):
We are no longer ignoring requested pointer type.
This allows us to dispatch touch actions correctly for Perform Actions.

Code after:
                actions: null_actions,
            } => {
                self.input_state_table_mut()
                    .entry(id)
                    .or_insert(InputSourceState::Null);
                null_actions.into_iter().map(ActionItem::Null).collect()
            },
            ActionsType::Key {
                actions: key_actions,
            } => {
                self.input_state_table_mut()
                    .entry(id)
                    .or_insert(InputSourceState::Key(KeyInputState::new()));
                key_actions.into_iter().map(ActionItem::Key).collect()
            },
            ActionsType::Pointer {
                parameters,
                actions: pointer_actions,
            } => {
                let pointer_ids = self.session().unwrap().pointer_ids();
                // Get or create a pointer input source with subtype, and other iterms
                // set to default values.
                self.input_state_table_mut()
                    .entry(id)
                    .or_insert(InputSourceState::Pointer(PointerInputState::new(
                        parameters.pointer_type,
                        pointer_ids,
                        0.0,
                        0.0,
                    )));
                pointer_actions
                    .into_iter()
                    .map(ActionItem::Pointer)
                    .collect()
            },
            ActionsType::Wheel {
                actions: wheel_actions,
            } => {
                self.input_state_table_mut()
                    .entry(id)
                    .or_insert(InputSourceState::Wheel);
                wheel_actions.into_iter().map(ActionItem::Wheel).collect()
            },
        }
    }

    fn input_state_table_mut(&mut self) -> &mut HashMap<String, InputSourceState> {
        &mut self.session_mut().unwrap().input_state_table
    }

    fn get_pointer_input_state_mut(&mut self, source_id: &str) -> &mut PointerInputState {