MediaSource, SourceBuffer, SourceBufferList over GStreamer's MSE library; URL.createObjectURL(MediaSource); HTMLMediaElement attaches via mse://. tests/smoke/mse.txt plays chunk-appended fMP4 and WebM. Co-Authored-By: Claude Opus 5.5 <[email protected]>
150 lines
5.1 KiB
Rust
150 lines
5.1 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
use std::rc::Rc;
|
|
use std::sync::Arc;
|
|
|
|
use data_url::mime::Mime;
|
|
use dom_struct::dom_struct;
|
|
use js::context::{JSContext, NoGC};
|
|
use net_traits::image_cache::ImageCache;
|
|
use net_traits::request::InsecureRequestsPolicy;
|
|
use script_bindings::codegen::GenericBindings::WindowBinding::WindowMethods;
|
|
use script_bindings::reflector::reflect_dom_object;
|
|
use script_traits::DocumentActivity;
|
|
use servo_url::{MutableOrigin, ServoUrl};
|
|
|
|
use crate::dom::animations::documenttimeline::DocumentTimeline;
|
|
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
|
DocumentMethods, NamedPropertyValue,
|
|
};
|
|
use crate::dom::bindings::codegen::Bindings::XMLDocumentBinding::XMLDocumentMethods;
|
|
use crate::dom::bindings::inheritance::Castable;
|
|
use crate::dom::bindings::root::DomRoot;
|
|
use crate::dom::bindings::str::DOMString;
|
|
use crate::dom::customelementregistry::CustomElementReactionStack;
|
|
use crate::dom::document::{Document, HasBrowsingContext, IsHTMLDocument};
|
|
use crate::dom::location::Location;
|
|
use crate::dom::node::Node;
|
|
use crate::dom::window::Window;
|
|
use crate::event_loop::document_loader::DocumentLoader;
|
|
|
|
// https://dom.spec.whatwg.org/#xmldocument
|
|
#[dom_struct]
|
|
pub(crate) struct XMLDocument {
|
|
document: Document,
|
|
}
|
|
|
|
impl XMLDocument {
|
|
#[expect(clippy::too_many_arguments)]
|
|
fn new_inherited(
|
|
window: &Window,
|
|
has_browsing_context: HasBrowsingContext,
|
|
url: Option<ServoUrl>,
|
|
origin: MutableOrigin,
|
|
is_html_document: IsHTMLDocument,
|
|
content_type: Option<Mime>,
|
|
last_modified: Option<String>,
|
|
activity: DocumentActivity,
|
|
doc_loader: DocumentLoader,
|
|
inherited_insecure_requests_policy: Option<InsecureRequestsPolicy>,
|
|
has_trustworthy_ancestor_origin: bool,
|
|
custom_element_reaction_stack: Rc<CustomElementReactionStack>,
|
|
timeline: &DocumentTimeline,
|
|
image_cache: Arc<dyn ImageCache>,
|
|
) -> XMLDocument {
|
|
XMLDocument {
|
|
document: Document::new_inherited(
|
|
window,
|
|
has_browsing_context,
|
|
url,
|
|
None,
|
|
origin,
|
|
is_html_document,
|
|
content_type,
|
|
last_modified,
|
|
activity,
|
|
doc_loader,
|
|
None,
|
|
None,
|
|
Default::default(),
|
|
false,
|
|
false,
|
|
inherited_insecure_requests_policy,
|
|
has_trustworthy_ancestor_origin,
|
|
custom_element_reaction_stack,
|
|
window.Document().creation_sandboxing_flag_set(),
|
|
timeline,
|
|
window.pipeline_id(),
|
|
image_cache,
|
|
),
|
|
}
|
|
}
|
|
|
|
#[expect(clippy::too_many_arguments)]
|
|
pub(crate) fn new(
|
|
cx: &mut JSContext,
|
|
window: &Window,
|
|
has_browsing_context: HasBrowsingContext,
|
|
url: Option<ServoUrl>,
|
|
origin: MutableOrigin,
|
|
doctype: IsHTMLDocument,
|
|
content_type: Option<Mime>,
|
|
last_modified: Option<String>,
|
|
activity: DocumentActivity,
|
|
doc_loader: DocumentLoader,
|
|
inherited_insecure_requests_policy: Option<InsecureRequestsPolicy>,
|
|
has_trustworthy_ancestor_origin: bool,
|
|
custom_element_reaction_stack: Rc<CustomElementReactionStack>,
|
|
image_cache: Arc<dyn ImageCache>,
|
|
) -> DomRoot<XMLDocument> {
|
|
let timeline = DocumentTimeline::new(cx, window);
|
|
let doc = reflect_dom_object(
|
|
cx,
|
|
Box::new(XMLDocument::new_inherited(
|
|
window,
|
|
has_browsing_context,
|
|
url,
|
|
origin,
|
|
doctype,
|
|
content_type,
|
|
last_modified,
|
|
activity,
|
|
doc_loader,
|
|
inherited_insecure_requests_policy,
|
|
has_trustworthy_ancestor_origin,
|
|
custom_element_reaction_stack,
|
|
&timeline,
|
|
image_cache,
|
|
)),
|
|
window,
|
|
);
|
|
{
|
|
let node = doc.upcast::<Node>();
|
|
node.set_owner_doc(&doc.document);
|
|
}
|
|
doc
|
|
}
|
|
}
|
|
|
|
impl XMLDocumentMethods<crate::DomTypeHolder> for XMLDocument {
|
|
/// <https://html.spec.whatwg.org/multipage/#dom-document-location>
|
|
fn GetLocation(&self, cx: &mut JSContext) -> Option<DomRoot<Location>> {
|
|
self.upcast::<Document>().GetLocation(cx)
|
|
}
|
|
|
|
/// <https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names>
|
|
fn SupportedPropertyNames(&self, no_gc: &NoGC) -> Vec<DOMString> {
|
|
self.upcast::<Document>().SupportedPropertyNames(no_gc)
|
|
}
|
|
|
|
/// <https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter>
|
|
fn NamedGetter(
|
|
&self,
|
|
cx: &mut js::context::JSContext,
|
|
name: DOMString,
|
|
) -> Option<NamedPropertyValue> {
|
|
self.upcast::<Document>().NamedGetter(cx, name)
|
|
}
|
|
}
|