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

@ -14,8 +14,8 @@ use keyboard_types::{CompositionEvent, KeyboardEvent};
use libc::c_void;
use net::protocols::ProtocolRegistry;
use script_traits::{
GamepadEvent, MediaSessionActionType, MouseButton, TouchEventType, TouchId, TraversalDirection,
WheelDelta,
GamepadEvent, MediaSessionActionType, MouseButton, Theme, TouchEventType, TouchId,
TraversalDirection, WheelDelta,
};
use servo_geometry::{DeviceIndependentIntRect, DeviceIndependentIntSize, DeviceIndependentPixel};
use servo_url::ServoUrl;
@ -55,6 +55,8 @@ pub enum EmbedderEvent {
Refresh,
/// Sent when the window is resized.
WindowResize,
/// Sent when the platform theme changes.
ThemeChange(Theme),
/// Sent when a navigation request from script is allowed/refused.
AllowNavigationResponse(PipelineId, bool),
/// Sent when a new URL is to be loaded.
@ -141,6 +143,7 @@ impl Debug for EmbedderEvent {
EmbedderEvent::Idle => write!(f, "Idle"),
EmbedderEvent::Refresh => write!(f, "Refresh"),
EmbedderEvent::WindowResize => write!(f, "Resize"),
EmbedderEvent::ThemeChange(..) => write!(f, "ThemeChange"),
EmbedderEvent::Keyboard(..) => write!(f, "Keyboard"),
EmbedderEvent::IMEComposition(..) => write!(f, "IMEComposition"),
EmbedderEvent::AllowNavigationResponse(..) => write!(f, "AllowNavigationResponse"),