Skip to content

Truly independent web browser

LibWeb: Remove small leftovers from the style traversal

Andreas Klingd9db4be6775d
diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/cascade.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/cascade.rs
index e5bb75eb3d3..200c84d960d 100644
--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/cascade.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/cascade.rs
@@ -38,17 +38,15 @@ pub(in crate::css::style) struct Winner {
pub(super) index: usize,
}
-/// What the cascade of the element could not decide yet.
+/// What the cascades of a pass decided.
#[derive(Default)]
pub(super) struct CascadeCounters {
pub(super) winners: u64,
- pub(super) pending_substitutions: u64,
}
impl CascadeCounters {
pub(super) fn add(&mut self, other: &Self) {
self.winners += other.winners;
- self.pending_substitutions += other.pending_substitutions;
}
}
diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rs
index aa163552858..da70e21ad21 100644
--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rs
@@ -2735,13 +2735,6 @@ fn font_group_carries_longhand(property: u16) -> bool {
)
}
-/// The proof that a record reads no resource context: no value its winners give it resolves a
-/// `url()` against a style sheet's or the document's base URL. The engine keeps only such records
-/// across transactions, so a move of those base URLs, which every `history.pushState()` makes
-/// without a `<base>`, leaves nothing it keeps to forget.
-#[derive(Clone, Copy)]
-pub(in crate::css::style) struct ReadsNoResourceContexts(pub(in crate::css::style) ());
-
/// Static checks attached to the original declaration spelling at input preparation, in one word:
/// the external dependencies of the value a longhand computes from, packed the way a winner
/// memoizes them (bits 0-20 and 31), or zero for a value that waits on substitution (bit 23), and how
diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/demand.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/demand.rs
index 4853cb1f770..fe359625c27 100644
--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/demand.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/demand.rs
@@ -498,7 +498,13 @@ impl Live {
for &ancestor in ancestors.iter().rev() {
let mut held: PseudoElementRecords = records.pseudo_element_records(ancestor).into();
held.retain(|(held_target, _)| *held_target != target);
- match traversal::style_pseudo_element(&context, ancestor, target, PseudoElementRead::Styled) {
+ match traversal::style_pseudo_element_inheriting_from(
+ &context,
+ ancestor,
+ target,
+ PseudoElementRead::Styled,
+ None,
+ ) {
DemandedPseudoElement::Styled(record) => held.push((target, record)),
DemandedPseudoElement::Unstyled => {}
demanded @ (DemandedPseudoElement::Waiting(..) | DemandedPseudoElement::Declined) => {
diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/install.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/install.rs
index b166fa5bb0d..19b087ef9b1 100644
--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/install.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/install.rs
@@ -81,10 +81,6 @@ impl StyleSwap {
}
}
-/// The index of an element's effects among those of a style installation.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub(crate) struct EffectsIndex(u32);
-
/// What the main thread does to take a style installation: the styles it swaps in, and the side effects of the
/// elements whose styles move, both in tree order, each element's pseudo-elements following it. An element's effects
/// name its swaps, which the main thread performs before them, and before it swaps in the styles of the elements after
@@ -101,7 +97,7 @@ pub(crate) struct StyleInstallation {
pub(crate) pinned_records: Vec<u64>,
/// The elements taking their first style whose parent, its layout tree parent as well, takes its first style in
/// this installation too, in the order of their effects, each with the index of those and that parent.
- first_styles_below_first_styles: Vec<(EffectsIndex, StyleNodeID)>,
+ first_styles_below_first_styles: Vec<(u32, StyleNodeID)>,
}
impl StyleInstallation {
@@ -181,15 +177,12 @@ impl StyleInstallation {
/// takes its first style too.
fn note_first_style_below_first_style(&mut self, parent: StyleNodeID) {
let index = u32::try_from(self.effects.len() - 1).expect("an installation's effects fit their index");
- self.first_styles_below_first_styles.push((EffectsIndex(index), parent));
+ self.first_styles_below_first_styles.push((index, parent));
}
/// Takes the elements `note_first_style_below_first_style` noted.
pub(crate) fn take_first_styles_below_first_styles(&mut self) -> Vec<(u32, StyleNodeID)> {
std::mem::take(&mut self.first_styles_below_first_styles)
- .into_iter()
- .map(|(EffectsIndex(index), parent)| (index, parent))
- .collect()
}
/// Keeps the effects of only the elements the main thread has anything to do for beside swapping in their styles.
@@ -206,11 +199,6 @@ impl StyleInstallation {
"every element with a style to swap in has effects"
);
}
-
- /// Ends the installation: what all its moves damage is `document_damage`.
- fn finish(&mut self, document_damage: u32) {
- self.document_damage = document_damage;
- }
}
impl RetainedState {
@@ -670,10 +658,8 @@ impl RetainedState {
installation.end_element(node, first_swap);
}
scratch.ordered = ordered;
- installation.finish(super::super::style_invalidation::merged_damage(
- Some(0),
- scratch.document_damage.iter().copied(),
- ));
+ installation.document_damage =
+ super::super::style_invalidation::merged_damage(Some(0), scratch.document_damage.iter().copied());
rows
}
diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rs
index dfcc84da98d..3b526c875b1 100644
--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/traversal.rs
@@ -439,7 +439,6 @@ pub(super) struct Statistics {
pub(super) waiting_pseudo_elements: Vec<StyleNodeID>,
/// What the pass suspended of those, where it suspends, for its next round to resume.
pub(super) suspended: Vec<Suspended>,
- pub(super) pseudo_elements_declined: u64,
/// The elements the pass styled.
pub(super) styled: Vec<StyleNodeID>,
/// The elements that took the custom properties their parents hand down now without being
@@ -1257,12 +1256,13 @@ impl<'a> Scratch<'a> {
element_dependent |= dependent;
pseudo_element_records.push((target, record));
}
- PseudoElementOutcome::Declined => self.statistics.pseudo_elements_declined += 1,
// A pseudo-element waiting on a font or a random base value is styled again with
// its element once those resolved. Until then its element shares its records with
// no other.
PseudoElementOutcome::Waiting => element_dependent = true,
- PseudoElementOutcome::Unstyled | PseudoElementOutcome::GeneratesNoBox => {}
+ PseudoElementOutcome::Declined
+ | PseudoElementOutcome::Unstyled
+ | PseudoElementOutcome::GeneratesNoBox => {}
}
}
Some((pseudo_element_records, element_dependent))
@@ -3002,9 +3002,6 @@ pub(super) enum DemandedPseudoElement {
Declined,
}
-/// Style the pseudo-element `target` of `node` for a read of its style, whether or not it
-/// generates a box, from the rules the element matches for it, over the record `context` holds for
-/// `node`, which it inherits from. Which pseudo-elements are styled is what `read` says.
/// Whether the computed values of `computed` hold `display: none`.
fn computed_display_is_none(computed: &super::compute::ComputedElement) -> bool {
crate::css::style_compute::display_of(
@@ -3015,17 +3012,10 @@ fn computed_display_is_none(computed: &super::compute::ComputedElement) -> bool
.is_none()
}
-pub(super) fn style_pseudo_element(
- context: &PassContext<'_>,
- node: StyleNodeID,
- target: super::PseudoElementTarget,
- read: PseudoElementRead,
-) -> DemandedPseudoElement {
- style_pseudo_element_inheriting_from(context, node, target, read, None)
-}
-
-/// Style the pseudo-element `target` of `node` as [`style_pseudo_element`] does, inheriting from
-/// `inheritance_parent` rather than from `node` where it names an element.
+/// Style the pseudo-element `target` of `node` for a read of its style, whether or not it
+/// generates a box, from the rules the element matches for it, over the record `context` holds for
+/// `node`, which it inherits from, or for `inheritance_parent` where that names an element. Which
+/// pseudo-elements are styled is what `read` says.
pub(super) fn style_pseudo_element_inheriting_from(
context: &PassContext<'_>,
node: StyleNodeID,
@@ -3120,7 +3110,6 @@ impl Statistics {
.waiting_with_kept_matches
.extend(round.waiting_with_kept_matches);
statistics.waiting_pseudo_elements.extend(round.waiting_pseudo_elements);
- statistics.pseudo_elements_declined += round.pseudo_elements_declined;
statistics.styled.extend(round.styled);
statistics.moved_custom_properties.extend(round.moved_custom_properties);
statistics.changed_elements += round.changed_elements;
diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rs
index 4c647030512..504826294df 100644
--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/winner_store.rs
@@ -9,7 +9,6 @@
//! input borrow.
use super::super::*;
-use super::compute::ReadsNoResourceContexts;
use crate::css::cascaded_properties::{CascadedValues, WinningDeclaration};
use crate::css::style_compute::{ExternalValueDependencies, RootFontReads};
use crate::css::style_value::ShorthandPayload;
@@ -136,17 +135,16 @@ impl WinnerStore {
}
}
- /// The proof that no value the store holds resolves a `url()`, or `None` when one may.
- pub(in crate::css::style) fn reads_no_resource_contexts(
- &self,
- engine: &RetainedState,
- ) -> Option<ReadsNoResourceContexts> {
+ /// Whether no value the store holds resolves a `url()` against a style sheet's or the
+ /// document's base URL. The engine keeps only such records across transactions, so a move of
+ /// those base URLs, which every `history.pushState()` makes without a `<base>`, leaves nothing
+ /// it keeps to forget.
+ pub(in crate::css::style) fn reads_no_resource_contexts(&self, engine: &RetainedState) -> bool {
let view = self.view(engine);
- (!self
+ !self
.declarations
.iter()
- .any(|declaration| view.dependencies(declaration).may_need_style_sheet_resource_context))
- .then_some(ReadsNoResourceContexts(()))
+ .any(|declaration| view.dependencies(declaration).may_need_style_sheet_resource_context)
}
/// The container-relative units the values the store holds resolve, as a
@@ -226,7 +224,7 @@ impl WinnerStore {
&self,
engine: &RetainedState,
) -> Vec<crate::css::style_compute::FfiStyleSheetResourceContext> {
- if self.reads_no_resource_contexts(engine).is_some() {
+ if self.reads_no_resource_contexts(engine) {
return Vec::new();
}
let view = self.view(engine);
@@ -423,11 +421,7 @@ mod tests {
}))
};
let first = store(property_id::FILL, url_value());
- assert_eq!(
- first.reads_no_resource_contexts(&engine.retained).is_some(),
- can_reuse,
- "{url}"
- );
+ assert_eq!(first.reads_no_resource_contexts(&engine.retained), can_reuse, "{url}");
}
let image_value = |base_url: &str, origin_clean| {
@@ -448,7 +442,7 @@ mod tests {
property_id::BACKGROUND_IMAGE,
image_value("https://example.com/first.css", true),
);
- assert!(first.reads_no_resource_contexts(&engine.retained).is_none());
+ assert!(!first.reads_no_resource_contexts(&engine.retained));
}
#[test]