devtools: Remove unsupported serde annotations from shared/devtools.rs (#42219)

There were some `#[serde(untagged)]` and `#[serde(skip*)]` annotations
in the shared devtools types. These are needed for correct JSON
serialization when sending messages to Firefox, but they fail in
multiprocess mode since we are sharing them through the IPC channel with
bincode, which doesn't support certain serde tags.

The workaround is to keep all shared types free from problematic
annotations, and defining wrapping types that are only used in the
devtools crate.

One instance are console messages and page errors. They have been moved
to `console.rs`, with `shared/devtools` only keeping the parts that are
needed for communication between threads.

The other instance are auto margins. Now the final message is built in
`page_style.rs`.

Apologies since both of them were introduced by me, I wasn't aware that
we were limited by bincode in multiprocess mode. A warning has been
added to `shared/devtools` listing the problematic annotations that
shouldn't be used in this file.

Testing: `mach test-devtools` and manual testing using `--multiprocess`.
Fixes: #42170

Signed-off-by: eri <eri@igalia.com>
This commit is contained in:
eri
2026-01-28 16:48:59 +01:00
committed by GitHub
parent 6b12ecf26b
commit 6e781aaf74
8 changed files with 265 additions and 247 deletions

View File

@@ -344,7 +344,7 @@ pub(crate) fn handle_get_layout(
documents: &DocumentCollection,
pipeline: PipelineId,
node_id: String,
reply: GenericSender<Option<ComputedNodeLayout>>,
reply: GenericSender<Option<(ComputedNodeLayout, AutoMargins)>>,
can_gc: CanGc,
) {
let node = match find_node_by_unique_id(documents, pipeline, &node_id) {
@@ -362,30 +362,28 @@ pub(crate) fn handle_get_layout(
let window = node.owner_window();
let computed_style = window.GetComputedStyle(elem, None);
let computed_layout = ComputedNodeLayout {
display: computed_style.Display().into(),
position: computed_style.Position().into(),
z_index: computed_style.ZIndex().into(),
box_sizing: computed_style.BoxSizing().into(),
margin_top: computed_style.MarginTop().into(),
margin_right: computed_style.MarginRight().into(),
margin_bottom: computed_style.MarginBottom().into(),
margin_left: computed_style.MarginLeft().into(),
border_top_width: computed_style.BorderTopWidth().into(),
border_right_width: computed_style.BorderRightWidth().into(),
border_bottom_width: computed_style.BorderBottomWidth().into(),
border_left_width: computed_style.BorderLeftWidth().into(),
padding_top: computed_style.PaddingTop().into(),
padding_right: computed_style.PaddingRight().into(),
padding_bottom: computed_style.PaddingBottom().into(),
padding_left: computed_style.PaddingLeft().into(),
width,
height,
};
reply
.send(Some(ComputedNodeLayout {
display: computed_style.Display().into(),
position: computed_style.Position().into(),
z_index: computed_style.ZIndex().into(),
box_sizing: computed_style.BoxSizing().into(),
auto_margins,
margin_top: computed_style.MarginTop().into(),
margin_right: computed_style.MarginRight().into(),
margin_bottom: computed_style.MarginBottom().into(),
margin_left: computed_style.MarginLeft().into(),
border_top_width: computed_style.BorderTopWidth().into(),
border_right_width: computed_style.BorderRightWidth().into(),
border_bottom_width: computed_style.BorderBottomWidth().into(),
border_left_width: computed_style.BorderLeftWidth().into(),
padding_top: computed_style.PaddingTop().into(),
padding_right: computed_style.PaddingRight().into(),
padding_bottom: computed_style.PaddingBottom().into(),
padding_left: computed_style.PaddingLeft().into(),
width,
height,
}))
.unwrap();
reply.send(Some((computed_layout, auto_margins))).unwrap();
}
pub(crate) fn handle_get_xpath(
@@ -453,10 +451,10 @@ fn determine_auto_margins(node: &Node) -> AutoMargins {
};
let margin = style.get_margin();
AutoMargins {
top: margin.margin_top.is_auto().then_some("auto".into()),
right: margin.margin_right.is_auto().then_some("auto".into()),
bottom: margin.margin_bottom.is_auto().then_some("auto".into()),
left: margin.margin_left.is_auto().then_some("auto".into()),
top: margin.margin_top.is_auto(),
right: margin.margin_right.is_auto(),
bottom: margin.margin_bottom.is_auto(),
left: margin.margin_left.is_auto(),
}
}