Nacre/vendor/servo-script/dom/testing/layoutresult.rs
astar76 0ecfd0f573 S031: root due timers in vendored servo-script (R5-01 SIGSEGV), crash-adblock regression smoke
fire_timer moved due timers into an unrooted Vec; a GC inside one callback swept
the functions of the timers still waiting. Heavy-web reruns and cargo test still pending.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 20:38:47 -06:00

77 lines
2.2 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 dom_struct::dom_struct;
use js::context::JSContext;
use js::gc::MutableHandleValue;
use script_bindings::domstring::DOMString;
use script_bindings::reflector::{Reflector, reflect_dom_object};
use crate::dom::bindings::codegen::Bindings::ServoTestUtilsBinding::LayoutResultMethods;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::utils::to_frozen_array;
use crate::dom::globalscope::GlobalScope;
#[dom_struct]
pub(crate) struct LayoutResult {
reflector_: Reflector,
phases: Vec<DOMString>,
rebuilt_fragment_count: u32,
restyle_fragment_count: u32,
only_descendants_changed_count: u32,
}
impl LayoutResult {
pub(crate) fn new_inherited(
phases: Vec<DOMString>,
rebuilt_fragment_count: u32,
restyle_fragment_count: u32,
only_descendants_changed_count: u32,
) -> Self {
Self {
reflector_: Reflector::new(),
phases,
rebuilt_fragment_count,
restyle_fragment_count,
only_descendants_changed_count,
}
}
pub(crate) fn new(
cx: &mut JSContext,
global: &GlobalScope,
phases: Vec<DOMString>,
rebuilt_fragment_count: u32,
restyle_fragment_count: u32,
only_descendants_changed_count: u32,
) -> DomRoot<Self> {
reflect_dom_object(
cx,
Box::new(Self::new_inherited(
phases,
rebuilt_fragment_count,
restyle_fragment_count,
only_descendants_changed_count,
)),
global,
)
}
}
impl LayoutResultMethods<crate::DomTypeHolder> for LayoutResult {
fn Phases(&self, cx: &mut JSContext, return_value: MutableHandleValue) {
to_frozen_array(cx, &self.phases, return_value);
}
fn RebuiltFragmentCount(&self) -> u32 {
self.rebuilt_fragment_count
}
fn RestyleFragmentCount(&self) -> u32 {
self.restyle_fragment_count
}
fn OnlyDescendantsChangedCount(&self) -> u32 {
self.only_descendants_changed_count
}
}