Add embedder event for preferred color scheme and respond to it in the LayoutThread (#34532)

* respond to winit platform theme changed event and send it to the layout thread

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* refactoring viewport and theme change handling functions based on feedback

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* fixing issues reported by test-tidy

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* update stylo in order to use color_scheme function on Device

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

---------

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>
Co-authored-by: lazypassion <25536767+lazypassion@users.noreply.github.com>
This commit is contained in:
arthmis 2024-12-12 01:17:02 -05:00 committed by GitHub
parent dfcbb18a8b
commit 26f61103d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 144 additions and 43 deletions

View file

@ -284,6 +284,8 @@ pub enum ConstellationControlMsg {
AttachLayout(NewLayoutInfo),
/// Window resized. Sends a DOM event eventually, but first we combine events.
Resize(PipelineId, WindowSizeData, WindowSizeType),
/// Theme changed.
ThemeChange(PipelineId, Theme),
/// Notifies script that window has been resized but to not take immediate action.
ResizeInactive(PipelineId, WindowSizeData),
/// Window switched from fullscreen mode.
@ -398,6 +400,7 @@ impl fmt::Debug for ConstellationControlMsg {
NavigationResponse(..) => "NavigationResponse",
AttachLayout(..) => "AttachLayout",
Resize(..) => "Resize",
ThemeChange(..) => "ThemeChange",
ResizeInactive(..) => "ResizeInactive",
UnloadDocument(..) => "UnloadDocument",
ExitPipeline(..) => "ExitPipeline",
@ -776,6 +779,15 @@ pub enum WindowSizeType {
Resize,
}
/// The type of platform theme.
#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
pub enum Theme {
/// Light theme.
Light,
/// Dark theme.
Dark,
}
/// Messages to the constellation originating from the WebDriver server.
#[derive(Debug, Deserialize, Serialize)]
pub enum WebDriverCommandMsg {