mirror of
https://github.com/servo/servo.git
synced 2025-06-08 08:33:26 +00: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
|
@ -85,8 +85,8 @@ use script_traits::{
|
|||
EventResult, HistoryEntryReplacement, InitialScriptState, JsEvalResult, LayoutMsg, LoadData,
|
||||
LoadOrigin, MediaSessionActionType, MouseButton, MouseEventType, NewLayoutInfo, Painter,
|
||||
ProgressiveWebMetricType, ScriptMsg, ScriptToConstellationChan, ScrollState,
|
||||
StructuredSerializedData, TimerSchedulerMsg, TouchEventType, TouchId, UntrustedNodeAddress,
|
||||
UpdatePipelineIdReason, WheelDelta, WindowSizeData, WindowSizeType,
|
||||
StructuredSerializedData, Theme, TimerSchedulerMsg, TouchEventType, TouchId,
|
||||
UntrustedNodeAddress, UpdatePipelineIdReason, WheelDelta, WindowSizeData, WindowSizeType,
|
||||
};
|
||||
use servo_atoms::Atom;
|
||||
use servo_config::opts;
|
||||
|
@ -2021,6 +2021,7 @@ impl ScriptThread {
|
|||
.parent_info
|
||||
.or(Some(new_layout_info.new_pipeline_id)),
|
||||
Resize(id, ..) => Some(id),
|
||||
ThemeChange(id, ..) => Some(id),
|
||||
ResizeInactive(id, ..) => Some(id),
|
||||
UnloadDocument(id) => Some(id),
|
||||
ExitPipeline(id, ..) => Some(id),
|
||||
|
@ -2265,6 +2266,9 @@ impl ScriptThread {
|
|||
ConstellationControlMsg::ResizeInactive(id, new_size) => {
|
||||
self.handle_resize_inactive_msg(id, new_size)
|
||||
},
|
||||
ConstellationControlMsg::ThemeChange(_, theme) => {
|
||||
self.handle_theme_change(theme);
|
||||
},
|
||||
ConstellationControlMsg::GetTitle(pipeline_id) => {
|
||||
self.handle_get_title_msg(pipeline_id)
|
||||
},
|
||||
|
@ -2856,6 +2860,15 @@ impl ScriptThread {
|
|||
})
|
||||
}
|
||||
|
||||
fn handle_theme_change(&self, theme: Theme) {
|
||||
let docs = self.documents.borrow();
|
||||
for (_, document) in docs.iter() {
|
||||
let window = document.window();
|
||||
window.set_theme(theme);
|
||||
window.force_reflow(ReflowGoal::Full, ReflowReason::ThemeChange, None);
|
||||
}
|
||||
}
|
||||
|
||||
// exit_fullscreen creates a new JS promise object, so we need to have entered a realm
|
||||
fn handle_exit_fullscreen(&self, id: PipelineId, can_gc: CanGc) {
|
||||
let document = self.documents.borrow().find_document(id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue