mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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:
parent
dfcbb18a8b
commit
26f61103d6
13 changed files with 144 additions and 43 deletions
|
@ -12,7 +12,7 @@ use embedder_traits::Cursor;
|
|||
use ipc_channel::ipc::IpcSender;
|
||||
use keyboard_types::{CompositionEvent, KeyboardEvent};
|
||||
use script_traits::{
|
||||
AnimationTickType, CompositorEvent, GamepadEvent, LogEntry, MediaSessionActionType,
|
||||
AnimationTickType, CompositorEvent, GamepadEvent, LogEntry, MediaSessionActionType, Theme,
|
||||
TraversalDirection, WebDriverCommandMsg, WindowSizeData, WindowSizeType,
|
||||
};
|
||||
use servo_url::ServoUrl;
|
||||
|
@ -46,6 +46,8 @@ pub enum ConstellationMsg {
|
|||
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
|
||||
/// Inform the constellation of a window being resized.
|
||||
WindowSize(TopLevelBrowsingContextId, WindowSizeData, WindowSizeType),
|
||||
/// Inform the constellation of a theme change.
|
||||
ThemeChange(Theme),
|
||||
/// Requests that the constellation instruct layout to begin a new tick of the animation.
|
||||
TickAnimation(PipelineId, AnimationTickType),
|
||||
/// Dispatch a webdriver command
|
||||
|
@ -110,6 +112,7 @@ impl ConstellationMsg {
|
|||
LoadUrl(..) => "LoadUrl",
|
||||
TraverseHistory(..) => "TraverseHistory",
|
||||
WindowSize(..) => "WindowSize",
|
||||
ThemeChange(..) => "ThemeChange",
|
||||
TickAnimation(..) => "TickAnimation",
|
||||
WebDriverCommand(..) => "WebDriverCommand",
|
||||
Reload(..) => "Reload",
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -48,6 +48,7 @@ use style::invalidation::element::restyle_hints::RestyleHint;
|
|||
use style::media_queries::Device;
|
||||
use style::properties::style_structs::Font;
|
||||
use style::properties::PropertyId;
|
||||
use style::queries::values::PrefersColorScheme;
|
||||
use style::selector_parser::{PseudoElement, RestyleDamage, Snapshot};
|
||||
use style::stylesheets::Stylesheet;
|
||||
use style::Atom;
|
||||
|
@ -426,6 +427,8 @@ pub struct ScriptReflow {
|
|||
pub animation_timeline_value: f64,
|
||||
/// The set of animations for this document.
|
||||
pub animations: DocumentAnimationSet,
|
||||
/// The theme for the window
|
||||
pub theme: PrefersColorScheme,
|
||||
}
|
||||
|
||||
/// A pending restyle.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue