Skip to content

Truly independent web browser

LibWeb: Track the initial registered custom property context

Callum Law152ba9bba156
diff --git a/Libraries/LibWeb/Rust/src/css/style/publication.rs b/Libraries/LibWeb/Rust/src/css/style/publication.rs
index 656a1f807ad..bfb009102c9 100644
--- a/Libraries/LibWeb/Rust/src/css/style/publication.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/publication.rs
@@ -637,6 +637,8 @@ impl RetainedState {
// republishes the record under the new one. A registered name declared here computes
// against the record's font until a drive settles the font anew.
let has_registered_declarations = self.declares_registered_custom_property(node, None, &inputs);
+ let initial_registered_context =
+ has_registered_declarations.then(|| self.standing_registered_value_context(node, None));
// Every installed record is published with an environment; a record without is
// republished as moved.
let old_environment = self
@@ -1084,7 +1086,7 @@ impl RetainedState {
&inputs,
&mut scratch.font_drive,
goal,
- has_registered_declarations,
+ initial_registered_context.as_ref(),
)?;
// The registered custom properties compute against the font the drive settled,
// and the winners substitute what they computed to.
@@ -1120,7 +1122,7 @@ impl RetainedState {
&inputs,
&mut scratch.font_drive,
goal,
- false,
+ None,
)?;
}
match driven {
@@ -1513,6 +1515,8 @@ impl RetainedState {
// A registered name declared here computes provisionally against the parent's font until
// the drive settles the element's own.
let has_registered_declarations = self.declares_registered_custom_property(node, None, &inputs);
+ let initial_registered_context =
+ has_registered_declarations.then(|| self.standing_registered_value_context(node, None));
// A function's container condition the engine cannot decide yet waits, as the row does.
let mut environment = self
.engine_custom_property_environment_by_answer(node, parent_environment, &inputs)
@@ -1701,7 +1705,7 @@ impl RetainedState {
&inputs,
&mut scratch.font_drive,
goal,
- has_registered_declarations,
+ initial_registered_context.as_ref(),
)?;
// The registered custom properties compute against the font the drive settled, and the
// winners substitute what they computed to.
@@ -1724,7 +1728,7 @@ impl RetainedState {
environment = settled;
store = std::sync::Arc::new(settled_store);
self.note_node_substitution(node, scratch, state, environment);
- driven = self.engine_full_drive(subject, None, &store, &inputs, &mut scratch.font_drive, goal, false)?;
+ driven = self.engine_full_drive(subject, None, &store, &inputs, &mut scratch.font_drive, goal, None)?;
}
let DrivenTable {
table,
diff --git a/Libraries/LibWeb/Rust/src/css/style/publication/demand.rs b/Libraries/LibWeb/Rust/src/css/style/publication/demand.rs
index 443f4101349..486194080d1 100644
--- a/Libraries/LibWeb/Rust/src/css/style/publication/demand.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/publication/demand.rs
@@ -546,6 +546,8 @@ impl StyleEngine {
let registered_declarations = self
.retained
.declarations_name_a_registered_custom_property(custom_declarations, &inputs);
+ let mut initial_registered_context =
+ registered_declarations.then(|| self.retained.standing_registered_value_context(subject, None));
let mut environment =
self.retained
.engine_custom_property_environment_over(subject, None, cascaded(), 0, &inputs, None)?;
@@ -559,7 +561,6 @@ impl StyleEngine {
};
let mut scratch = EngineComputedRecordScratch::default();
- let mut awaits_registered_context = registered_declarations;
let driven = loop {
match self.retained.engine_full_drive(
drive_subject,
@@ -568,7 +569,7 @@ impl StyleEngine {
&inputs,
&mut scratch.font_drive,
FontDriveGoal::Complete,
- awaits_registered_context,
+ initial_registered_context.as_ref(),
) {
Err(Unanswered::Suspended(Suspension::Font)) => {
let request = scratch.font_drive.take_suspended_request();
@@ -589,7 +590,7 @@ impl StyleEngine {
store = self
.retained
.declared_only_winners(subject, declarations, environment)?;
- awaits_registered_context = false;
+ initial_registered_context = None;
}
driven => break driven?,
}
diff --git a/Libraries/LibWeb/Rust/src/css/style/publication/drive.rs b/Libraries/LibWeb/Rust/src/css/style/publication/drive.rs
index 420a8b03943..683ccef6a28 100644
--- a/Libraries/LibWeb/Rust/src/css/style/publication/drive.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/publication/drive.rs
@@ -648,7 +648,7 @@ impl RetainedState {
/// element's font resolved through the document's resolver, line-height and color-scheme
/// against that font, and the remaining phase with the element facts the box-type
/// transformation reads. Root-input preparation finishes only the font and line-height
- /// phases and preserves them for completion, and a drive that `awaits_registered_context`
+ /// phases and preserves them for completion, and a drive with an `initial_registered_context`
/// stops after the color-scheme phase with the context the registered custom properties it
/// declares compute against, which it preserves likewise. Monospace default-size recascade
/// stays in C++.
@@ -661,7 +661,7 @@ impl RetainedState {
inputs: &bridge::FfiDocumentStyleComputationInputs,
font_scratch: &mut FontDriveScratch,
goal: FontDriveGoal,
- awaits_registered_context: bool,
+ initial_registered_context: Option<&custom_property_cascade::RegisteredValueContext>,
) -> Drive<FullDrive> {
let random_base_values = store
.drive_random_base_values(self, subject.target.node())
@@ -1122,7 +1122,7 @@ impl RetainedState {
// A registered custom property computes against the font and color scheme settled now, as
// the host finalizes one after the line-height phase; the winners the remaining phase reads
// substitute what it computes to.
- if awaits_registered_context {
+ if initial_registered_context.is_some() {
let context = self.registered_value_context(
target.node(),
FfiLengthResolutionContext {
diff --git a/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs b/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs
index 620135c6790..5fa8ad6dd4d 100644
--- a/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/publication/pseudo.rs
@@ -389,6 +389,8 @@ impl RetainedState {
// provisionally against the element's font until the drive settles the pseudo-element's
// own.
let has_registered_declarations = self.declares_registered_custom_property(node, Some(kind), &inputs);
+ let initial_registered_context =
+ has_registered_declarations.then(|| self.standing_registered_value_context(node, Some(kind)));
let mut environment =
self.engine_custom_property_environment_of(node, Some(kind), element_environment, &inputs, None)?;
// A store substituting `attr()` or `inherit()` holds the element's attributes or its
@@ -527,7 +529,7 @@ impl RetainedState {
&inputs,
&mut scratch.font_drive,
FontDriveGoal::Complete,
- has_registered_declarations,
+ initial_registered_context.as_ref(),
);
// The registered custom properties compute against the font the drive
// settled, and the winners substitute what they computed to.
@@ -557,7 +559,7 @@ impl RetainedState {
&inputs,
&mut scratch.font_drive,
FontDriveGoal::Complete,
- false,
+ None,
);
}
if let Err(Unanswered::Suspended(_)) = driven {
@@ -1050,6 +1052,9 @@ impl RetainedState {
let registered_declarations = self
.declarations_name_a_registered_custom_property(&custom_declarations, &inputs)
.then(|| custom_declarations.clone());
+ let initial_registered_context = registered_declarations
+ .as_ref()
+ .map(|_| self.standing_registered_value_context(host, None));
let mut environment = self.engine_custom_property_environment_over(
host,
None,
@@ -1077,7 +1082,7 @@ impl RetainedState {
&inputs,
&mut scratch.font_drive,
FontDriveGoal::Complete,
- registered_declarations.is_some(),
+ initial_registered_context.as_ref(),
)?;
if let FullDrive::AwaitsRegisteredContext(registered) = driven
&& let Some(custom_declarations) = registered_declarations
@@ -1105,7 +1110,7 @@ impl RetainedState {
&inputs,
&mut scratch.font_drive,
FontDriveGoal::Complete,
- false,
+ None,
)?;
}
let FullDrive::Driven(DrivenTable {