Nacre/vendor/servo-script/css/css.rs
astar76 1c078655e2 S022: MSE prototype on gst_mse (vendored script, script-bindings, servo-media*)
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]>
2026-11-12 10:21:01 -06:00

87 lines
2.5 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/. */
//! Helpers for CSS value parsing.
use std::sync::LazyLock;
use style::context::QuirksMode;
use style::error_reporting::ParseErrorReporter;
use style::parser::ParserContext;
use style::stylesheets::{CssRuleType, Origin, UrlExtraData};
use style_traits::ParsingMode;
use url::Url;
use crate::dom::document::Document;
pub(crate) static ANONYMOUS_CONTENT_URL_DATA: LazyLock<UrlExtraData> =
LazyLock::new(|| Url::parse("about:blank").unwrap().into());
/// Creates a `ParserContext` from the given document.
///
/// Automatically configures quirks mode and error reporter from the document.
pub(crate) fn parser_context_for_document<'a>(
document: &'a Document,
rule_type: CssRuleType,
parsing_mode: ParsingMode,
url_data: &'a UrlExtraData,
) -> ParserContext<'a> {
let quirks_mode = document.quirks_mode();
let error_reporter = document.window().css_error_reporter();
ParserContext::new(
Origin::Author,
url_data,
Some(rule_type),
parsing_mode,
quirks_mode,
/* namespaces = */ Default::default(),
Some(error_reporter),
None,
/* attr_taint = */ Default::default(),
)
}
/// Like [`parser_context_for_document`], but with a custom error reporter.
pub(crate) fn parser_context_for_document_with_reporter<'a>(
document: &'a Document,
rule_type: CssRuleType,
parsing_mode: ParsingMode,
url_data: &'a UrlExtraData,
error_reporter: &'a dyn ParseErrorReporter,
) -> ParserContext<'a> {
let quirks_mode = document.quirks_mode();
ParserContext::new(
Origin::Author,
url_data,
Some(rule_type),
parsing_mode,
quirks_mode,
/* namespaces = */ Default::default(),
Some(error_reporter),
None,
/* attr_taint = */ Default::default(),
)
}
/// Creates a `ParserContext` without a document, using no quirks mode
/// and no error reporter.
pub(crate) fn parser_context_for_anonymous_content<'a>(
rule_type: CssRuleType,
parsing_mode: ParsingMode,
url_data: &'a UrlExtraData,
) -> ParserContext<'a> {
ParserContext::new(
Origin::Author,
url_data,
Some(rule_type),
parsing_mode,
QuirksMode::NoQuirks,
/* namespaces = */ Default::default(),
None,
None,
/* attr_taint = */ Default::default(),
)
}