Truly independent web browser
LibWeb: Remove Rust exports that no C++ code calls
Andreas Klingddd3c0ca887a
diff --git a/Libraries/LibWeb/CSS/Parser/RustSyntaxHandle.h b/Libraries/LibWeb/CSS/Parser/RustSyntaxHandle.hindex 5c420afb994..b4133e5d2a1 100644--- a/Libraries/LibWeb/CSS/Parser/RustSyntaxHandle.h+++ b/Libraries/LibWeb/CSS/Parser/RustSyntaxHandle.h@@ -53,7 +53,6 @@ public:}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)); }bool operator==(RustSyntaxHandle const& other) const{diff --git a/Libraries/LibWeb/CSS/RustMediaList.h b/Libraries/LibWeb/CSS/RustMediaList.hindex 6eb98a73173..d5e6183647a 100644--- a/Libraries/LibWeb/CSS/RustMediaList.h+++ b/Libraries/LibWeb/CSS/RustMediaList.h@@ -81,7 +81,6 @@ public:}RustMediaList retain() const { return RustMediaList { Parser::ValueParserFFI::rust_media_list_retain(m_list) }; }- RustMediaList share() const { return RustMediaList { Parser::ValueParserFFI::rust_media_list_share(m_list) }; }size_t length() const { return Parser::ValueParserFFI::rust_media_list_length(m_list); }bool matches() const { return Parser::ValueParserFFI::rust_media_list_matches(m_list); }bool evaluate(DOM::Document const& document) constdiff --git a/Libraries/LibWeb/CSS/RustRule.h b/Libraries/LibWeb/CSS/RustRule.hindex df211b23aa1..3cd2ca1100b 100644--- a/Libraries/LibWeb/CSS/RustRule.h+++ b/Libraries/LibWeb/CSS/RustRule.h@@ -58,7 +58,6 @@ public:return RustDeclarationBlock { declarations };return {};}- size_t external_memory_size() const { return Parser::ValueParserFFI::rust_rule_external_memory_size(m_rule); }Parser::ValueParserFFI::NativeRule const* handle() const { return m_rule; }private:diff --git a/Libraries/LibWeb/CSS/StyleValues/OpacityValueStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/OpacityValueStyleValue.hindex 509a57cf03a..3aecd69c86b 100644--- a/Libraries/LibWeb/CSS/StyleValues/OpacityValueStyleValue.h+++ b/Libraries/LibWeb/CSS/StyleValues/OpacityValueStyleValue.h@@ -13,10 +13,6 @@ namespace Web::CSS {class OpacityValueStyleValue final : public StyleValueWithDefaultOperators<OpacityValueStyleValue> {public:- static ValueComparingNonnullRefPtr<OpacityValueStyleValue const> create(ValueComparingNonnullRefPtr<StyleValue const> value)- {- return adopt_ref(*new (nothrow) OpacityValueStyleValue(StyleValueFFI::rust_style_value_create_opacity_value(StyleValueFFI::rust_style_value_retain(value->rust_style_value_data()))));- }virtual ~OpacityValueStyleValue() override = default;private:diff --git a/Libraries/LibWeb/Rust/src/css/calc.rs b/Libraries/LibWeb/Rust/src/css/calc.rsindex e792d30f3ec..a9e352bb475 100644--- a/Libraries/LibWeb/Rust/src/css/calc.rs+++ b/Libraries/LibWeb/Rust/src/css/calc.rs@@ -4609,8 +4609,7 @@ pub extern "C" fn rust_style_value_contains_anchor_function(value: &crate::css::/// The value of a computed `<length-percentage>` whose anchor() and anchor-size() functions are unresolvable: one/// strong reference to it with the functions replaced by their fallback values, or null when it holds no anchor/// functions or when one of them has no fallback value, which `is_invalid` tells apart.-#[unsafe(no_mangle)]-pub extern "C" fn rust_style_value_with_unresolvable_anchor_functions(+pub(crate) fn style_value_with_unresolvable_anchor_functions(value: &crate::css::style_value::StyleValueData,is_invalid: &mut bool,) -> *const crate::css::style_value::StyleValueData {diff --git a/Libraries/LibWeb/Rust/src/css/color_resolution.rs b/Libraries/LibWeb/Rust/src/css/color_resolution.rsindex cccda0e99c7..8b36b575049 100644--- a/Libraries/LibWeb/Rust/src/css/color_resolution.rs+++ b/Libraries/LibWeb/Rust/src/css/color_resolution.rs@@ -1604,57 +1604,6 @@ pub(crate) fn relative_color_computed_value_form(value: StyleValueData) -> Style}))}-/// The resolved value of a relative color function against a style: its relative form in its-/// computed value form. Returns one strong reference, or null when the origin color does not-/// resolve.-///-/// # Safety-/// `style` must be null or point at a style whose group payloads outlive the call.-#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_relative_color_resolved_value(- value: &StyleValueData,- style: *const FfiColorResolutionStyle,-) -> *const StyleValueData {- // SAFETY: Guaranteed by the caller.- let resolution_input = unsafe { ColorResolutionInput::for_ffi_style(style) };- match resolve_relative_form(value, &resolution_input) {- Some(resolved) => StyleValueArc::into_raw(StyleValueArc::new(relative_color_computed_value_form(resolved))),- None => core::ptr::null(),- }-}--/// The resolved value of a `color-mix()` against a style: the color it mixes, in the form a mix whose colors are all-/// known computes to. A computed mix stays a mix only where it reads `currentcolor`, which the style names. Returns-/// one strong reference, or null when the value is no mix or does not resolve.-///-/// # Safety-/// `style` must be null or point at a style whose group payloads outlive the call.-#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_color_mix_resolved_value(- value: &StyleValueData,- style: *const FfiColorResolutionStyle,-) -> *const StyleValueData {- if !matches!(value, StyleValueData::ColorMix { .. }) {- return core::ptr::null();- }- // SAFETY: Guaranteed by the caller.- let resolution_input = unsafe { ColorResolutionInput::for_ffi_style(style) };- match resolve_color_mix(value, &resolution_input) {- Some(resolved) => StyleValueArc::into_raw(StyleValueArc::new(resolved)),- None => core::ptr::null(),- }-}--/// Whether a color function value has a missing color component, which its resolved value keeps.-///-/// # Safety-/// `value` must point at live style value data.-#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_color_function_has_missing_component(value: *const core::ffi::c_void) -> bool {- let value = unsafe { &*value.cast::<StyleValueData>() };- crate::css::serialize::color_function_has_missing_component(value)-}-/// Port of ColorStyleValue::extract_channels_in_color_space().////// NB: The C++ code computes linear sRGB with the direct transfer function; that function isdiff --git a/Libraries/LibWeb/Rust/src/css/counter_style.rs b/Libraries/LibWeb/Rust/src/css/counter_style.rsindex 3c50bf62b87..ea5f4664c7b 100644--- a/Libraries/LibWeb/Rust/src/css/counter_style.rs+++ b/Libraries/LibWeb/Rust/src/css/counter_style.rs@@ -12,7 +12,7 @@ use crate::css::css_enums::{counter_style_system, keyword, keyword_from_ascii_case_insensitive, keyword_to_counter_style_name_keyword,};use crate::css::css_string::CssString;-use crate::css::descriptor_block::{DescriptorBlockData, FfiDescriptorBlock, rust_descriptor_block_retain};+use crate::css::descriptor_block::{DescriptorBlockData, FfiDescriptorBlock};use crate::css::descriptor_metadata::descriptor_metadata;use crate::css::ffi_support::{FfiUtf16View, ascii_lowercase};use crate::css::parser::descriptor_parser::resolve_descriptor_integer;@@ -63,7 +63,7 @@ impl FfiCounterStyle {}pub(crate) fn set_name_text(&self, name: &[u16]) -> bool {- rust_counter_style_set_name(self, FfiUtf16View::from_utf16(name))+ counter_style_set_name(self, FfiUtf16View::from_utf16(name))}/// The value of the `system` descriptor, if the rule has one.@@ -82,7 +82,7 @@ impl FfiCounterStyle {let Some(system) = self.system() else {return true;};- rust_counter_style_system_accepts_symbols(+ counter_style_system_accepts_symbols(Some(&system),additive,value.child_values().map_or(0, |values| values.len()),@@ -92,7 +92,7 @@ impl FfiCounterStyle {/// Whether the value of the `system` descriptor would change the algorithm that the rule uses.pub(crate) fn system_change_alters_algorithm(&self, new: &StyleValueData) -> bool {self.system()- .is_none_or(|current| rust_counter_style_system_changes_algorithm(¤t, new))+ .is_none_or(|current| counter_style_system_changes_algorithm(¤t, new))}pub(crate) fn set_descriptor(&self, name: &[u16], value: StyleValueArc) {@@ -110,13 +110,12 @@ impl FfiCounterStyle {}}-#[unsafe(no_mangle)]-pub extern "C" fn rust_counter_style_descriptors(rule: &FfiCounterStyle) -> *mut FfiDescriptorBlock {- rust_descriptor_block_retain(&rule.descriptors)+#[cfg(test)]+pub(crate) fn rust_counter_style_descriptors(rule: &FfiCounterStyle) -> *mut FfiDescriptorBlock {+ crate::css::descriptor_block::rust_descriptor_block_retain(&rule.descriptors)}-#[unsafe(no_mangle)]-pub extern "C" fn rust_counter_style_set_name(rule: &FfiCounterStyle, name: FfiUtf16View) -> bool {+pub(crate) fn counter_style_set_name(rule: &FfiCounterStyle, name: FfiUtf16View) -> bool {let Some(mut name) = name.to_utf16() else {return false;};@@ -589,20 +588,14 @@ pub unsafe extern "C" fn rust_counter_styles_resolve(/// Whether a rule whose `system` is `system`, null when it has none, still defines a counter style/// once its `symbols` descriptor, or its `additive-symbols` one when `additive`, lists `count`/// entries.-#[unsafe(no_mangle)]-pub extern "C" fn rust_counter_style_system_accepts_symbols(- system: Option<&StyleValueData>,- additive: bool,- count: usize,-) -> bool {+fn counter_style_system_accepts_symbols(system: Option<&StyleValueData>, additive: bool, count: usize) -> bool {symbol_counts_needed(system).is_some_and(|(symbols, additive_symbols)| count >= if additive { additive_symbols } else { symbols })}/// Whether setting a rule's `system` from `current` to `new` changes the algorithm it uses: the/// system itself, the first symbol of a fixed one or the style an extending one extends.-#[unsafe(no_mangle)]-pub extern "C" fn rust_counter_style_system_changes_algorithm(current: &StyleValueData, new: &StyleValueData) -> bool {+fn counter_style_system_changes_algorithm(current: &StyleValueData, new: &StyleValueData) -> bool {let (Some(current), Some(new)) = (current.as_counter_style_system(), new.as_counter_style_system()) else {return true;};diff --git a/Libraries/LibWeb/Rust/src/css/font_feature_values.rs b/Libraries/LibWeb/Rust/src/css/font_feature_values.rsindex 049dca6d3f4..f70ecb44e4d 100644--- a/Libraries/LibWeb/Rust/src/css/font_feature_values.rs+++ b/Libraries/LibWeb/Rust/src/css/font_feature_values.rs@@ -195,8 +195,8 @@ pub unsafe extern "C" fn rust_font_feature_values_family_at(FfiUtf16View::from_utf16(data.families[index].units())}-#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_font_feature_values_set_families(+#[cfg(test)]+pub(crate) unsafe fn rust_font_feature_values_set_families(owner: &FontFeatureValuesRule,families: *const FfiUtf16View,count: usize,diff --git a/Libraries/LibWeb/Rust/src/css/media_list.rs b/Libraries/LibWeb/Rust/src/css/media_list.rsindex 9b1312308b7..f5bf0717b72 100644--- a/Libraries/LibWeb/Rust/src/css/media_list.rs+++ b/Libraries/LibWeb/Rust/src/css/media_list.rs@@ -206,8 +206,8 @@ pub extern "C" fn rust_media_list_retain(list: &MediaList) -> *mut MediaList {Box::into_raw(Box::new(list.clone()))}-#[unsafe(no_mangle)]-pub extern "C" fn rust_media_list_share(list: &MediaList) -> *mut MediaList {+#[cfg(test)]+pub(crate) fn rust_media_list_share(list: &MediaList) -> *mut MediaList {Box::into_raw(Box::new(list.share()))}diff --git a/Libraries/LibWeb/Rust/src/css/parser/syntax.rs b/Libraries/LibWeb/Rust/src/css/parser/syntax.rsindex a6bd71ed211..ad2a64f4e60 100644--- a/Libraries/LibWeb/Rust/src/css/parser/syntax.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/syntax.rs@@ -456,11 +456,6 @@ pub extern "C" fn rust_syntax_is_universal(syntax: &SyntaxNode) -> bool {matches!(syntax, SyntaxNode::Universal)}-#[unsafe(no_mangle)]-pub extern "C" fn rust_syntax_is_single_component(syntax: &SyntaxNode) -> bool {- is_single_syntax_component(syntax)-}-#[unsafe(no_mangle)]pub extern "C" fn rust_syntax_value_is_list(syntax: &SyntaxNode, value: &StyleValueData) -> bool {match syntax {@@ -524,7 +519,7 @@ impl SyntaxNode {}pub(crate) fn is_single_component(&self) -> bool {- rust_syntax_is_single_component(self)+ is_single_syntax_component(self)}pub(crate) fn serialize_to(&self, sink: &mut TextSink) {diff --git a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rs b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rsindex f1b3d078077..af111a8fbeb 100644--- a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rs@@ -177,11 +177,11 @@ fn counter_style_mutation_preserves_names_and_descriptor_snapshots() {let data = other_descriptors.data();let replacement = data.descriptors[0].view();assert!(rust_descriptor_block_set(&mut descriptors, &replacement));- assert!(rust_counter_style_set_name(&rule, view(&utf16("UPPER-ROMAN"))));+ assert!(counter_style_set_name(&rule, view(&utf16("UPPER-ROMAN"))));assert_eq!(retained.name().units(), utf16("upper-roman"));assert_eq!(shared.name().units(), utf16("初"));- assert!(!rust_counter_style_set_name(&rule, view(&utf16("DiSc"))));- assert!(!rust_counter_style_set_name(&rule, view(&utf16("NONE"))));+ assert!(!counter_style_set_name(&rule, view(&utf16("DiSc"))));+ assert!(!counter_style_set_name(&rule, view(&utf16("NONE"))));let changed = snapshot(&rule);assert_eq!(changed.name().units(), utf16("upper-roman"));assert_eq!(@@ -199,7 +199,7 @@ fn counter_style_mutation_preserves_names_and_descriptor_snapshots() {));assert!(retained.descriptors().descriptors.is_empty());assert_eq!(changed.descriptors().descriptors.len(), 1);- assert!(rust_counter_style_set_name(&rule, view(&utf16("名前 空白"))));+ assert!(counter_style_set_name(&rule, view(&utf16("名前 空白"))));assert_eq!(retained.name().units(), utf16("名前 空白"));assert_eq!(changed.name().units(), utf16("upper-roman"));}diff --git a/Libraries/LibWeb/Rust/src/css/resolved_value.rs b/Libraries/LibWeb/Rust/src/css/resolved_value.rsindex 0dc432a1d63..7c08c125915 100644--- a/Libraries/LibWeb/Rust/src/css/resolved_value.rs+++ b/Libraries/LibWeb/Rust/src/css/resolved_value.rs@@ -356,7 +356,7 @@ fn style_value_for_transform_origin(fn resolve_unresolvable_anchor_functions(property: u16, computed_value: StyleValueArc) -> StyleValueArc {let mut is_invalid = false;let substituted =- crate::css::calc::rust_style_value_with_unresolvable_anchor_functions(&computed_value, &mut is_invalid);+ crate::css::calc::style_value_with_unresolvable_anchor_functions(&computed_value, &mut is_invalid);if !substituted.is_null() {// SAFETY: The call hands over one strong reference.return unsafe { StyleValueArc::from_raw(substituted) };diff --git a/Libraries/LibWeb/Rust/src/css/rule.rs b/Libraries/LibWeb/Rust/src/css/rule.rsindex 0e14fde1500..0bcaa60a7bf 100644--- a/Libraries/LibWeb/Rust/src/css/rule.rs+++ b/Libraries/LibWeb/Rust/src/css/rule.rs@@ -1041,8 +1041,7 @@ pub extern "C" fn rust_rule_declarations(rule: &NativeRule) -> *mut DeclarationB.map_or(std::ptr::null_mut(), |block| Box::into_raw(Box::new(block.clone())))}-#[unsafe(no_mangle)]-pub extern "C" fn rust_rule_external_memory_size(rule: &NativeRule) -> usize {+fn rule_external_memory_size(rule: &NativeRule) -> usize {let payload_size = match &rule.payload {RulePayload::FontFace(_) | RulePayload::Page { .. } | RulePayload::FunctionDeclarations(_) => {size_of::<FfiDescriptorBlock>()diff --git a/Libraries/LibWeb/Rust/src/css/rule/cssom.rs b/Libraries/LibWeb/Rust/src/css/rule/cssom.rsindex 54e0017c74c..30ceb018f61 100644--- a/Libraries/LibWeb/Rust/src/css/rule/cssom.rs+++ b/Libraries/LibWeb/Rust/src/css/rule/cssom.rs@@ -150,7 +150,7 @@ impl NativeRule {/// The memory the rule owns outside the heap.pub fn cssom_external_memory_size(&self) -> usize {- super::rust_rule_external_memory_size(self)+ super::rule_external_memory_size(self)}pub fn cssom_set_selector_text(&self, text: &Utf16String, sheet_rules: Option<&NativeRuleList>) -> bool {diff --git a/Libraries/LibWeb/Rust/src/css/style_value.rs b/Libraries/LibWeb/Rust/src/css/style_value.rsindex 51fa0104f28..3127ba05d87 100644--- a/Libraries/LibWeb/Rust/src/css/style_value.rs+++ b/Libraries/LibWeb/Rust/src/css/style_value.rs@@ -4197,31 +4197,8 @@ pub extern "C" fn rust_style_value_create_ratio())))}-/// Takes ownership of one strong reference to the number, percentage or calculated value.-#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_style_value_create_opacity_value(value: *const StyleValueData) -> *const StyleValueData {- StyleValueArc::into_raw(StyleValueArc::new(StyleValueData::OpacityValue {- value: unsafe { RetainedStyleValueData::from_retained_pointer(value) },- }))-}--/// Takes ownership of one strong reference to the length-percentage value.-#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_style_value_create_text_indent(- length_percentage: *const StyleValueData,- hanging: bool,- each_line: bool,-) -> *const StyleValueData {- StyleValueArc::into_raw(StyleValueArc::new(StyleValueData::TextIndent {- length_percentage: unsafe { RetainedStyleValueData::from_retained_pointer(length_percentage) },- hanging,- each_line,- }))-}-/// Takes ownership of one strong reference to each track size.-#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_style_value_create_grid_track_size_list(+pub(crate) unsafe fn style_value_create_grid_track_size_list(track_sizes: *const *const StyleValueData,length: usize,) -> *const StyleValueData {@@ -4242,8 +4219,7 @@ pub unsafe extern "C" fn rust_style_value_create_grid_track_size_list(/// The track size of a grid track size list that holds just one track size, without line names, or null. The/// returned value is borrowed from `data`.-#[unsafe(no_mangle)]-pub extern "C" fn rust_style_value_grid_track_size_list_single_size(data: &StyleValueData) -> *const StyleValueData {+pub(crate) fn style_value_grid_track_size_list_single_size(data: &StyleValueData) -> *const StyleValueData {let StyleValueData::GridTrackSizeList(grid_track_size_list) = data else {return std::ptr::null();};diff --git a/Libraries/LibWeb/Rust/src/css/typed_om.rs b/Libraries/LibWeb/Rust/src/css/typed_om.rsindex 19e32e694d9..cdbc3ea93af 100644--- a/Libraries/LibWeb/Rust/src/css/typed_om.rs+++ b/Libraries/LibWeb/Rust/src/css/typed_om.rs@@ -39,7 +39,7 @@ use crate::css::serialize::{SerializationMode, TextSink, serialize_style_value};use crate::css::style_compute::{LENGTH_UNIT_CANONICAL_PX_RATIOS, LENGTH_UNIT_NAMES, rust_style_value_is_computationally_independent,};-use crate::css::style_value::rust_style_value_create_grid_track_size_list;+use crate::css::style_value::style_value_create_grid_track_size_list;pub use crate::css::style_value::{ReifiedUnresolvedSegment, RetainedStyleValueData as RetainedStyleValue};use crate::css::style_value::{RetainedNumericRangeByType, StyleValueData, rust_style_value_create_calculated, rust_style_value_create_value_list,@@ -445,7 +445,7 @@ impl RetainedStyleValue {let pointers: Vec<_> = track_sizes.into_iter().map(|size| size.into_raw().cast()).collect();// SAFETY: This hands over strong references to the track sizes, and takes over the one that the call returns.unsafe {- RetainedStyleValue::from_retained_pointer(rust_style_value_create_grid_track_size_list(+ RetainedStyleValue::from_retained_pointer(style_value_create_grid_track_size_list(pointers.as_ptr(),pointers.len(),))@@ -569,7 +569,7 @@ pub fn reification_of(value: &RetainedStyleValue) -> Reification {StyleValueData::OpacityValue { value } => return Reification::Value(value.clone()),StyleValueData::GridTrackSizeList(_) => {// NB: A track list that is just one track size, as for `grid-auto-columns: 10px`, is that track size.- let track_size = crate::css::style_value::rust_style_value_grid_track_size_list_single_size(value.data());+ let track_size = crate::css::style_value::style_value_grid_track_size_list_single_size(value.data());if !track_size.is_null() {// SAFETY: The value holds the track size alive, and this takes its own strong reference.return Reification::Value(unsafe {