diff options
author | Simon Wülker <simon.wuelker@arcor.de> | 2025-05-15 19:30:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-15 17:30:38 +0000 |
commit | b100a98e1d7f5ccf4af54a819a55f20f83308fef (patch) | |
tree | 02352489726897c790e7d4f5ef91e26408a4ce1f /components/shared/embedder/lib.rs | |
parent | f9382fcaa00206ce1f5f99a9dc417065d980b5ee (diff) | |
download | servo-b100a98e1d7f5ccf4af54a819a55f20f83308fef.tar.gz servo-b100a98e1d7f5ccf4af54a819a55f20f83308fef.zip |
Fully support `<input type=color>` (#36992)
This change adds a shadow-tree widget for `<input type=color>` elements.
It also involves some changes to the way layout interacts with the DOM,
because currently all `input` and `textarea` elements are rendered as
plain text and their descendants are ignored. This obviously doesn't
work for `<input type={color, date, range, etc}>`.

<details><summary>HTML used for the screenshot above</summary>
```html
<input type=color>
```
</details>
Testing: I doubt that this affects WPT tests, because the appearance and
behaviour of the widget is almost entirely unspecified.
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Diffstat (limited to 'components/shared/embedder/lib.rs')
-rw-r--r-- | components/shared/embedder/lib.rs | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/components/shared/embedder/lib.rs b/components/shared/embedder/lib.rs index e9427fcc719..575c8f54ff6 100644 --- a/components/shared/embedder/lib.rs +++ b/components/shared/embedder/lib.rs @@ -364,16 +364,8 @@ pub enum EmbedderMsg { ShutdownComplete, /// Request to display a notification. ShowNotification(Option<WebViewId>, Notification), - /// Indicates that the user has activated a `<select>` element. - /// - /// The embedder should respond with the new state of the `<select>` element. - ShowSelectElementMenu( - WebViewId, - Vec<SelectElementOptionOrOptgroup>, - Option<usize>, - DeviceIntRect, - IpcSender<Option<usize>>, - ), + /// Request to display a form control to the embedder. + ShowFormControl(WebViewId, DeviceIntRect, FormControl), /// Inform the embedding layer that a JavaScript evaluation has /// finished with the given result. FinishJavaScriptEvaluation( @@ -389,6 +381,18 @@ impl Debug for EmbedderMsg { } } +#[derive(Deserialize, Serialize)] +pub enum FormControl { + /// Indicates that the user has activated a `<select>` element. + SelectElement( + Vec<SelectElementOptionOrOptgroup>, + Option<usize>, + IpcSender<Option<usize>>, + ), + /// Indicates that the user has activated a `<input type=color>` element. + ColorPicker(RgbColor, IpcSender<Option<RgbColor>>), +} + /// Filter for file selection; /// the `String` content is expected to be extension (e.g, "doc", without the prefixing ".") #[derive(Clone, Debug, Deserialize, Serialize)] @@ -921,3 +925,10 @@ pub enum JavaScriptEvaluationError { /// value into a [`JSValue`]. SerializationError, } + +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub struct RgbColor { + pub red: u8, + pub green: u8, + pub blue: u8, +} |