Repository: servo/servo
File: components/shared/embedder/embedder_controls.rs (Rust)

Code before:
        const Selection = 1 << 4;
    }
}

/// Information about the element that a context menu was activated for. values which
/// do not apply to this element will be `None`.
///
/// Note that an element might be both an image and a link, if the element is an `<img>`
/// tag nested inside of a `<a>` tag.
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct ContextMenuElementInformation {
    pub flags: ContextMenuElementInformationFlags,
    pub link_url: Option<Url>,
    pub image_url: Option<Url>,
}

/// Request to present an IME to the user when an editable element is focused. If `type` is
/// [`InputMethodType::Text`], then the `text` parameter specifies the pre-existing text content and
/// `insertion_point` the zero-based index into the string of the insertion point.
#[derive(Debug, Deserialize, Serialize)]
pub struct InputMethodRequest {
    pub input_method_type: InputMethodType,
    pub text: String,
    pub insertion_point: Option<u32>,
    pub multiline: bool,
    pub has_sticky_activation: bool,
}

/// Filter for file selection;
/// the `String` content is expected to be extension (e.g, "doc", without the prefixing ".")
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct FilterPattern(pub String);

#[derive(Debug, Deserialize, Serialize)]
pub struct FilePickerRequest {
    pub origin: ImmutableOrigin,
    pub current_paths: Vec<PathBuf>,
    pub filter_patterns: Vec<FilterPattern>,
    pub allow_select_multiple: bool,
    pub accept_current_paths_for_testing: bool,
}

#[derive(Debug, Deserialize, Serialize)]
pub enum EmbedderControlResponse {
    SelectElement(Option<usize>),
    ColorPicker(Option<RgbColor>),
    FilePicker(Option<Vec<SelectedFile>>),
    ContextMenu(Option<ContextMenuAction>),
}

/// Response to file selection request

Review comment (suggestion):
I would keep this consistent with the embedding layer:

```suggestion
    pub allow_virtual_keyboard: bool,
```

Code after:
        const Selection = 1 << 4;
    }
}

/// Information about the element that a context menu was activated for. values which
/// do not apply to this element will be `None`.
///
/// Note that an element might be both an image and a link, if the element is an `<img>`
/// tag nested inside of a `<a>` tag.
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct ContextMenuElementInformation {
    pub flags: ContextMenuElementInformationFlags,
    pub link_url: Option<Url>,
    pub image_url: Option<Url>,
}

/// Request to present an IME to the user when an editable element is focused. If `type` is
/// [`InputMethodType::Text`], then the `text` parameter specifies the pre-existing text content and
/// `insertion_point` the zero-based index into the string of the insertion point.
#[derive(Debug, Deserialize, Serialize)]
pub struct InputMethodRequest {
    pub input_method_type: InputMethodType,
    pub text: String,
    pub insertion_point: Option<u32>,
    pub multiline: bool,
    pub allow_virtual_keyboard: bool,
}

/// Filter for file selection;
/// the `String` content is expected to be extension (e.g, "doc", without the prefixing ".")
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct FilterPattern(pub String);

#[derive(Debug, Deserialize, Serialize)]
pub struct FilePickerRequest {
    pub origin: ImmutableOrigin,
    pub current_paths: Vec<PathBuf>,
    pub filter_patterns: Vec<FilterPattern>,
    pub allow_select_multiple: bool,
    pub accept_current_paths_for_testing: bool,
}

#[derive(Debug, Deserialize, Serialize)]
pub enum EmbedderControlResponse {
    SelectElement(Option<usize>),
    ColorPicker(Option<RgbColor>),
    FilePicker(Option<Vec<SelectedFile>>),
    ContextMenu(Option<ContextMenuAction>),
}

/// Response to file selection request