mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Barebones media UI
This commit is contained in:
parent
4f6b86f9f5
commit
1c02fc94a8
11 changed files with 177 additions and 25 deletions
|
@ -163,6 +163,7 @@ use style::stylesheet_set::DocumentStylesheetSet;
|
|||
use style::stylesheets::{Origin, OriginSet, Stylesheet};
|
||||
use url::percent_encoding::percent_decode;
|
||||
use url::Host;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// The number of times we are allowed to see spurious `requestAnimationFrame()` calls before
|
||||
/// falling back to fake ones.
|
||||
|
@ -385,6 +386,12 @@ pub struct Document {
|
|||
shadow_roots: DomRefCell<HashSet<Dom<ShadowRoot>>>,
|
||||
/// Whether any of the shadow roots need the stylesheets flushed.
|
||||
shadow_roots_styles_changed: Cell<bool>,
|
||||
/// List of registered media controls.
|
||||
/// We need to keep this list to allow the media controls to
|
||||
/// access the "privileged" document.servoGetMediaControls(id) API,
|
||||
/// where `id` needs to match any of the registered ShadowRoots
|
||||
/// hosting the media controls UI.
|
||||
media_controls: DomRefCell<HashMap<String, Dom<ShadowRoot>>>,
|
||||
}
|
||||
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
|
@ -2457,6 +2464,18 @@ impl Document {
|
|||
self.responsive_images.borrow_mut().remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register_media_controls(&self, controls: &ShadowRoot) -> String {
|
||||
let id = Uuid::new_v4().to_string();
|
||||
self.media_controls
|
||||
.borrow_mut()
|
||||
.insert(id.clone(), Dom::from_ref(controls));
|
||||
id
|
||||
}
|
||||
|
||||
pub fn unregister_media_controls(&self, id: &str) {
|
||||
self.media_controls.borrow_mut().remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(MallocSizeOf, PartialEq)]
|
||||
|
@ -2750,6 +2769,7 @@ impl Document {
|
|||
delayed_tasks: Default::default(),
|
||||
shadow_roots: DomRefCell::new(HashSet::new()),
|
||||
shadow_roots_styles_changed: Cell::new(false),
|
||||
media_controls: DomRefCell::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4551,6 +4571,15 @@ impl DocumentMethods for Document {
|
|||
fn ExitFullscreen(&self) -> Rc<Promise> {
|
||||
self.exit_fullscreen()
|
||||
}
|
||||
|
||||
// Servo only API to get an instance of the controls of a specific
|
||||
// media element matching the given id.
|
||||
fn ServoGetMediaControls(&self, id: DOMString) -> Fallible<DomRoot<ShadowRoot>> {
|
||||
match self.media_controls.borrow().get(&*id) {
|
||||
Some(m) => Ok(DomRoot::from_ref(&*m)),
|
||||
None => Err(Error::InvalidAccess),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update_with_current_time_ms(marker: &Cell<u64>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue