Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(style): stabilize document observation environments
ldm07db06196414e
diff --git a/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/document.rs b/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/document.rsindex d54a83e33..3cafa4a56 100644--- a/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/document.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/document.rs@@ -270,9 +270,11 @@ fn install_child_document_stream_methods<'s>(value.into(),);}- runtime- .dom_host_mut()- .mark_subtree_connected_preserving_owner_document(document_handle);+ if !runtime.dom_host().is_connected(document_handle) {+ runtime+ .dom_host_mut()+ .mark_subtree_connected_preserving_owner_document(document_handle);+ }}let _ = ChildDocumentStreamMethodsDeclaration::new(handle_value).initialize(scope, document);}diff --git a/moli-renderer-v8/src/native_bridge/context_host/layout.rs b/moli-renderer-v8/src/native_bridge/context_host/layout.rsindex ed64e5c94..c9b0abe6f 100644--- a/moli-renderer-v8/src/native_bridge/context_host/layout.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/layout.rs@@ -6,11 +6,13 @@ use moli_layout::{};use super::JsContextHost;+use super::layout_state::InferredFrameStyleViewportCacheKey;use crate::{css_resource_urls::{CompletedStylesheetWebFont, StylesheetLoadBlockingResource},document_runtime::DomHandle,native_bridge::element::iframe_handle_viewport,script_vm::web_fonts::DocumentWebFontCompletion,+ style_engine::{StyleViewport, StyloStyleEnvironment},};/// Resets the entry flag on every return path, including unwinding.@@ -140,6 +142,40 @@ impl JsContextHost {.frame_viewport(frame)}+ pub(crate) fn inferred_frame_style_viewport(+ &self,+ frame: DomHandle,+ parent_document: DomHandle,+ parent_viewport: StyleViewport,+ compute: impl FnOnce() -> StyleViewport,+ ) -> StyleViewport {+ let key = InferredFrameStyleViewportCacheKey {+ dom_version: self.dom_host().dom_version(),+ parent_style_epoch: self+ .style_engine+ .target_context_epoch_for_document(parent_document),+ parent_viewport,+ environment: StyloStyleEnvironment::from_emulated_media(self.emulated_media()),+ };+ if let Ok(mut state) = self.document_layout_state.try_borrow_mut()+ && let Some(viewport) = state.inferred_frame_style_viewport(frame, key)+ {+ return viewport;+ }+ let viewport = compute();+ if let Ok(mut state) = self.document_layout_state.try_borrow_mut() {+ state.publish_inferred_frame_style_viewport(frame, key, viewport);+ }+ viewport+ }++ #[cfg(test)]+ pub(crate) fn inferred_frame_style_viewport_cache_observability(&self) -> (u64, u64, usize) {+ self.document_layout_state+ .borrow()+ .inferred_frame_style_viewport_cache_observability()+ }+pub(crate) fn with_fresh_layout_pass_for_document<T>(&self,document: DomHandle,diff --git a/moli-renderer-v8/src/native_bridge/context_host/layout_state.rs b/moli-renderer-v8/src/native_bridge/context_host/layout_state.rsindex a093d5000..62c414293 100644--- a/moli-renderer-v8/src/native_bridge/context_host/layout_state.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/layout_state.rs@@ -7,9 +7,23 @@ use crate::{css_resource_urls::{CompletedStylesheetWebFont, StylesheetLoadBlockingResource},document_runtime::DomHandle,script_vm::web_fonts::{DocumentWebFontCompletion, DocumentWebFontState},- style_engine::StylesheetResourceGeneration,+ style_engine::{StyleViewport, StylesheetResourceGeneration, StyloStyleEnvironment},};+#[derive(Clone, Copy, Debug, PartialEq)]+pub(super) struct InferredFrameStyleViewportCacheKey {+ pub(super) dom_version: u64,+ pub(super) parent_style_epoch: u64,+ pub(super) parent_viewport: StyleViewport,+ pub(super) environment: StyloStyleEnvironment,+}++#[derive(Clone, Copy, Debug)]+struct CachedInferredFrameStyleViewport {+ key: InferredFrameStyleViewportCacheKey,+ viewport: StyleViewport,+}+/// Layout-facing state whose lifetime is bounded by exactly one main Document.////// `ScriptVm` outlives `document.open()`, so the main-document owner@@ -34,6 +48,14 @@ pub(super) struct DocumentLayoutState {/// separate from the single latest-tree slot because a later fresh layout/// may replace that slot while the frame view remains live.frame_viewports: HashMap<DomHandle, LayoutViewport>,+ /// Authored-size fallback used before parent layout publishes an exact+ /// iframe content viewport. The dependency key makes clean style reads+ /// cheap without turning this into independently valid layout state.+ inferred_frame_style_viewports: HashMap<DomHandle, CachedInferredFrameStyleViewport>,+ #[cfg(test)]+ inferred_frame_style_viewport_cache_hits: u64,+ #[cfg(test)]+ inferred_frame_style_viewport_cache_misses: u64,}impl DocumentLayoutState {@@ -123,6 +145,39 @@ impl DocumentLayoutState {self.frame_viewports.get(&frame).copied()}+ pub(super) fn inferred_frame_style_viewport(+ &mut self,+ frame: DomHandle,+ key: InferredFrameStyleViewportCacheKey,+ ) -> Option<StyleViewport> {+ let viewport = self+ .inferred_frame_style_viewports+ .get(&frame)+ .filter(|cached| cached.key == key)+ .map(|cached| cached.viewport);+ #[cfg(test)]+ if viewport.is_some() {+ self.inferred_frame_style_viewport_cache_hits = self+ .inferred_frame_style_viewport_cache_hits+ .saturating_add(1);+ } else {+ self.inferred_frame_style_viewport_cache_misses = self+ .inferred_frame_style_viewport_cache_misses+ .saturating_add(1);+ }+ viewport+ }++ pub(super) fn publish_inferred_frame_style_viewport(+ &mut self,+ frame: DomHandle,+ key: InferredFrameStyleViewportCacheKey,+ viewport: StyleViewport,+ ) {+ self.inferred_frame_style_viewports+ .insert(frame, CachedInferredFrameStyleViewport { key, viewport });+ }+pub(super) fn update_frame_viewports(&mut self,updates: impl IntoIterator<Item = (DomHandle, Option<LayoutViewport>)>,@@ -144,6 +199,17 @@ impl DocumentLayoutState {mut is_live: impl FnMut(DomHandle) -> bool,) {self.frame_viewports.retain(|frame, _| is_live(*frame));+ self.inferred_frame_style_viewports+ .retain(|frame, _| is_live(*frame));+ }++ #[cfg(test)]+ pub(super) fn inferred_frame_style_viewport_cache_observability(&self) -> (u64, u64, usize) {+ (+ self.inferred_frame_style_viewport_cache_hits,+ self.inferred_frame_style_viewport_cache_misses,+ self.inferred_frame_style_viewports.len(),+ )}#[cfg(test)]diff --git a/moli-renderer-v8/src/native_bridge/element/styles.rs b/moli-renderer-v8/src/native_bridge/element/styles.rsindex cd0fa7d76..29be7c925 100644--- a/moli-renderer-v8/src/native_bridge/element/styles.rs+++ b/moli-renderer-v8/src/native_bridge/element/styles.rs@@ -526,6 +526,18 @@ pub(crate) fn iframe_handle_viewport(iframe_handle_viewport_with_depth(host, frame_handle, 0)}+pub(in crate::native_bridge::element) fn style_viewport_for_document(+ host: &JsContextHost,+ document: DomHandle,+) -> StyleViewport {+ if document == host.document_handle() {+ return host.style_viewport();+ }+ host.child_browsing_context_host_for_document_handle(document)+ .and_then(|frame| iframe_handle_viewport(host, frame))+ .unwrap_or_default()+}+pub(crate) fn computed_style_property_values_for_document_snapshot(host: &JsContextHost,handle: DomHandle,@@ -669,10 +681,8 @@ fn style_computation_context_for_document_snapshot(return Some(DocumentSnapshotStyleComputation::HiddenChildFrame);}Some(DocumentSnapshotStyleComputation::Available(- StyleComputationContext::new(- iframe_handle_viewport(host, frame_handle).unwrap_or_default(),- )- .with_read_document(Some(document)),+ StyleComputationContext::new(style_viewport_for_document(host, document))+ .with_read_document(Some(document)),))}}@@ -685,10 +695,12 @@ fn iframe_handle_viewport_with_depth(if depth > 32 {return None;}- let parent_viewport = host+ let parent_document = host.dom_host().owner_document_handle(frame_handle)- .and_then(|document| host.child_browsing_context_host_for_document_handle(document))+ .unwrap_or_else(|| host.document_handle());+ let parent_viewport = host+ .child_browsing_context_host_for_document_handle(parent_document).filter(|parent_frame| *parent_frame != frame_handle).and_then(|parent_frame| iframe_handle_viewport_with_depth(host, parent_frame, depth + 1));let parent_viewport = parent_viewport.unwrap_or_else(|| host.style_viewport());@@ -701,50 +713,52 @@ fn iframe_handle_viewport_with_depth(.with_screen_size(parent_viewport.screen_width, parent_viewport.screen_height),);}- let computed_width = style_property_value_with_context(- host,- frame_handle,- StyleMode::Computed,- "width",- StyleComputationContext::new(parent_viewport),- );- let width = css_px_value(&computed_width)- .or_else(|| {- parent_viewport- .width- .zip(css_percent_value(&computed_width))- .map(|(parent_width, percent)| parent_width * percent / 100.0)- })- .or_else(|| {- host.dom_host()- .get_attribute(frame_handle, "width")- .and_then(|value| iframe_width_attribute_viewport_width(&value))- });- let computed_height = style_property_value_with_context(- host,- frame_handle,- StyleMode::Computed,- "height",- StyleComputationContext::new(parent_viewport),- );- let height = css_px_value(&computed_height)- .or_else(|| {- parent_viewport- .height- .zip(css_percent_value(&computed_height))- .map(|(parent_height, percent)| parent_height * percent / 100.0)- })- .or_else(|| {- host.dom_host()- .get_attribute(frame_handle, "height")- .and_then(|value| iframe_dimension_attribute_viewport_size(&value))- })- .or(Some(- moli_browser_profile::DEFAULT_WINDOW_SURFACE_PROFILE.inner_height,- ));Some(- StyleViewport::new(width, height)- .with_screen_size(parent_viewport.screen_width, parent_viewport.screen_height),+ host.inferred_frame_style_viewport(frame_handle, parent_document, parent_viewport, || {+ let computed_width = style_property_value_with_context(+ host,+ frame_handle,+ StyleMode::Computed,+ "width",+ StyleComputationContext::new(parent_viewport),+ );+ let width = css_px_value(&computed_width)+ .or_else(|| {+ parent_viewport+ .width+ .zip(css_percent_value(&computed_width))+ .map(|(parent_width, percent)| parent_width * percent / 100.0)+ })+ .or_else(|| {+ host.dom_host()+ .get_attribute(frame_handle, "width")+ .and_then(|value| iframe_width_attribute_viewport_width(&value))+ });+ let computed_height = style_property_value_with_context(+ host,+ frame_handle,+ StyleMode::Computed,+ "height",+ StyleComputationContext::new(parent_viewport),+ );+ let height = css_px_value(&computed_height)+ .or_else(|| {+ parent_viewport+ .height+ .zip(css_percent_value(&computed_height))+ .map(|(parent_height, percent)| parent_height * percent / 100.0)+ })+ .or_else(|| {+ host.dom_host()+ .get_attribute(frame_handle, "height")+ .and_then(|value| iframe_dimension_attribute_viewport_size(&value))+ })+ .or(Some(+ moli_browser_profile::DEFAULT_WINDOW_SURFACE_PROFILE.inner_height,+ ));+ StyleViewport::new(width, height)+ .with_screen_size(parent_viewport.screen_width, parent_viewport.screen_height)+ }),)}diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation.rsindex ac750e6d5..913c4a7bd 100644--- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation.rs+++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/observation.rs@@ -9,6 +9,7 @@ use crate::{};use super::super::super::super::JsContextHost;+use super::super::style_viewport_for_document;use super::style_world::{StyleObservationKey, prepare_style_world_update, stylesheet_query_fallback,stylesheet_source_document_for_handle,@@ -71,7 +72,10 @@ struct ComputedStyleReadInvariant {/// query needs it, then shared by every read in this observation.pub(crate) struct StyleObservation<'a> {runtime: &'a JsContextHost,- context: StyleComputationContext,+ /// `None` resolves one stable context per touched Document. Layout and+ /// detached CSSOM snapshots use `Some` to pin an exact caller-owned+ /// viewport instead.+ fixed_context: Option<StyleComputationContext>,drained_document: Option<DomHandle>,additional_drained_documents: Vec<DomHandle>,primary_document: Option<Rc<StyleObservationInputs<'a>>>,@@ -111,6 +115,10 @@ impl<'a> StyleObservationInputs<'a> {self.key.tree_scope_versions()}+ fn context(&self) -> StyleComputationContext {+ self.context+ }+fn prepared_update(&self, plan: &StyleWorldUpdatePlan) -> Rc<PreparedStyleWorldUpdate> {if let Some(update) = self.prepared_update.borrow().as_ref() {return Rc::clone(update);@@ -166,10 +174,7 @@ impl RetainedStyleObservation for StyleObservationInputs<'_> {impl<'a> StyleObservation<'a> {pub(crate) fn new(runtime: &'a JsContextHost) -> Self {- Self::new_with_context(- runtime,- StyleComputationContext::new(runtime.style_viewport()),- )+ Self::new_with_fixed_context(runtime, None)}/// Creates one synchronous style-observation scope for an exact document@@ -194,10 +199,17 @@ impl<'a> StyleObservation<'a> {pub(super) fn new_with_context(runtime: &'a JsContextHost,context: StyleComputationContext,+ ) -> Self {+ Self::new_with_fixed_context(runtime, Some(context))+ }++ fn new_with_fixed_context(+ runtime: &'a JsContextHost,+ fixed_context: Option<StyleComputationContext>,) -> Self {Self {runtime,- context,+ fixed_context,drained_document: None,additional_drained_documents: Vec::new(),primary_document: None,@@ -212,7 +224,10 @@ impl<'a> StyleObservation<'a> {}pub(crate) fn read(&mut self, handle: DomHandle) -> ComputedStyleRead<'a> {- let read_document = self.context.resolved_read_document(self.runtime, handle);+ let read_document = self+ .fixed_context+ .unwrap_or_default()+ .resolved_read_document(self.runtime, handle);if self.drained_document != Some(read_document)&& !self.additional_drained_documents.contains(&read_document){@@ -228,13 +243,14 @@ impl<'a> StyleObservation<'a> {}let source_document = stylesheet_source_document_for_handle(self.runtime, handle);- let observation_inputs = self.observation_inputs(source_document);+ let observation_inputs = self.observation_inputs(source_document, read_document);+ let context = observation_inputs.context();let stylo_style = match self.runtime.computed_style_snapshot_from_current_observation(handle,read_document,- self.context.viewport,+ context.viewport,observation_inputs.tree_scope_versions(),) {StyleObservationSnapshot::Current(style) => style,@@ -252,7 +268,7 @@ impl<'a> StyleObservation<'a> {ComputedStyleRead {runtime: self.runtime,handle,- context: self.context,+ context,observation_inputs,stylo_style,}@@ -261,6 +277,7 @@ impl<'a> StyleObservation<'a> {fn observation_inputs(&mut self,source_document: Option<DomHandle>,+ read_document: DomHandle,) -> Rc<StyleObservationInputs<'a>> {if let Some(observation) = self.primary_document.as_ref()&& observation.source_document() == source_document@@ -275,10 +292,13 @@ impl<'a> StyleObservation<'a> {return Rc::clone(observation);}+ let context = self.fixed_context.unwrap_or_else(|| {+ StyleComputationContext::new(style_viewport_for_document(self.runtime, read_document))+ });let observation = Rc::new(StyleObservationInputs::new(self.runtime,source_document,- self.context,+ context,));if self.primary_document.is_none() {self.primary_document = Some(Rc::clone(&observation));diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/style_world.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/style_world.rsindex 1cdbd201e..d74dbf2fa 100644--- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/style_world.rs+++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/style_world.rs@@ -96,12 +96,7 @@ pub(super) fn prepare_style_world_update() -> Rc<PreparedStyleWorldUpdate> {let media = StyloStyleEnvironment::from_emulated_media(runtime.emulated_media());let quirks_mode = quirks_mode(runtime, key.source_document());- let document_url = key- .source_document()- .map(|document| runtime.document_url_for_handle(document))- .unwrap_or_else(|| runtime.document_url().clone());let environment = StyleWorldEnvironment::new(- document_url,context.viewport(),media,quirks_mode,diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rsindex 6928d42be..3ab635fa7 100644--- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rs+++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rs@@ -185,8 +185,7 @@ impl<'a> StyleResolutionContext<'a> {impl<'a> ComputedStyleRead<'a> {pub(crate) fn new(runtime: &'a JsContextHost, handle: DomHandle) -> Self {- let context = StyleComputationContext::new(runtime.style_viewport());- Self::new_with_context(runtime, handle, context)+ StyleObservation::new(runtime).read(handle)}pub(in crate::native_bridge::element::styles) fn new_with_context(@@ -204,6 +203,16 @@ impl<'a> ComputedStyleRead<'a> {self.property_in_prepared_scope(&property)}+ fn resolution_context(&self) -> StyleResolutionContext<'_> {+ StyleResolutionContext::observed(+ self.context,+ None,+ self.observation_inputs.as_ref(),+ self.handle,+ self.stylo_style.as_ref(),+ )+ }+pub(in crate::native_bridge::element) fn rendered_style_facts(&self,) -> Option<ComputedRenderedStyleFacts> {@@ -425,23 +434,8 @@ pub(crate) fn active_css_animation_transform_value(runtime: &JsContextHost,handle: DomHandle,) -> Option<String> {- active_css_animation_transform_value_with_context(- runtime,- handle,- StyleComputationContext::new(runtime.style_viewport()),- )-}--fn active_css_animation_transform_value_with_context(- runtime: &JsContextHost,- handle: DomHandle,- context: StyleComputationContext,-) -> Option<String> {- active_css_animation_transform_value_with_resolution(- runtime,- handle,- StyleResolutionContext::independent(context),- )+ let read = ComputedStyleRead::new(runtime, handle);+ active_css_animation_transform_value_with_resolution(runtime, handle, read.resolution_context())}fn active_css_animation_transform_value_with_resolution(@@ -486,23 +480,8 @@ fn active_css_animation_property_values_with_resolution(}fn active_css_animation_names(runtime: &JsContextHost, handle: DomHandle) -> Vec<String> {- active_css_animation_names_with_context(- runtime,- handle,- StyleComputationContext::new(runtime.style_viewport()),- )-}--fn active_css_animation_names_with_context(- runtime: &JsContextHost,- handle: DomHandle,- context: StyleComputationContext,-) -> Vec<String> {- active_css_animation_names_with_resolution(- runtime,- handle,- StyleResolutionContext::independent(context),- )+ let read = ComputedStyleRead::new(runtime, handle);+ active_css_animation_names_with_resolution(runtime, handle, read.resolution_context())}fn active_css_animation_names_with_resolution(@@ -1496,13 +1475,7 @@ pub(crate) fn style_property_value(property: &str,) -> String {if mode == StyleMode::Computed {- return style_property_value_with_context(- runtime,- handle,- mode,- property,- StyleComputationContext::new(runtime.style_viewport()),- );+ return ComputedStyleRead::new(runtime, handle).property(property);}style_property_value_with_viewport_width(runtime, handle, mode, property, None)}@@ -3017,19 +2990,12 @@ fn css_numeric_context(runtime: &JsContextHost,handle: DomHandle,) -> moli_css_parse::CssNumericContext {- css_numeric_context_with_viewport(runtime, handle, runtime.style_viewport())-}--fn css_numeric_context_with_viewport(- runtime: &JsContextHost,- handle: DomHandle,- viewport: StyleViewport,-) -> moli_css_parse::CssNumericContext {+ let read = ComputedStyleRead::new(runtime, handle);css_numeric_context_with_viewport_and_resolution(runtime,handle,- viewport,- StyleResolutionContext::independent(StyleComputationContext::new(viewport)),+ read.context.viewport(),+ read.resolution_context(),)}@@ -5013,11 +4979,8 @@ fn container_type_is_size_container(value: &str) -> bool {}fn inline_width_px(runtime: &JsContextHost, handle: DomHandle) -> Option<f64> {- inline_width_px_with_resolution(- runtime,- handle,- StyleResolutionContext::independent(StyleComputationContext::new(runtime.style_viewport())),- )+ let read = ComputedStyleRead::new(runtime, handle);+ inline_width_px_with_resolution(runtime, handle, read.resolution_context())}fn inline_width_px_with_resolution(@@ -5637,11 +5600,8 @@ fn resolve_computed_inset_length_percentage(}fn computed_position(runtime: &JsContextHost, handle: DomHandle) -> String {- computed_position_with_resolution(- runtime,- handle,- StyleResolutionContext::independent(StyleComputationContext::new(runtime.style_viewport())),- )+ let read = ComputedStyleRead::new(runtime, handle);+ computed_position_with_resolution(runtime, handle, read.resolution_context())}fn computed_position_with_resolution(@@ -5705,11 +5665,8 @@ fn physical_inset_logical_source(}fn computed_direction(runtime: &JsContextHost, handle: DomHandle) -> String {- computed_direction_with_resolution(- runtime,- handle,- StyleResolutionContext::independent(StyleComputationContext::new(runtime.style_viewport())),- )+ let read = ComputedStyleRead::new(runtime, handle);+ computed_direction_with_resolution(runtime, handle, read.resolution_context())}fn computed_direction_with_resolution(@@ -5737,13 +5694,9 @@ fn raw_stylo_computed_style_value(handle: DomHandle,property: &str,) -> String {- raw_stylo_computed_style_value_with_context(- runtime,- handle,- property,- StyleComputationContext::new(runtime.style_viewport()),- )- .unwrap_or_default()+ ComputedStyleRead::new(runtime, handle)+ .raw_primary_property(property)+ .unwrap_or_default()}fn raw_stylo_computed_style_value_with_inputs(@@ -6240,11 +6193,8 @@ fn computed_line_height_px_with_resolution(}fn computed_font_size_px(runtime: &JsContextHost, handle: DomHandle) -> Option<f64> {- computed_font_size_px_with_resolution(- runtime,- handle,- StyleResolutionContext::independent(StyleComputationContext::new(runtime.style_viewport())),- )+ let read = ComputedStyleRead::new(runtime, handle);+ computed_font_size_px_with_resolution(runtime, handle, read.resolution_context())}fn inline_font_size_px(runtime: &JsContextHost, handle: DomHandle) -> Option<f64> {diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rsindex c051f0bca..bd2f0f00e 100644--- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rs+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rs@@ -4528,6 +4528,288 @@ fn computed_style_child_document_viewport_units_use_css_iframe_size() {assert_eq!(result, "100px|100px|200px");}+#[test]+fn child_document_mixed_style_observations_do_not_churn_the_retained_world() {+ let mut vm = new_storage_test_vm("https://child-style-observation-context.test/");+ let warmup = vm+ .eval(+ r#"+(() => {+ const frame = document.createElement('iframe');+ frame.id = 'mixed-observation-frame';+ frame.style.cssText = 'width: 240px; height: 160px';+ (document.body || document.documentElement || document).appendChild(frame);++ const childWindow = frame.contentWindow;+ const childDocument = childWindow.document;+ childDocument.open();+ childDocument.write(`+ <style>#mixed-observation-target { color: rgb(0, 128, 0); }</style>+ <style media="(max-width: 300px)">+ .narrow-child-rule { display: block; }+ </style>+ <style media="(min-width: 700px)">+ .wide-child-rule { display: block; }+ </style>+ <body><div id="mixed-observation-target"+ style="font-size: 16px; transition-duration: calc(1s); text-size-adjust: calc(100%)"+ >child text</div></body>`);+ childDocument.close();++ const shadowHost = childDocument.createElement('section');+ childDocument.body.appendChild(shadowHost);+ shadowHost.attachShadow({ mode: 'open' }).innerHTML = `+ <style media="(max-width: 300px)">:host { display: block; }</style>+ <span>shadow text</span>`;++ const target = childDocument.getElementById('mixed-observation-target');+ globalThis.__mixedStyleObservation = { childWindow, target };+ return [+ target.checkVisibility(),+ target.innerText,+ childWindow.getComputedStyle(target).color+ ].join('|');+})()+"#,+ )+ .expect("mixed child-document style observation fixture should initialize");+ assert_eq!(warmup, "true|child text|rgb(0, 128, 0)");++ let child_document = child_document_handle_for_frame_id(&vm, "mixed-observation-frame");+ let child_updates = vm.retained_style_system_update_count_for_document_for_test(child_document);+ let child_stylist = vm.retained_stylist_identity_for_document_for_test(child_document);+ let materializations = vm+ ._context_host+ .borrow()+ .style_world_update_materializations_for_test();+ let dom_version = vm._context_host.borrow().dom_host().dom_version();+ let (_, viewport_cache_misses, viewport_cache_entries) = vm+ ._context_host+ .borrow()+ .inferred_frame_style_viewport_cache_observability();++ let visibility_result = vm+ .eval(+ r#"+(() => {+ const { target } = __mixedStyleObservation;+ let visible = 0;+ for (let index = 0; index < 12; index += 1) {+ visible += target.checkVisibility() ? 1 : 0;+ }+ return String(visible);+})()+"#,+ )+ .expect("repeated child checkVisibility observations should remain stable");+ assert_eq!(visibility_result, "12");+ assert_eq!(+ vm.retained_style_system_update_count_for_document_for_test(child_document),+ child_updates,+ "child checkVisibility must use the child style environment",+ );++ let inner_text_result = vm+ .eval(+ r#"+(() => {+ const { target } = __mixedStyleObservation;+ let length = 0;+ for (let index = 0; index < 12; index += 1) {+ length += target.innerText.length;+ }+ return String(length);+})()+"#,+ )+ .expect("repeated child innerText observations should remain stable");+ assert_eq!(inner_text_result, "120");+ assert_eq!(+ vm.retained_style_system_update_count_for_document_for_test(child_document),+ child_updates,+ "child innerText must use the child style environment",+ );++ let computed_result = vm+ .eval(+ r#"+(() => {+ const { childWindow, target } = __mixedStyleObservation;+ let length = 0;+ for (let index = 0; index < 12; index += 1) {+ length += childWindow.getComputedStyle(target).color.length;+ }+ return String(length);+})()+"#,+ )+ .expect("repeated child computed-style observations should remain stable");+ assert_eq!(computed_result, "168");+ assert_eq!(+ vm.retained_style_system_update_count_for_document_for_test(child_document),+ child_updates,+ "child getComputedStyle must retain the child style environment",+ );++ let mixed_result = vm+ .eval(+ r#"+(() => {+ const { childWindow, target } = __mixedStyleObservation;+ let checksum = 0;+ for (let index = 0; index < 12; index += 1) {+ checksum += target.checkVisibility() ? 1 : 0;+ checksum += target.innerText.length;+ checksum += childWindow.getComputedStyle(target).color.length;+ }+ return String(checksum);+})()+"#,+ )+ .expect("mixed child-document style observations should remain stable");+ assert_eq!(mixed_result, "300");+ assert_eq!(+ vm.retained_style_system_update_count_for_document_for_test(child_document),+ child_updates,+ "alternating child DOM APIs must not change the retained child style environment",+ );+ assert_eq!(+ vm.retained_stylist_identity_for_document_for_test(child_document),+ child_stylist,+ "alternating child DOM APIs must retain the same child Stylist",+ );+ assert_eq!(+ vm._context_host+ .borrow()+ .style_world_update_materializations_for_test(),+ materializations,+ "alternating child DOM APIs must not materialize clean style-world updates",+ );+ assert_eq!(+ vm._context_host.borrow().dom_host().dom_version(),+ dom_version,+ "installing an existing child document wrapper must not report a DOM mutation",+ );+ let (_, final_viewport_cache_misses, final_viewport_cache_entries) = vm+ ._context_host+ .borrow()+ .inferred_frame_style_viewport_cache_observability();+ assert_eq!(+ final_viewport_cache_misses, viewport_cache_misses,+ "clean child style observations must reuse the inferred iframe viewport",+ );+ assert_eq!(final_viewport_cache_entries, viewport_cache_entries);+}++#[test]+fn nested_child_mixed_style_observations_keep_each_document_viewport() {+ let mut vm = new_storage_test_vm("https://nested-style-observation-context.test/");+ let warmup = vm+ .eval(+ r#"+(() => {+ const outerFrame = document.createElement('iframe');+ outerFrame.id = 'mixed-observation-outer-frame';+ outerFrame.style.cssText = 'width: 500px; height: 300px';+ (document.body || document.documentElement || document).appendChild(outerFrame);++ const outerWindow = outerFrame.contentWindow;+ const outerDocument = outerWindow.document;+ outerDocument.open();+ outerDocument.write(`+ <style media="(width: 500px)">body { color: rgb(1, 2, 3); }</style>+ <body><iframe id="mixed-observation-inner-frame"+ style="width: 180px; height: 90px"></iframe></body>`);+ outerDocument.close();++ const innerFrame = outerDocument.getElementById('mixed-observation-inner-frame');+ const innerWindow = innerFrame.contentWindow;+ const innerDocument = innerWindow.document;+ innerDocument.open();+ innerDocument.write(`+ <style>#mixed-observation-nested-target { color: rgb(0, 128, 0); }</style>+ <style media="(max-width: 200px)">+ .narrow-nested-rule { display: block; }+ </style>+ <style media="(min-width: 700px)">+ .wide-nested-rule { display: block; }+ </style>+ <body><div id="mixed-observation-nested-target">nested text</div></body>`);+ innerDocument.close();++ const target = innerDocument.getElementById('mixed-observation-nested-target');+ target.checkVisibility();+ outerWindow.getComputedStyle(innerFrame).display;+ const color = innerWindow.getComputedStyle(target).color;+ globalThis.__nestedMixedStyleObservation = { innerWindow, target };+ return color;+})()+"#,+ )+ .expect("nested mixed style observation fixture should initialize");+ assert_eq!(warmup, "rgb(0, 128, 0)");++ let documents = [+ vm.document_handle_for_test(),+ child_document_handle_for_frame_id(&vm, "mixed-observation-outer-frame"),+ child_document_handle_for_frame_id(&vm, "mixed-observation-inner-frame"),+ ];+ let updates = documents+ .map(|document| vm.retained_style_system_update_count_for_document_for_test(document));+ let stylists =+ documents.map(|document| vm.retained_stylist_identity_for_document_for_test(document));+ let dom_version = vm._context_host.borrow().dom_host().dom_version();+ let (_, viewport_cache_misses, viewport_cache_entries) = vm+ ._context_host+ .borrow()+ .inferred_frame_style_viewport_cache_observability();++ let result = vm+ .eval(+ r#"+(() => {+ const { innerWindow, target } = __nestedMixedStyleObservation;+ let checksum = 0;+ for (let index = 0; index < 12; index += 1) {+ checksum += target.checkVisibility() ? 1 : 0;+ checksum += target.innerText.length;+ checksum += innerWindow.getComputedStyle(target).color.length;+ }+ return String(checksum);+})()+"#,+ )+ .expect("nested mixed style observations should remain stable");+ assert_eq!(result, "312");++ for (index, document) in documents.into_iter().enumerate() {+ assert_eq!(+ vm.retained_style_system_update_count_for_document_for_test(document),+ updates[index],+ "mixed nested DOM APIs must not update retained style document {index}",+ );+ assert_eq!(+ vm.retained_stylist_identity_for_document_for_test(document),+ stylists[index],+ "mixed nested DOM APIs must retain Stylist identity for document {index}",+ );+ }+ assert_eq!(+ vm._context_host.borrow().dom_host().dom_version(),+ dom_version,+ "nested child document wrappers must remain connected without repeated mutations",+ );+ let (_, final_viewport_cache_misses, final_viewport_cache_entries) = vm+ ._context_host+ .borrow()+ .inferred_frame_style_viewport_cache_observability();+ assert_eq!(+ final_viewport_cache_misses, viewport_cache_misses,+ "clean nested style observations must reuse every inferred iframe viewport",+ );+ assert_eq!(final_viewport_cache_entries, viewport_cache_entries);+}+#[test]fn child_window_and_mock_root_geometry_use_iframe_viewport() {let mut vm = new_storage_test_vm("https://child-window-viewport.test/");diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom.rsindex 261f12ad0..6e5c20d4f 100644--- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom.rs+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/dom.rs@@ -8138,13 +8138,16 @@ fn inner_text_updates_device_in_place_without_full_style_world_snapshots() {}#[test]-fn inner_text_replaces_style_world_after_document_url_change() {+fn same_document_history_url_mutations_preserve_style_world() {let mut vm = new_parsed_test_vm("https://inner-text-document-url-style-world.test/start/index.html",- r#"<!doctype html><html><head>- <base href="https://cdn.test/stable-base/">- <style>#target { text-transform: uppercase; }</style>- </head><body><div id="target">mixed</div></body></html>"#,+ r#"<!doctype html><html><head><style>+ #target { text-transform: uppercase; background-image: url(asset.png); }+ #hash-target:target { text-transform: lowercase; }+ </style></head><body>+ <div id="target">mixed</div>+ <div id="hash-target">HASH</div>+ </body></html>"#,);assert_eq!(@@ -8152,6 +8155,15 @@ fn inner_text_replaces_style_world_after_document_url_change() {.expect("initial innerText read should evaluate"),"MIXED");+ assert_eq!(+ vm.eval("getComputedStyle(document.getElementById('target')).backgroundImage")+ .expect("initial stylesheet URL should evaluate"),+ r#"url("https://inner-text-document-url-style-world.test/start/asset.png")"#+ );+ let document = vm.document_handle_for_test();+ let stylist_identity = vm.retained_stylist_identity_for_document_for_test(document);+ let rebuilds = vm.retained_style_system_rebuild_count_for_document_for_test(document);+ let updates = vm.retained_style_system_update_count_for_document_for_test(document);let update_materializations_after_initial = vm._context_host.borrow()@@ -8168,47 +8180,92 @@ fn inner_text_replaces_style_world_after_document_url_change() {.expect("innerText after same-document URL mutation should evaluate"),"MIXED");- let update_materializations_after_url_change = vm- ._context_host- .borrow()- .style_world_update_materializations_for_test();- let full_snapshots_after_url_change = vm- ._context_host- .borrow()- .style_world_full_snapshots_for_test();-assert_eq!(- vm.eval("document.getElementById('target').innerText")- .expect("repeated innerText after URL mutation should evaluate"),+ vm.eval("document.baseURI")+ .expect("base URI after pushState should evaluate"),+ "https://inner-text-document-url-style-world.test/next/path"+ );+ assert_eq!(+ vm.eval("getComputedStyle(document.getElementById('target')).backgroundImage")+ .expect("existing stylesheet URL after pushState should evaluate"),+ r#"url("https://inner-text-document-url-style-world.test/start/asset.png")"#,+ "an existing inline stylesheet keeps its processing-time base URL"+ );+ assert_eq!(+ vm.eval(+ r#"(() => {+ const dynamic = document.createElement('div');+ dynamic.style.backgroundImage = 'url(new.png)';+ document.body.appendChild(dynamic);+ return getComputedStyle(dynamic).backgroundImage;+ })()"#+ )+ .expect("new inline declaration after pushState should evaluate"),+ r#"url("https://inner-text-document-url-style-world.test/next/new.png")"#,+ "new style declarations must observe the updated Document base URL"+ );+ assert_eq!(+ vm.eval(+ "history.replaceState(null, '', '?view=compact'); document.getElementById('target').innerText"+ )+ .expect("innerText after same-document query mutation should evaluate"),"MIXED");- let update_materializations_after_repeated = vm- ._context_host- .borrow()- .style_world_update_materializations_for_test();- let full_snapshots_after_repeated = vm- ._context_host- .borrow()- .style_world_full_snapshots_for_test();+ assert_eq!(+ vm.eval("document.baseURI")+ .expect("base URI after replaceState should evaluate"),+ "https://inner-text-document-url-style-world.test/next/path?view=compact"+ );+ assert_eq!(+ vm.eval(+ r#"(() => {+ const target = document.getElementById('target');+ for (let index = 0; index < 64; index += 1) {+ history.replaceState(null, '', `?view=${index}`);+ void target.innerText;+ }+ return target.innerText;+ })()"#+ )+ .expect("repeated history URL and layout observations should evaluate"),+ "MIXED"+ );+ assert_eq!(+ vm.eval(+ "history.replaceState(null, '', '#hash-target'); document.getElementById('hash-target').innerText"+ )+ .expect(":target style after same-document fragment mutation should evaluate"),+ "hash"+ );assert_eq!(- update_materializations_after_url_change- .saturating_sub(update_materializations_after_initial),- 1+ vm.retained_stylist_identity_for_document_for_test(document),+ stylist_identity,+ "same-Document history mutations must retain the Stylist");assert_eq!(- full_snapshots_after_url_change.saturating_sub(full_snapshots_after_initial),- 1,- "a path-changing history mutation is an explicit style-world replacement boundary"+ vm.retained_style_system_rebuild_count_for_document_for_test(document),+ rebuilds,+ "same-Document history mutations must not rebuild the style world");assert_eq!(- update_materializations_after_repeated- .saturating_sub(update_materializations_after_url_change),- 0+ vm.retained_style_system_update_count_for_document_for_test(document),+ updates,+ "path, query, and fragment changes need no retained style-world update");assert_eq!(- full_snapshots_after_repeated.saturating_sub(full_snapshots_after_url_change),- 0+ vm._context_host+ .borrow()+ .style_world_update_materializations_for_test(),+ update_materializations_after_initial,+ "history URL mutations must not materialize stylesheet inputs"+ );+ assert_eq!(+ vm._context_host+ .borrow()+ .style_world_full_snapshots_for_test(),+ full_snapshots_after_initial,+ "history URL mutations must not materialize a full style snapshot");}diff --git a/moli-renderer-v8/src/style_engine/computed.rs b/moli-renderer-v8/src/style_engine/computed.rsindex 227946812..2b61d368f 100644--- a/moli-renderer-v8/src/style_engine/computed.rs+++ b/moli-renderer-v8/src/style_engine/computed.rs@@ -309,7 +309,6 @@ pub(super) fn computed_style_property_value(None => None,};let style_system_key = StyleWorldKey::new_for_observation(- document_url,inputs,viewport,super::StyleTreeScopeVersions::current(host, Some(owner_document)),@@ -383,7 +382,6 @@ pub(super) fn computed_style_snapshot_after_style_update() -> Option<StyloComputedStyleSnapshot> {let owner_document = owner_document_for_computed_style_read(host, handle)?;let style_system_key = StyleWorldKey::new_for_observation(- document_url,inputs,viewport,super::StyleTreeScopeVersions::current(host, Some(owner_document)),@@ -428,14 +426,10 @@ pub(super) fn computed_style_snapshot_from_current_observation(.and_then(Node::as_document).map(|document| document.quirks_mode()).unwrap_or(QuirksMode::NoQuirks);- let style_document_url = host- .document_url_for_handle(owner_document)- .unwrap_or(document_url);let world = engine.world_for_document(owner_document);if !world.document_state.retained_style_system_is_current_for_observation(- style_document_url,viewport,environment,quirks_mode,@@ -446,7 +440,6 @@ pub(super) fn computed_style_snapshot_from_current_observation(host,&world.document_state,owner_document,- style_document_url,viewport,environment,quirks_mode,@@ -482,7 +475,6 @@ pub(super) fn computed_style_snapshot_after_world_update(StyleWorldUpdate::Full(inputs) => {let environment = update.environment();let style_system_key = StyleWorldKey::new_for_observation(- &environment.document_url,inputs,environment.viewport,environment.tree_scope_versions,diff --git a/moli-renderer-v8/src/style_engine/retained.rs b/moli-renderer-v8/src/style_engine/retained.rsindex ca68a3e8c..d0446fb50 100644--- a/moli-renderer-v8/src/style_engine/retained.rs+++ b/moli-renderer-v8/src/style_engine/retained.rs@@ -22,7 +22,8 @@ use super::{state::RetainedStyleSystem,stylesheet::{append_stylesheet_to_stylist, install_active_stylesheet, install_active_stylesheets,- new_style_device_with_viewport_bits, new_stylist_with_viewport_bits,+ moli_ua_stylesheet_base_url, new_style_device_with_viewport_bits,+ new_stylist_with_viewport_bits,},stylesheet_resources::StylesheetResourceManifest,ua::HTML_STYLESHEET as MOLI_UA_STYLESHEET,@@ -97,7 +98,7 @@ pub(super) fn build_retained_style_system(&mut stylist,shared_lock,MOLI_UA_STYLESHEET,- &key.document_url,+ moli_ua_stylesheet_base_url(),Origin::UserAgent,key.quirks_mode,);diff --git a/moli-renderer-v8/src/style_engine/state.rs b/moli-renderer-v8/src/style_engine/state.rsindex 34231e9a0..70be1b607 100644--- a/moli-renderer-v8/src/style_engine/state.rs+++ b/moli-renderer-v8/src/style_engine/state.rs@@ -194,7 +194,6 @@ impl StyleDocumentState {pub(super) fn retained_style_system_is_current_for_observation(&self,- document_url: &url::Url,viewport: StyleViewport,environment: StyloStyleEnvironment,quirks_mode: style::context::QuirksMode,@@ -211,7 +210,6 @@ impl StyleDocumentState {.as_ref().is_some_and(|retained| {retained.key.matches_observation_environment(- document_url,viewport,environment,quirks_mode,diff --git a/moli-renderer-v8/src/style_engine/stylesheet.rs b/moli-renderer-v8/src/style_engine/stylesheet.rsindex 340ea9f81..2bc535e7b 100644--- a/moli-renderer-v8/src/style_engine/stylesheet.rs+++ b/moli-renderer-v8/src/style_engine/stylesheet.rs@@ -42,10 +42,13 @@ use super::{world_key::{DEFAULT_VIEWPORT_HEIGHT, DEFAULT_VIEWPORT_WIDTH},};+static MOLI_UA_STYLESHEET_BASE_URL: LazyLock<url::Url> =+ LazyLock::new(|| url::Url::parse("about:blank").expect("valid built-in stylesheet base URL"));+static MOLI_UA_SOURCE_METADATA: LazyLock<StyleSourceMetadata> = LazyLock::new(|| {style_source_metadata_for_css_text_with_origin(MOLI_UA_STYLESHEET,- &url::Url::parse("about:blank").expect("valid built-in stylesheet base URL"),+ moli_ua_stylesheet_base_url(),Origin::UserAgent,)});@@ -70,6 +73,10 @@ pub(crate) fn author_source_text_parse_count_for_test() -> usize {AUTHOR_SOURCE_TEXT_PARSE_COUNT.with(std::cell::Cell::get)}+pub(super) fn moli_ua_stylesheet_base_url() -> &'static url::Url {+ &MOLI_UA_STYLESHEET_BASE_URL+}+#[derive(Debug)]struct HeadlessFontMetricsProvider;diff --git a/moli-renderer-v8/src/style_engine/tests/dependency.rs b/moli-renderer-v8/src/style_engine/tests/dependency.rsindex 0450df364..272ac4302 100644--- a/moli-renderer-v8/src/style_engine/tests/dependency.rs+++ b/moli-renderer-v8/src/style_engine/tests/dependency.rs@@ -289,9 +289,8 @@ fn missing_retained_cascade_data_reaches_cleanup_application_table() {let mut engine = MoliStyleEngine::new();let root = host.document_handle();engine.set_document_adopted_style_sheet_sources(root, Vec::new());- let document_url = url::Url::parse("https://example.test/").unwrap();let inputs = FullStyleWorldSnapshot::default();- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, root, key, &inputs);let source_id = StyleSourceId::document_adopted_style_sheet(root, 0);@@ -1443,7 +1442,7 @@ fn source_dependency_request_translation_preserves_context_fallback_kind_with_reengine.set_document_adopted_style_sheet_sources(document, vec![source.clone()]);let mut inputs = FullStyleWorldSnapshot::default();inputs.document_stylesheet_sources.push(source);- let key = StyleWorldKey::new(&base_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, document, key, &inputs);let application = engine@@ -2444,9 +2443,8 @@ fn retained_style_system_cache_hit_preserves_computed_and_retained_generations()let engine = MoliStyleEngine::new();let host = test_host();let document = host.document_handle();- let document_url = url::Url::parse("https://example.test/").unwrap();let inputs = FullStyleWorldSnapshot::default();- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host,@@ -2495,8 +2493,8 @@ fn viewport_change_updates_the_persistent_style_world_in_place() {};let initial_viewport = StyleViewport::from_width(Some(800.0));let next_viewport = StyleViewport::from_width(Some(640.0));- let initial_key = StyleWorldKey::new(&document_url, &inputs, initial_viewport);- let viewport_key = StyleWorldKey::new(&document_url, &inputs, next_viewport);+ let initial_key = StyleWorldKey::new(&inputs, initial_viewport);+ let viewport_key = StyleWorldKey::new(&inputs, next_viewport);let mismatch = initial_key.mismatch_trace(&viewport_key);assert!(mismatch.viewport_changed);@@ -2855,7 +2853,7 @@ fn cache_key_source_matching_skips_inactive_owner_sources() {engine.ensure_retained_style_system_for_document(&host,host.document_handle(),- StyleWorldKey::new(&document_url, &inputs, None),+ StyleWorldKey::new(&inputs, None),&inputs,);engine.with_retained_style_system_for_document_for_test(host.document_handle(), |retained| {diff --git a/moli-renderer-v8/src/style_engine/tests/invalidator.rs b/moli-renderer-v8/src/style_engine/tests/invalidator.rsindex 35cba75e4..1274a1ea6 100644--- a/moli-renderer-v8/src/style_engine/tests/invalidator.rs+++ b/moli-renderer-v8/src/style_engine/tests/invalidator.rs@@ -120,9 +120,8 @@ fn retained_system_mutations_without_computed_cache_still_queue_work() {style,"section:has(span) { color: red; }".into(),);- let document_url = host.document_url().expect("test document url").clone();let inputs = FullStyleWorldSnapshot::default();- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, host.document_handle(), key, &inputs);assert_eq!(engine.computed_style_cache_entry_count_for_document_for_test(document),@@ -552,7 +551,7 @@ fn stylo_tree_invalidator_wrapper_collects_sibling_roots() {document, 0,))),);- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, host.document_handle(), key, &inputs);let (roots, requires_fallback) = collect_source_invalidation_roots_for_test(@@ -592,7 +591,7 @@ fn stylo_tree_invalidator_wrapper_handles_normal_dependency_chains() {document, 0,))),);- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, host.document_handle(), key, &inputs);let (roots, requires_fallback) = collect_source_invalidation_roots_for_test(@@ -635,7 +634,7 @@ fn stylo_tree_invalidator_wrapper_handles_scope_dependency_chains() {document, 0,))),);- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, host.document_handle(), key, &inputs);let (roots, requires_fallback) = collect_source_invalidation_roots_for_test(@@ -675,7 +674,7 @@ fn stylo_tree_invalidator_wrapper_accepts_empty_scope_dependency_result() {document, 0,))),);- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, host.document_handle(), key, &inputs);let (roots, requires_fallback) = collect_source_invalidation_roots_for_test(diff --git a/moli-renderer-v8/src/style_engine/tests/lifecycle.rs b/moli-renderer-v8/src/style_engine/tests/lifecycle.rsindex f4f330c8d..b81bbdbee 100644--- a/moli-renderer-v8/src/style_engine/tests/lifecycle.rs+++ b/moli-renderer-v8/src/style_engine/tests/lifecycle.rs@@ -481,7 +481,6 @@ fn retained_sources_are_scoped_to_document_worlds() {let mut host = test_host();let document = host.document_handle();let mut engine = MoliStyleEngine::new();- let document_url = host.document_url().expect("test document url").clone();let disconnected_style = host.create_element("style");engine.set_owner_style_sheet_text_with_host(@@ -509,7 +508,7 @@ fn retained_sources_are_scoped_to_document_worlds() {engine.ensure_retained_style_system_for_document(&host,host.document_handle(),- StyleWorldKey::new(&document_url, &inputs, None),+ StyleWorldKey::new(&inputs, None),&inputs,);engine.with_retained_style_system_for_document_for_test(host.document_handle(), |retained| {@@ -546,7 +545,7 @@ fn retained_sources_are_scoped_to_document_worlds() {engine.ensure_retained_style_system_for_document(&host,host.document_handle(),- StyleWorldKey::new(&document_url, &inputs, None),+ StyleWorldKey::new(&inputs, None),&inputs,);engine.with_retained_style_system_for_document_for_test(host.document_handle(), |retained| {@@ -559,7 +558,7 @@ fn retained_sources_are_scoped_to_document_worlds() {engine.ensure_retained_style_system_for_document(&host,detached_document,- StyleWorldKey::new(&document_url, &inputs, None),+ StyleWorldKey::new(&inputs, None),&inputs,);engine.with_retained_style_system_for_document_for_test(detached_document, |retained| {@@ -2180,7 +2179,6 @@ fn missing_document_adopted_sources_remain_trackable_without_retained_source() {let host = test_host();let mut engine = MoliStyleEngine::new();let missing_document = NativeNodeId::new(90_001);- let document_url = host.document_url().expect("test document url").clone();let source_url = url::Url::parse("https://example.test/missing-document.css").unwrap();let source_id = StyleSourceId::document_adopted_style_sheet(missing_document, 0);@@ -2217,7 +2215,7 @@ fn missing_document_adopted_sources_remain_trackable_without_retained_source() {engine.ensure_retained_style_system_for_document(&host,host.document_handle(),- StyleWorldKey::new(&document_url, &inputs, None),+ StyleWorldKey::new(&inputs, None),&inputs,);engine.with_retained_style_system_for_document_for_test(host.document_handle(), |retained| {diff --git a/moli-renderer-v8/src/style_engine/tests/outcome.rs b/moli-renderer-v8/src/style_engine/tests/outcome.rsindex 6a2a6bbac..f920d9676 100644--- a/moli-renderer-v8/src/style_engine/tests/outcome.rs+++ b/moli-renderer-v8/src/style_engine/tests/outcome.rs@@ -763,7 +763,7 @@ fn mixed_cleanup_clears_shadow_cascade_data_only_for_source_fallback_roots() {document_url.clone(),)],));- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, document, key, &inputs);let (exact_cascade_data, fallback_cascade_data, structural_cascade_data) = engine@@ -1761,7 +1761,7 @@ fn subtree_fallback_cleanup_clears_only_affected_shadow_cascade_data() {inputs.shadow_stylesheet_sources.push((second_shadow_root, vec![second_source]));- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, document, key, &inputs);let (first_cascade_data, second_cascade_data) = enginediff --git a/moli-renderer-v8/src/style_engine/tests/subtree_cache.rs b/moli-renderer-v8/src/style_engine/tests/subtree_cache.rsindex 0c685aa4f..a2159d2e9 100644--- a/moli-renderer-v8/src/style_engine/tests/subtree_cache.rs+++ b/moli-renderer-v8/src/style_engine/tests/subtree_cache.rs@@ -1436,14 +1436,14 @@ fn document_source_update_preserves_shadow_scope_cascade_data() {active_inputs.shadow_stylesheet_sources.push((active_shadow_root, vec![active_shadow_source]));- let active_key = StyleWorldKey::new(&document_url, &active_inputs, None);+ let active_key = StyleWorldKey::new(&active_inputs, None);engine.ensure_retained_style_system_for_document(&host, document, active_key, &active_inputs);let mut detached_inputs = FullStyleWorldSnapshot::default();detached_inputs.shadow_stylesheet_sources.push((detached_shadow_root, vec![detached_shadow_source]));- let detached_key = StyleWorldKey::new(&document_url, &detached_inputs, None);+ let detached_key = StyleWorldKey::new(&detached_inputs, None);engine.ensure_retained_style_system_for_document(&host,detached_document,@@ -1513,7 +1513,7 @@ fn document_source_update_preserves_shadow_scope_cascade_data() {active_inputs.document_stylesheet_sources.push(second_document_source);- let active_key = StyleWorldKey::new(&document_url, &active_inputs, None);+ let active_key = StyleWorldKey::new(&active_inputs, None);engine.ensure_retained_style_system_for_document(&host, document, active_key, &active_inputs);let active_cascade_data_after =engine.with_retained_style_system_for_document_for_test(document, |retained| {@@ -4698,34 +4698,8 @@ fn matching_dependency_sources_have_explicit_source_and_scope_ids() {assert!(shadow_fallback_roots.contains(&shadow_host));assert!(!shadow_fallback_roots.contains(&document));}-#[test]-fn style_world_identity_ignores_document_fragment() {- let old_url = url::Url::parse("https://example.test/page.html#old").unwrap();- let new_url = url::Url::parse("https://example.test/page.html#new").unwrap();- let mut inputs = FullStyleWorldSnapshot::default();- inputs- .document_stylesheet_sources- .push(StyloStylesheetSource::new(- ".probe { color: green; }".to_owned(),- old_url.clone(),- ));- let mut next_inputs = FullStyleWorldSnapshot::default();- next_inputs- .document_stylesheet_sources- .push(StyloStylesheetSource::new(- ".probe { color: green; }".to_owned(),- new_url.clone(),- ));-- assert_eq!(- StyleWorldKey::new(&old_url, &inputs, None),- StyleWorldKey::new(&new_url, &next_inputs, None)- );-}-#[test]fn style_world_identity_changes_when_screen_size_changes() {- let document_url = url::Url::parse("https://example.test/page.html").unwrap();let inputs = FullStyleWorldSnapshot::default();let viewport =StyleViewport::new(Some(800.0), Some(600.0)).with_screen_size(Some(1920.0), Some(1080.0));@@ -4733,8 +4707,8 @@ fn style_world_identity_changes_when_screen_size_changes() {StyleViewport::new(Some(800.0), Some(600.0)).with_screen_size(Some(1366.0), Some(768.0));assert_ne!(- StyleWorldKey::new(&document_url, &inputs, viewport),- StyleWorldKey::new(&document_url, &inputs, next_viewport)+ StyleWorldKey::new(&inputs, viewport),+ StyleWorldKey::new(&inputs, next_viewport));}@@ -4757,13 +4731,12 @@ fn style_world_identity_does_not_hash_stylesheet_text() {));assert_eq!(- StyleWorldKey::new(&document_url, &inputs, None),- StyleWorldKey::new(&document_url, &next_inputs, None)+ StyleWorldKey::new(&inputs, None),+ StyleWorldKey::new(&next_inputs, None));}#[test]fn style_world_identity_does_not_hash_stylesheet_base_urls() {- let document_url = url::Url::parse("https://example.test/page.html").unwrap();let old_base = url::Url::parse("https://example.test/assets/app.css").unwrap();let next_base = url::Url::parse("https://cdn.example.test/assets/app.css").unwrap();let mut inputs = FullStyleWorldSnapshot::default();@@ -4782,13 +4755,12 @@ fn style_world_identity_does_not_hash_stylesheet_base_urls() {));assert_eq!(- StyleWorldKey::new(&document_url, &inputs, None),- StyleWorldKey::new(&document_url, &next_inputs, None)+ StyleWorldKey::new(&inputs, None),+ StyleWorldKey::new(&next_inputs, None));}#[test]fn style_world_identity_changes_when_document_quirks_mode_changes() {- let document_url = url::Url::parse("https://example.test/page.html").unwrap();let standards_inputs = FullStyleWorldSnapshot::default();let quirks_inputs = FullStyleWorldSnapshot {quirks_mode: style::context::QuirksMode::Quirks,@@ -4796,15 +4768,13 @@ fn style_world_identity_changes_when_document_quirks_mode_changes() {};assert_ne!(- StyleWorldKey::new(&document_url, &standards_inputs, None),- StyleWorldKey::new(&document_url, &quirks_inputs, None)+ StyleWorldKey::new(&standards_inputs, None),+ StyleWorldKey::new(&quirks_inputs, None));}#[test]fn style_world_identity_mismatch_trace_records_changed_dimensions() {- let previous_url = url::Url::parse("https://example.test/old.html").unwrap();- let next_url = url::Url::parse("https://example.test/new.html").unwrap();let previous_inputs = FullStyleWorldSnapshot::default();let mut next_inputs = previous_inputs.clone();@@ -4816,25 +4786,21 @@ fn style_world_identity_mismatch_trace_records_changed_dimensions() {);next_inputs.quirks_mode = style::context::QuirksMode::Quirks;let previous_key = StyleWorldKey::new(- &previous_url,&previous_inputs,StyleViewport::new(Some(800.0), Some(600.0)).with_screen_size(Some(1920.0), Some(1080.0)),);let next_key = StyleWorldKey::new(- &next_url,&next_inputs,StyleViewport::new(Some(1024.0), Some(768.0)).with_screen_size(Some(1366.0), Some(768.0)),);let trace = previous_key.mismatch_trace(&next_key);- assert!(trace.document_url_changed);- assert_eq!(trace.previous_document_url, previous_url);- assert_eq!(trace.next_document_url, next_url);assert!(trace.viewport_changed);assert!(trace.screen_changed);assert!(trace.environment_changed);assert!(trace.quirks_mode_changed);+ assert!(trace.requires_style_system_replacement());}#[test]@@ -4998,7 +4964,6 @@ fn document_stylesheet_fallback_updates_the_persistent_world_in_place() {document_url.clone(),));let first_key = StyleWorldKey::new_for_observation(- &document_url,&first_inputs,StyleViewport::default(),StyleTreeScopeVersions::current(&host, Some(document)),@@ -5085,9 +5050,8 @@ fn style_subtree_invalidation_retains_style_system() {let target = host.create_element("section");assert!(host.append_child(document, target));let mut engine = MoliStyleEngine::new();- let document_url = url::Url::parse("https://example.test/").unwrap();let inputs = FullStyleWorldSnapshot::default();- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host,@@ -5117,7 +5081,6 @@ fn retained_style_system_keeps_cascade_data_for_empty_shadow_scopes() {.expect("closed host should accept a shadow root");let engine = MoliStyleEngine::new();- let document_url = url::Url::parse("https://example.test/empty-scopes.html").unwrap();let mut inputs = FullStyleWorldSnapshot::default();inputs.shadow_stylesheet_sources@@ -5125,7 +5088,7 @@ fn retained_style_system_keeps_cascade_data_for_empty_shadow_scopes() {inputs.shadow_stylesheet_sources.push((closed_root, Vec::new()));- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, document, key, &inputs);engine.with_retained_style_system_for_document_for_test(document, |retained| {@@ -5361,7 +5324,7 @@ fn retained_stylesheet_resource_manifest_advances_only_when_resources_change() {document_stylesheet_sources: vec![first_source],..Default::default()};- let first_key = StyleWorldKey::new(&document_url, &first_inputs, None);+ let first_key = StyleWorldKey::new(&first_inputs, None);engine.ensure_retained_style_system_for_document(&host, document, first_key, &first_inputs);let first = engine@@ -5387,7 +5350,7 @@ fn retained_stylesheet_resource_manifest_advances_only_when_resources_change() {assert_eq!(stylesheet_resource_manifest_build_count_for_test(), 1);let viewport = StyleViewport::from_width(Some(640.0));- let viewport_key = StyleWorldKey::new(&document_url, &first_inputs, viewport);+ let viewport_key = StyleWorldKey::new(&first_inputs, viewport);engine.ensure_retained_style_system_for_document(&host, document, viewport_key, &first_inputs);let after_viewport_change = engine.stylesheet_resource_snapshot_for_document(document)@@ -5413,7 +5376,7 @@ fn retained_stylesheet_resource_manifest_advances_only_when_resources_change() {document_stylesheet_sources: vec![same_resources_source],..Default::default()};- let same_resources_key = StyleWorldKey::new(&document_url, &same_resources_inputs, viewport);+ let same_resources_key = StyleWorldKey::new(&same_resources_inputs, viewport);engine.ensure_retained_style_system_for_document(&host,document,@@ -5441,7 +5404,7 @@ fn retained_stylesheet_resource_manifest_advances_only_when_resources_change() {document_stylesheet_sources: vec![second_source],..Default::default()};- let second_key = StyleWorldKey::new(&document_url, &second_inputs, viewport);+ let second_key = StyleWorldKey::new(&second_inputs, viewport);engine.ensure_retained_style_system_for_document(&host, document, second_key, &second_inputs);let second = engine@@ -5688,7 +5651,7 @@ fn one_shadow_stylesheet_change_preserves_the_other_scope_cascade_data() {first_inputs.shadow_stylesheet_sources.push((second_root, vec![second_source.clone()]));- let first_key = StyleWorldKey::new(&document_url, &first_inputs, None);+ let first_key = StyleWorldKey::new(&first_inputs, None);engine.ensure_retained_style_system_for_document(&host, document, first_key, &first_inputs);let initial_data =@@ -5720,7 +5683,7 @@ fn one_shadow_stylesheet_change_preserves_the_other_scope_cascade_data() {second_inputs.shadow_stylesheet_sources.push((second_root, vec![second_source]));- let second_key = StyleWorldKey::new(&document_url, &second_inputs, None);+ let second_key = StyleWorldKey::new(&second_inputs, None);engine.ensure_retained_style_system_for_document(&host, document, second_key, &second_inputs);engine.with_retained_style_system_for_document_for_test(document, |retained| {@@ -5799,7 +5762,7 @@ fn style_subtree_invalidation_clears_only_affected_shadow_cascade_data() {inputs.shadow_stylesheet_sources.push((second_shadow_root, vec![second_source]));- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, document, key, &inputs);let (first_cascade_data, second_cascade_data) = engine@@ -5891,7 +5854,7 @@ fn detached_subtree_invalidation_clears_only_affected_shadow_cascade_data() {inputs.shadow_stylesheet_sources.push((second_shadow_root, vec![second_source]));- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, document, key, &inputs);let (first_cascade_data, second_cascade_data) = engine@@ -5990,14 +5953,14 @@ fn document_stylesheet_dirty_mark_isolated_to_its_document_world() {active_inputs.shadow_stylesheet_sources.push((active_shadow_root, vec![active_source]));- let active_key = StyleWorldKey::new(&document_url, &active_inputs, None);+ let active_key = StyleWorldKey::new(&active_inputs, None);engine.ensure_retained_style_system_for_document(&host, document, active_key, &active_inputs);let mut detached_inputs = FullStyleWorldSnapshot::default();detached_inputs.shadow_stylesheet_sources.push((detached_shadow_root, vec![detached_source]));- let detached_key = StyleWorldKey::new(&document_url, &detached_inputs, None);+ let detached_key = StyleWorldKey::new(&detached_inputs, None);engine.ensure_retained_style_system_for_document(&host,detached_document,@@ -6200,7 +6163,7 @@ fn detached_retained_rebuild_preserves_active_document_adapter_element_data() {let engine = MoliStyleEngine::new();let document_url = url::Url::parse("https://example.test/").unwrap();let inputs = FullStyleWorldSnapshot::default();- let active_key = StyleWorldKey::new(&document_url, &inputs, None);+ let active_key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, document, active_key, &inputs);ensure_adapter_element_data(&engine, &host, active);assert!(engine.dom_adapter.has_element_data(active));@@ -6213,7 +6176,7 @@ fn detached_retained_rebuild_preserves_active_document_adapter_element_data() {first_detached_inputs.document_stylesheet_sources.push(detached_source);- let first_detached_key = StyleWorldKey::new(&document_url, &first_detached_inputs, None);+ let first_detached_key = StyleWorldKey::new(&first_detached_inputs, None);engine.ensure_retained_style_system_for_document(&host,detached_document,@@ -6229,7 +6192,7 @@ fn detached_retained_rebuild_preserves_active_document_adapter_element_data() {next_detached_inputs.document_stylesheet_sources.push(next_detached_source);- let next_detached_key = StyleWorldKey::new(&document_url, &next_detached_inputs, None);+ let next_detached_key = StyleWorldKey::new(&next_detached_inputs, None);engine.ensure_retained_style_system_for_document(&host,detached_document,diff --git a/moli-renderer-v8/src/style_engine/tests/subtree_context.rs b/moli-renderer-v8/src/style_engine/tests/subtree_context.rsindex daf5fed3c..7141edc14 100644--- a/moli-renderer-v8/src/style_engine/tests/subtree_context.rs+++ b/moli-renderer-v8/src/style_engine/tests/subtree_context.rs@@ -296,9 +296,8 @@ fn pending_attribute_mutation_invalidations_merge_for_batch_drain() {style,".first { color: red; } .second { color: blue; }".into(),);- let document_url = host.document_url().expect("test document url").clone();let inputs = FullStyleWorldSnapshot::default();- let key = StyleWorldKey::new(&document_url, &inputs, None);+ let key = StyleWorldKey::new(&inputs, None);engine.ensure_retained_style_system_for_document(&host, host.document_handle(), key, &inputs);let media = crate::protocol_types::EmulatedMediaOverrides::default();diff --git a/moli-renderer-v8/src/style_engine/world_environment.rs b/moli-renderer-v8/src/style_engine/world_environment.rsindex 9b26c751f..ddbdaafd5 100644--- a/moli-renderer-v8/src/style_engine/world_environment.rs+++ b/moli-renderer-v8/src/style_engine/world_environment.rs@@ -207,7 +207,6 @@ impl StyloStyleReducedPreference {#[derive(Clone, Debug)]pub(crate) struct StyleWorldEnvironment {- pub(super) document_url: url::Url,pub(super) viewport: StyleViewport,pub(super) media: StyloStyleEnvironment,pub(super) quirks_mode: style::context::QuirksMode,@@ -216,14 +215,12 @@ pub(crate) struct StyleWorldEnvironment {impl StyleWorldEnvironment {pub(crate) fn new(- document_url: url::Url,viewport: StyleViewport,media: StyloStyleEnvironment,quirks_mode: style::context::QuirksMode,tree_scope_versions: StyleTreeScopeVersions,) -> Self {Self {- document_url,viewport,media,quirks_mode,diff --git a/moli-renderer-v8/src/style_engine/world_key.rs b/moli-renderer-v8/src/style_engine/world_key.rsindex b7934ba92..0ea3a1f8f 100644--- a/moli-renderer-v8/src/style_engine/world_key.rs+++ b/moli-renderer-v8/src/style_engine/world_key.rs@@ -8,14 +8,15 @@ use super::{pub(super) const DEFAULT_VIEWPORT_WIDTH: f32 = 1024.0;pub(super) const DEFAULT_VIEWPORT_HEIGHT: f32 = 768.0;-/// Stable identity of a retained Document style world.+/// Style-affecting state of a retained Document style world.////// Stylesheet contents intentionally do not participate. Persistent active/// collections and dirty records update those incrementally; hashing complete-/// source vectors here would reintroduce the snapshot model.+/// source vectors here would reintroduce the snapshot model. The Document URL+/// is also intentionally absent: same-Document history mutations change that+/// address without replacing the Document's style world.#[derive(Clone, Debug, PartialEq, Eq, Hash)]pub(super) struct StyleWorldKey {- pub(super) document_url: url::Url,pub(super) viewport_width_bits: u32,pub(super) viewport_height_bits: u32,pub(super) screen_width_bits: u32,@@ -27,9 +28,6 @@ pub(super) struct StyleWorldKey {#[derive(Clone, Debug, PartialEq, Eq)]pub(super) struct StyleWorldKeyMismatchTrace {- pub(super) document_url_changed: bool,- pub(super) previous_document_url: url::Url,- pub(super) next_document_url: url::Url,pub(super) viewport_changed: bool,pub(super) previous_viewport_width_bits: u32,pub(super) next_viewport_width_bits: u32,@@ -49,35 +47,26 @@ pub(super) struct StyleWorldKeyMismatchTrace {impl StyleWorldKey {#[cfg(test)]- pub(super) fn new(- document_url: &url::Url,- inputs: &FullStyleWorldSnapshot,- viewport: impl Into<StyleViewport>,- ) -> Self {- Self::build(document_url, inputs, viewport.into(), None)+ pub(super) fn new(inputs: &FullStyleWorldSnapshot, viewport: impl Into<StyleViewport>) -> Self {+ Self::build(inputs, viewport.into(), None)}pub(super) fn new_for_observation(- document_url: &url::Url,inputs: &FullStyleWorldSnapshot,viewport: StyleViewport,tree_scope_versions: StyleTreeScopeVersions,) -> Self {- Self::build(document_url, inputs, viewport, Some(tree_scope_versions))+ Self::build(inputs, viewport, Some(tree_scope_versions))}fn build(- document_url: &url::Url,inputs: &FullStyleWorldSnapshot,viewport: StyleViewport,tree_scope_versions: Option<StyleTreeScopeVersions>,) -> Self {- let mut document_url = document_url.clone();- document_url.set_fragment(None);let viewport_width_bits = style_dimension_bits(viewport.width, DEFAULT_VIEWPORT_WIDTH);let viewport_height_bits = style_dimension_bits(viewport.height, DEFAULT_VIEWPORT_HEIGHT);Self {- document_url,viewport_width_bits,viewport_height_bits,screen_width_bits: style_dimension_bits(@@ -96,13 +85,10 @@ impl StyleWorldKey {pub(super) fn updated_for_observation(&self, environment: &StyleWorldEnvironment) -> Self {let mut next = self.clone();- let mut document_url = environment.document_url.clone();- document_url.set_fragment(None);let viewport_width_bits =style_dimension_bits(environment.viewport.width, DEFAULT_VIEWPORT_WIDTH);let viewport_height_bits =style_dimension_bits(environment.viewport.height, DEFAULT_VIEWPORT_HEIGHT);- next.document_url = document_url;next.viewport_width_bits = viewport_width_bits;next.viewport_height_bits = viewport_height_bits;next.screen_width_bits = style_dimension_bits(@@ -121,9 +107,6 @@ impl StyleWorldKey {pub(super) fn mismatch_trace(&self, next: &Self) -> StyleWorldKeyMismatchTrace {StyleWorldKeyMismatchTrace {- document_url_changed: self.document_url != next.document_url,- previous_document_url: self.document_url.clone(),- next_document_url: next.document_url.clone(),viewport_changed: self.viewport_width_bits != next.viewport_width_bits|| self.viewport_height_bits != next.viewport_height_bits,previous_viewport_width_bits: self.viewport_width_bits,@@ -146,18 +129,14 @@ impl StyleWorldKey {pub(super) fn matches_observation_environment(&self,- document_url: &url::Url,viewport: StyleViewport,environment: StyloStyleEnvironment,quirks_mode: QuirksMode,tree_scope_versions: StyleTreeScopeVersions,) -> bool {- let mut document_url = document_url.clone();- document_url.set_fragment(None);let viewport_width_bits = style_dimension_bits(viewport.width, DEFAULT_VIEWPORT_WIDTH);let viewport_height_bits = style_dimension_bits(viewport.height, DEFAULT_VIEWPORT_HEIGHT);- self.document_url == document_url- && self.viewport_width_bits == viewport_width_bits+ self.viewport_width_bits == viewport_width_bits&& self.viewport_height_bits == viewport_height_bits&& self.screen_width_bits== style_dimension_bits(viewport.screen_width, f32::from_bits(viewport_width_bits))@@ -171,14 +150,8 @@ impl StyleWorldKey {&& self.tree_scope_versions == Some(tree_scope_versions)}- pub(super) fn requires_replacement_for_observation(- &self,- document_url: &url::Url,- quirks_mode: QuirksMode,- ) -> bool {- let mut document_url = document_url.clone();- document_url.set_fragment(None);- self.document_url != document_url || self.quirks_mode != quirks_mode+ pub(super) fn requires_replacement_for_observation(&self, quirks_mode: QuirksMode) -> bool {+ self.quirks_mode != quirks_mode}pub(super) fn device_differs_from_observation(@@ -203,7 +176,7 @@ impl StyleWorldKey {impl StyleWorldKeyMismatchTrace {pub(super) fn requires_style_system_replacement(&self) -> bool {- self.document_url_changed || self.quirks_mode_changed+ self.quirks_mode_changed}}diff --git a/moli-renderer-v8/src/style_engine/world_lifecycle.rs b/moli-renderer-v8/src/style_engine/world_lifecycle.rsindex 37bb7d9ff..35dd4c831 100644--- a/moli-renderer-v8/src/style_engine/world_lifecycle.rs+++ b/moli-renderer-v8/src/style_engine/world_lifecycle.rs@@ -28,7 +28,6 @@ pub(super) fn retained_style_world_update_plan(host: &DomHost,document_state: &StyleDocumentState,document: DomHandle,- document_url: &url::Url,viewport: StyleViewport,environment: StyloStyleEnvironment,quirks_mode: QuirksMode,@@ -40,7 +39,7 @@ pub(super) fn retained_style_world_update_plan((retained.key- .requires_replacement_for_observation(document_url, quirks_mode),+ .requires_replacement_for_observation(quirks_mode),retained.key.device_differs_from_observation(viewport, environment),diff --git a/moli-renderer-v8/src/style_engine/world_trace.rs b/moli-renderer-v8/src/style_engine/world_trace.rsindex b376d252e..c48a13cb7 100644--- a/moli-renderer-v8/src/style_engine/world_trace.rs+++ b/moli-renderer-v8/src/style_engine/world_trace.rs@@ -56,7 +56,6 @@ pub(super) fn trace_retained_style_system_change(stylist_identity = retained.stylist_identity,stylist_flush_count = retained.stylist.num_rebuilds(),custom_property_history_is_append_only,- document_url = %retained.key.document_url,document_stylesheet_input_count = inputs.document_stylesheet_sources.len(),shadow_stylesheet_input_count = inputs.shadow_stylesheet_sources.len(),retained_shadow_cascade_count = retained.shadow_cascade_data.len(),