script: Introduce HtmlSerialize to support extensible node serialization (#40568)

XML and HTML serialization routines relied on a single, shared
implementation of the `markup5ever::Serialize` trait for the DOM Node
type.

These changes introduce the HtmlSerialize type to make it possible to
support XML serialization and fix other issues.

Testing: It does not change any behavior and it builds.
Fixes: #40552

---------

Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
This commit is contained in:
Rod Borovyk
2025-11-12 11:05:46 +01:00
committed by GitHub
parent bcba86eef7
commit a79d7d700d
5 changed files with 23 additions and 8 deletions

View File

@@ -119,6 +119,7 @@ use crate::dom::pointerevent::{PointerEvent, PointerId};
use crate::dom::processinginstruction::ProcessingInstruction;
use crate::dom::range::WeakRangeVec;
use crate::dom::raredata::NodeRareData;
use crate::dom::servoparser::html::HtmlSerialize;
use crate::dom::servoparser::{ServoParser, serialize_html_fragment};
use crate::dom::shadowroot::{IsUserAgentWidget, LayoutShadowRootHelpers, ShadowRoot};
use crate::dom::svg::svgsvgelement::{LayoutSVGSVGElementHelpers, SVGSVGElement};
@@ -3241,7 +3242,7 @@ impl Node {
let mut writer = vec![];
xml_serialize::serialize(
&mut writer,
&self,
&HtmlSerialize::new(self),
xml_serialize::SerializeOpts { traversal_scope },
)
.map_err(|error| {