mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
MediaSessionAction message from embedder to script thread
This commit is contained in:
parent
7101a9d070
commit
6233f78de4
5 changed files with 97 additions and 3 deletions
|
@ -139,7 +139,6 @@ use net_traits::{self, FetchResponseMsg, IpcSend, ResourceThreads};
|
|||
use profile_traits::mem;
|
||||
use profile_traits::time;
|
||||
use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent};
|
||||
use script_traits::MouseEventType;
|
||||
use script_traits::{webdriver_msg, LogEntry, ScriptToConstellationChan, ServiceWorkerMsg};
|
||||
use script_traits::{
|
||||
AnimationState, AnimationTickType, AuxiliaryBrowsingContextLoadInfo, CompositorEvent,
|
||||
|
@ -154,6 +153,7 @@ use script_traits::{
|
|||
};
|
||||
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory};
|
||||
use script_traits::{MessagePortMsg, PortMessageTask, StructuredSerializedData};
|
||||
use script_traits::{MediaSessionActionType, MouseEventType};
|
||||
use script_traits::{SWManagerMsg, ScopeThings, UpdatePipelineIdReason, WebDriverCommandMsg};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use servo_config::{opts, pref};
|
||||
|
@ -1541,6 +1541,9 @@ where
|
|||
FromCompositorMsg::ExitFullScreen(top_level_browsing_context_id) => {
|
||||
self.handle_exit_fullscreen_msg(top_level_browsing_context_id);
|
||||
},
|
||||
FromCompositorMsg::MediaSessionAction(top_level_browsing_context_id, action) => {
|
||||
self.handle_media_session_action_msg(top_level_browsing_context_id, action);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5019,4 +5022,35 @@ where
|
|||
.send(ToCompositorMsg::SetFrameTree(frame_tree));
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_media_session_action_msg(
|
||||
&mut self,
|
||||
top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||
action: MediaSessionActionType,
|
||||
) {
|
||||
let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
|
||||
let pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
||||
Some(browsing_context) => browsing_context.pipeline_id,
|
||||
None => {
|
||||
return warn!(
|
||||
"Browsing context {} got media session action request after closure.",
|
||||
browsing_context_id
|
||||
);
|
||||
},
|
||||
};
|
||||
let msg =
|
||||
ConstellationControlMsg::MediaSessionAction(top_level_browsing_context_id, action);
|
||||
let result = match self.pipelines.get(&pipeline_id) {
|
||||
None => {
|
||||
return warn!(
|
||||
"Pipeline {} got media session action request after closure.",
|
||||
pipeline_id
|
||||
)
|
||||
},
|
||||
Some(pipeline) => pipeline.event_loop.send(msg),
|
||||
};
|
||||
if let Err(e) = result {
|
||||
self.handle_send_error(pipeline_id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue