Skip to content

Truly independent web browser

LibWeb: Remove Rust exports that nothing calls

Aliaksandr Kalenika59efebf9b48
diff --git a/Libraries/LibWeb/CSS/Parser/RustSyntaxHandle.h b/Libraries/LibWeb/CSS/Parser/RustSyntaxHandle.h
index d715512a366..5c420afb994 100644
--- a/Libraries/LibWeb/CSS/Parser/RustSyntaxHandle.h
+++ b/Libraries/LibWeb/CSS/Parser/RustSyntaxHandle.h
@@ -52,11 +52,6 @@ public:
ValueParserFFI::rust_syntax_release(m_syntax);
}
- static RustSyntaxHandle universal()
- {
- return RustSyntaxHandle { ValueParserFFI::rust_syntax_create_universal() };
- }
-
bool is_universal() const { return ValueParserFFI::rust_syntax_is_universal(m_syntax); }
bool is_single_component() const { return ValueParserFFI::rust_syntax_is_single_component(m_syntax); }
Utf16String serialize() const { return Utf16String::adopt_raw(ValueParserFFI::rust_syntax_serialize(m_syntax)); }
diff --git a/Libraries/LibWeb/CSS/RustPageSelectors.h b/Libraries/LibWeb/CSS/RustPageSelectors.h
index 6c96c48a2b0..f7fa61a00c9 100644
--- a/Libraries/LibWeb/CSS/RustPageSelectors.h
+++ b/Libraries/LibWeb/CSS/RustPageSelectors.h
@@ -56,7 +56,6 @@ public:
}
Parser::ValueParserFFI::PageSelectorList const* handle() const { return m_selectors; }
- size_t size() const { return Parser::ValueParserFFI::rust_page_selector_list_count(m_selectors); }
Utf16String serialize() const
{
Utf16String result;
diff --git a/Libraries/LibWeb/CSS/RustRule.h b/Libraries/LibWeb/CSS/RustRule.h
index 37c18349f31..46629245523 100644
--- a/Libraries/LibWeb/CSS/RustRule.h
+++ b/Libraries/LibWeb/CSS/RustRule.h
@@ -81,8 +81,6 @@ public:
{
}
~RustCompiledFunction() { Parser::ValueParserFFI::rust_compiled_function_release(m_function); }
- u64 identity() const { return Parser::ValueParserFFI::rust_compiled_function_identity(m_function); }
- Parser::ValueParserFFI::FunctionSignature const* signature() const { return Parser::ValueParserFFI::rust_compiled_function_signature(m_function); }
auto* handle() const { return m_function; }
private:
diff --git a/Libraries/LibWeb/CSS/StyleEngineBridge.h b/Libraries/LibWeb/CSS/StyleEngineBridge.h
index ee2823c0139..c560faa7804 100644
--- a/Libraries/LibWeb/CSS/StyleEngineBridge.h
+++ b/Libraries/LibWeb/CSS/StyleEngineBridge.h
@@ -65,9 +65,6 @@ void style_engine_set_element_part_exposure(DocumentHost const*, StyleNodeID nod
void style_engine_set_element_directionality(DocumentHost const*, StyleNodeID node, StyleAtomID directionality);
void style_engine_set_element_custom_states(DocumentHost const*, StyleNodeID node, ReadonlySpan<StyleAtomID> states);
void style_engine_end_deferred_geometry_transaction_flush(DocumentHost const*);
-void style_engine_begin_cold_matching_batch(DocumentHost const*, StyleNodeID root);
-void style_engine_begin_adaptive_cold_matching_batch(DocumentHost const*, StyleNodeID root);
-void style_engine_end_cold_matching_batch(DocumentHost const*);
void style_engine_record_container_query_input(DocumentHost const*, StyleNodeID node);
void style_engine_note_children_explicitly_inherit(DocumentHost const*, StyleNodeID node, u32 groups);
void style_engine_record_derived_element_style_input(DocumentHost const*, StyleNodeID node, u8 reaction, u8 inherited_style_groups);
@@ -81,7 +78,6 @@ void style_engine_set_element_box_kind(DocumentHost const*, StyleNodeID node, u8
void style_engine_set_element_replaced_content_input(DocumentHost const*, StyleNodeID node, u8 kind, u8 present, u32 const* values);
void style_engine_set_element_heading_level(DocumentHost const*, StyleNodeID node, u8 level);
void style_engine_acknowledge_engine_computed_record(DocumentHost const*, StyleNodeID node);
-void style_engine_abandon_demanded_records(DocumentHost const*, StyleNodeID node);
void style_engine_record_transition_baseline(DocumentHost const*, StyleNodeID node, u8 pseudo_kind, u64 style_record);
void style_engine_release_transition_baselines(DocumentHost const*);
void style_engine_pin_style_record(DocumentHost const*, u64 style_record);
@@ -111,7 +107,6 @@ bool style_engine_begin_deferred_geometry_transaction_flush(DocumentHost const*,
bool style_engine_has_deferred_geometry_transaction(DocumentHost const*, BegunRead const*);
size_t style_engine_match_document(DocumentHost const*, BegunRead const*, StyleNodeID root);
u32 style_engine_layer_index(DocumentHost const*, BegunRead const*, TreeScopeID tree_scope, u32 layer);
-bool style_engine_node_declares_custom_properties(DocumentHost const*, BegunRead const*, StyleNodeID node);
u64 style_engine_size_query_container_scan_visits(DocumentHost const*, BegunRead const*, bool reset);
u64 style_engine_ensure_random_base_value(DocumentHost const*, BegunRead const*, StyleNodeID node, ReadonlySpan<u16> name, bool element_shared);
}
@@ -382,7 +377,6 @@ public:
// The transaction that flew knows an element that arrived or was removed beside it as it was sealed: the drain
// leaves its change, and what inherits from it, to the next transaction.
void note_style_node_arrived_or_retired(StyleNodeID);
- [[nodiscard]] bool style_node_arrived_or_retired_beside_flown_transaction(StyleNodeID style_node) const { return StyleEngineFFI::style_engine_style_node_is_beside_flown_transaction(host(), style_node.value()); }
// The transaction that flew decided which of its rows the host composes from the animations each element had as it
// was sealed: an element whose animations changed beside it holds them composed from the next transaction on.
void note_animations_changed(StyleNodeID);
diff --git a/Libraries/LibWeb/CSS/StyleValues/CalcNodeRef.h b/Libraries/LibWeb/CSS/StyleValues/CalcNodeRef.h
index 607e7743fe5..75cf83daace 100644
--- a/Libraries/LibWeb/CSS/StyleValues/CalcNodeRef.h
+++ b/Libraries/LibWeb/CSS/StyleValues/CalcNodeRef.h
@@ -56,14 +56,6 @@ public:
// simplification entry points.
static CalcNodeRef adopt(StyleValueFFI::CalcNode const* node) { return CalcNodeRef { node }; }
- // Retains an additional reference to a borrowed node, for example the root
- // stored in a calculated style value's data.
- static CalcNodeRef retain(StyleValueFFI::CalcNode const* node)
- {
- StyleValueFFI::rust_calc_node_retain(node);
- return CalcNodeRef { node };
- }
-
static CalcNodeRef numeric(NumericValue const&);
static CalcNodeRef sum(Vector<CalcNodeRef>);
diff --git a/Libraries/LibWeb/Rust/src/css/calc.rs b/Libraries/LibWeb/Rust/src/css/calc.rs
index d5ea6d9a553..ab94f02f640 100644
--- a/Libraries/LibWeb/Rust/src/css/calc.rs
+++ b/Libraries/LibWeb/Rust/src/css/calc.rs
@@ -1159,16 +1159,6 @@ pub unsafe extern "C" fn rust_calc_node_release(node: *const CalcNode) {
drop(unsafe { Arc::from_raw(node) });
}
-/// Retains an additional strong reference to a calculation node, so the C++
-/// side can take ownership of a borrowed node.
-///
-/// # Safety
-/// `node` must be a valid calculation node pointer.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn rust_calc_node_retain(node: *const CalcNode) {
- unsafe { Arc::increment_strong_count(node) };
-}
-
/// https://drafts.csswg.org/css-values-4/#determine-the-type-of-a-calculation
/// Determines the type of the calculation rooted at `node` under the given
/// resolve-as target. The result's valid flag is false when the tree does not
diff --git a/Libraries/LibWeb/Rust/src/css/parser/syntax.rs b/Libraries/LibWeb/Rust/src/css/parser/syntax.rs
index 7ea93aa4af1..c4ad9a3bf9e 100644
--- a/Libraries/LibWeb/Rust/src/css/parser/syntax.rs
+++ b/Libraries/LibWeb/Rust/src/css/parser/syntax.rs
@@ -444,12 +444,6 @@ pub unsafe extern "C" fn rust_parse_syntax(source: FfiUtf16View, limit_ident_to_
Arc::into_raw(Arc::new(syntax)).cast()
}
-/// Returns an owned universal-syntax handle.
-#[unsafe(no_mangle)]
-pub extern "C" fn rust_syntax_create_universal() -> *const c_void {
- Arc::into_raw(Arc::new(SyntaxNode::Universal)).cast()
-}
-
/// # Safety
/// `syntax` must be a live parsed-syntax handle.
#[unsafe(no_mangle)]
diff --git a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs
index b2ad61014db..38d838c770a 100644
--- a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs
+++ b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs
@@ -3706,11 +3706,6 @@ pub unsafe extern "C" fn rust_page_selector_list_release(list: *const PageSelect
}
}
-#[unsafe(no_mangle)]
-pub extern "C" fn rust_page_selector_list_count(list: &PageSelectorList) -> usize {
- list.selectors.len()
-}
-
#[unsafe(no_mangle)]
pub unsafe extern "C" fn rust_page_selector_list_serialize(
list: &PageSelectorList,
diff --git a/Libraries/LibWeb/Rust/src/css/rule/function.rs b/Libraries/LibWeb/Rust/src/css/rule/function.rs
index 7fe07e1e0ec..f7c6721a939 100644
--- a/Libraries/LibWeb/Rust/src/css/rule/function.rs
+++ b/Libraries/LibWeb/Rust/src/css/rule/function.rs
@@ -122,16 +122,6 @@ pub unsafe extern "C" fn rust_compiled_function_retain(function: *const Compiled
function
}
-#[unsafe(no_mangle)]
-pub extern "C" fn rust_compiled_function_identity(function: &CompiledFunction) -> u64 {
- function.identity
-}
-
-#[unsafe(no_mangle)]
-pub extern "C" fn rust_compiled_function_signature(function: &CompiledFunction) -> *const FunctionSignature {
- Arc::as_ptr(&function.signature)
-}
-
/// The functions a style sheet's top-level `@function` rules compile to, in order, with no rule
/// owner left alive.
#[cfg(test)]
diff --git a/Libraries/LibWeb/Rust/src/css/style/boundary.rs b/Libraries/LibWeb/Rust/src/css/style/boundary.rs
index aa79a7cefc4..19c4a667424 100644
--- a/Libraries/LibWeb/Rust/src/css/style/boundary.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/boundary.rs
@@ -6,8 +6,9 @@
//! The host's plain writes and reads of a document's style engine, one row each in the table below. A write row names
//! the [`StyleChange`] its entry queues for the document's render state, which applies the change in the order the host
-//! made them; a read is answered in place while the host waits. A row is exported as `style_engine_` and its name, and
-//! does what the engine method of that name does unless the row says otherwise.
+//! made them; a read is answered in place while the host waits. A row of `writes` or `reads` is exported as
+//! `style_engine_` and its name, and does what the engine method of that name does unless the row says otherwise. A row
+//! of `unexported_writes` names a change only Rust queues, so it has no entry.
//!
//! cbindgen does not expand macros, so the C++ declarations of the entries are written by hand in
//! `CSS/StyleEngineBridge.h`, and a test checks each against its row.
@@ -129,11 +130,16 @@ macro_rules! style_boundary {
(
|$engine:ident|
writes { $($write:ident => $Change:ident $({ $($field:ident: $type:ty),+ })? $(=> $apply:expr)?;)+ }
+ unexported_writes {
+ $($unexported_write:ident => $UnexportedChange:ident
+ $({ $($unexported_field:ident: $unexported_type:ty),+ })? $(=> $unexported_apply:expr)?;)+
+ }
reads { $($read:ident($($argument:ident: $argument_type:ty),*) -> $answer:ty $(=> $ask:expr)?;)+ }
) => {
- /// A write of the host to the document's style engine, which the render state applies to it.
+ /// A write of the host or of Rust to the document's style engine, which the render state applies to it.
pub(crate) enum StyleChange {
$($Change $({ $($field: <$type as Carried>::Held),+ })?,)+
+ $($UnexportedChange $({ $($unexported_field: <$unexported_type as Carried>::Held),+ })?,)+
}
impl StyleChange {
@@ -143,6 +149,14 @@ macro_rules! style_boundary {
$($(let Some($field) = <$type>::applied($field) else { return };)+)?
style_boundary!(@apply $engine $write($($($field),+)?) $($apply)?);
})+
+ $(Self::$UnexportedChange $({ $($unexported_field),+ })? => {
+ $($(
+ let Some($unexported_field) = <$unexported_type>::applied($unexported_field) else { return };
+ )+)?
+ style_boundary!(
+ @apply $engine $unexported_write($($($unexported_field),+)?) $($unexported_apply)?
+ );
+ })+
}
}
}
@@ -248,9 +262,6 @@ style_boundary! {
set_element_custom_states => SetElementCustomStates { node: StyleNodeID, states: Box<[StyleAtomID]> } =>
engine.set_element_custom_states(node, &states);
end_deferred_geometry_transaction_flush => EndDeferredGeometryTransactionFlush;
- begin_cold_matching_batch => BeginColdMatchingBatch { root: StyleNodeID };
- begin_adaptive_cold_matching_batch => BeginAdaptiveColdMatchingBatch { root: StyleNodeID };
- end_cold_matching_batch => EndColdMatchingBatch;
record_container_query_input => RecordContainerQueryInput { node: StyleNodeID };
note_children_explicitly_inherit => NoteChildrenExplicitlyInherit { node: StyleNodeID, groups: u32 };
record_derived_element_style_input => RecordDerivedElementStyleInput {
@@ -274,7 +285,6 @@ style_boundary! {
} => engine.set_element_replaced_content_input(node, ReplacedContentInput::from_raw(kind, present, values));
set_element_heading_level => SetElementHeadingLevel { node: StyleNodeID, level: u8 };
acknowledge_engine_computed_record => AcknowledgeEngineComputedRecord { node: StyleNodeID };
- abandon_demanded_records => AbandonDemandedRecords { node: StyleNodeID };
record_transition_baseline => RecordTransitionBaseline {
node: StyleNodeID, pseudo_kind: u8, style_record: u64
};
@@ -317,6 +327,13 @@ style_boundary! {
set_sheet_conditions_hold => SetSheetConditionsHold { sheet: SheetID, conditions_hold: bool };
}
+ unexported_writes {
+ begin_cold_matching_batch => BeginColdMatchingBatch { root: StyleNodeID };
+ begin_adaptive_cold_matching_batch => BeginAdaptiveColdMatchingBatch { root: StyleNodeID };
+ end_cold_matching_batch => EndColdMatchingBatch;
+ abandon_demanded_records => AbandonDemandedRecords { node: StyleNodeID };
+ }
+
reads {
connected_element_count() -> u32;
has_suspended_style_pass() -> bool;
@@ -327,8 +344,6 @@ style_boundary! {
match_document(root: Option<StyleNodeID>) -> usize =>
root.and_then(|root| engine.match_document(root).ok()).unwrap_or(usize::MAX);
layer_index(tree_scope: TreeScopeID, layer: CascadeLayerID) -> u32;
- node_declares_custom_properties(node: Option<StyleNodeID>) -> bool =>
- node.is_some_and(|node| engine.node_declares_custom_properties(node));
size_query_container_scan_visits(reset: bool) -> u64;
ensure_random_base_value(node: Option<StyleNodeID>, name: FfiSpan<u16>, element_shared: bool) -> u64 => {
// SAFETY: The host lends the name for the call.
diff --git a/Libraries/LibWeb/Rust/src/css/style/style_job.rs b/Libraries/LibWeb/Rust/src/css/style/style_job.rs
index 120ac9e173b..2360c4cf8ae 100644
--- a/Libraries/LibWeb/Rust/src/css/style/style_job.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/style_job.rs
@@ -432,13 +432,6 @@ pub extern "C" fn style_engine_note_style_node_beside_flown_transaction(host: &D
}
}
-/// Whether the element `node` names arrived, moved or retired beside the style transaction of `host`'s document that
-/// flew.
-#[unsafe(no_mangle)]
-pub extern "C" fn style_engine_style_node_is_beside_flown_transaction(host: &DocumentHost, node: u32) -> bool {
- StyleNodeID::from_raw(node).is_some_and(|node| host.engine_memo().beside_flown_transaction.borrow().contains(&node))
-}
-
/// Whether the frame whose style transaction `host`'s document drains applied the element `style_node` names its record
/// `style_record` ahead of the host, and marked the relayout the move asks for: the host's install of the row marks none
/// then.