Repository: servo/servo
File: components/servo/webview_delegate.rs (Rust)

Code before:
    /// Tell Servo that the file picker was dismissed with no selection.
    pub fn dismiss(mut self) {
        if let Some(sender) = self.response_sender.take() {
            let _ = sender.send(None);
        }
    }
}

impl Drop for FilePicker {
    fn drop(&mut self) {
        if let Some(sender) = self.response_sender.take() {
            let _ = sender.send(None);
        }
    }
}

/// Represents a request to enable the system input method interface.
pub struct InputMethodControl {
    pub(crate) id: EmbedderControlId,
    pub(crate) input_method_type: InputMethodType,
    pub(crate) text: String,
    pub(crate) insertion_point: Option<u32>,
    pub(crate) position: DeviceIntRect,
    pub(crate) multiline: bool,
    #[cfg_attr(not(any(target_os = "android", target_env = "ohos")), expect(dead_code))]
    pub(crate) has_sticky_activation: bool,
}

impl InputMethodControl {
    /// Return the type of input method that initated this request.
    pub fn input_method_type(&self) -> InputMethodType {
        self.input_method_type
    }

    /// Return the current string value of the input field.
    pub fn text(&self) -> String {
        self.text.clone()
    }

    /// The current zero-based insertion point / cursor position if it is within the field or `None`
    /// if it is not.
    pub fn insertion_point(&self) -> Option<u32> {
        self.insertion_point
    }

    /// Get the area occupied by the `<input>` element that triggered the input method.
    ///
    /// The embedder should use this value to position the input method interface that is
    /// shown to the user.
    pub fn position(&self) -> DeviceIntRect {
        self.position

Review comment (suggestion):
This should be exposed like other members of `InputMethodControl` with a `pub fn`.

In addition, the new function needs documentation that explains what this does. Currently, "sticky_activation" is incredibly mysterious unless you are familiar with the HTML specification. Instead, it should probably be called something like, "user_has_interacted_with_document" which is a bit more self-explanatory.

What I'm unsure about is this:

> When the [current high resolution time](https://w3c.github.io/hr-time/#dfn-current-high-resolution-time) given W is greater than or equal to the [last activation timestamp](https://html.spec.whatwg.org/multipage/interaction.html#last-activation-timestamp) in W, W is said to have [sticky activation](https://html.spec.whatwg.org/multipage/interaction.html#sticky-activation).

Since the IME always pops up due to a user activating an input field, won't this always be true? In what cases is it not true. Perhaps we should just not show the IME in those cases.

Code after:
    /// Tell Servo that the file picker was dismissed with no selection.
    pub fn dismiss(mut self) {
        if let Some(sender) = self.response_sender.take() {
            let _ = sender.send(None);
        }
    }
}

impl Drop for FilePicker {
    fn drop(&mut self) {
        if let Some(sender) = self.response_sender.take() {
            let _ = sender.send(None);
        }
    }
}

/// Represents a request to enable the system input method interface.
pub struct InputMethodControl {
    pub(crate) id: EmbedderControlId,
    pub(crate) input_method_type: InputMethodType,
    pub(crate) text: String,
    pub(crate) insertion_point: Option<u32>,
    pub(crate) position: DeviceIntRect,
    pub(crate) multiline: bool,
    pub(crate) allow_virtual_keyboard: bool,
}

impl InputMethodControl {
    /// Return the type of input method that initated this request.
    pub fn input_method_type(&self) -> InputMethodType {
        self.input_method_type
    }

    /// Return the current string value of the input field.
    pub fn text(&self) -> String {
        self.text.clone()
    }

    /// The current zero-based insertion point / cursor position if it is within the field or `None`
    /// if it is not.
    pub fn insertion_point(&self) -> Option<u32> {
        self.insertion_point
    }

    /// Get the area occupied by the `<input>` element that triggered the input method.
    ///
    /// The embedder should use this value to position the input method interface that is
    /// shown to the user.
    pub fn position(&self) -> DeviceIntRect {
        self.position
    }