Truly independent web browser
LibWeb: Stop moving the misc layout group with backgrounds and borders
Andreas Klingd62a66fb985f
diff --git a/Libraries/LibWeb/Rust/src/css/computed_values.rs b/Libraries/LibWeb/Rust/src/css/computed_values.rsindex f0d580aa2fb..bab6c96e8db 100644--- a/Libraries/LibWeb/Rust/src/css/computed_values.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_values.rs@@ -3580,14 +3580,6 @@ impl StyleGroupMasks {// NB: The surround group holds whether the element names a default anchor, which layout reads beside the// anchor group's name.masks[index(POSITION_ANCHOR)] |= 1 << crate::css::table_group_builder::group_index::SURROUND;- // NB: The misc layout group holds whether an author declaration disables native appearance, which these- // properties' winners decide.- let disabling = crate::css::style_compute::PROPERTIES_DISABLING_NATIVE_APPEARANCE;- let mut disabling_index = 0;- while disabling_index < disabling.len() {- masks[index(disabling[disabling_index])] |= 1 << crate::css::table_group_builder::group_index::MISC_LAYOUT;- disabling_index += 1;- }let mut ungrouped_inherited = [0; LONGHAND_COUNT];let mut ungrouped_inherited_count = 0;diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rsindex 7fc1d41b3b2..92a0ee3f5a6 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/compute.rs@@ -780,6 +780,15 @@ impl RetainedState {parent.map(|(parent, _)| parent),);let is_th_element = facts & bridge::element_adjustment_fact::IS_TH != 0;+ // https://drafts.csswg.org/css-ui/#appearance-disabling-properties+ // NB: Only an element whose appearance is not none can have a native appearance to disable. Leaving the flag+ // clear for every other element keeps their author backgrounds and borders from splitting style groups.+ let appearance_is_none = |writer: &GroupValuesWriter<'_>| {+ matches!(+ writer.get(prop::APPEARANCE).map(RetainedStyleValueData::data),+ Some(StyleValueData::Keyword { keyword }) if *keyword == crate::css::style_compute::keyword::NONE+ )+ };// A container-relative length never computes directly, so only a drive resolves one.let mut container_units = 0;let (mut writer, length, font, author_disables_native_appearance) = if runs_drive {@@ -868,8 +877,8 @@ impl RetainedState {{unreachable!("the style engine answers every row");}- let author_disables_native_appearance =- crate::css::style_compute::has_author_value_disabling_native_appearance(&store.view(self));+ let author_disables_native_appearance = !appearance_is_none(&writer)+ && crate::css::style_compute::has_author_value_disabling_native_appearance(&store.view(self));(writer, length, Some(font), author_disables_native_appearance)} else {// https://drafts.csswg.org/css-fonts/#font-size-prop@@ -938,24 +947,18 @@ impl RetainedState {unreachable!("the style engine answers every row");}// NB: None of these winners reverts, so each is the cascaded value of its property.- let author_disables_native_appearance = winners.iter().any(|winner| {- crate::css::style_compute::PROPERTIES_DISABLING_NATIVE_APPEARANCE.contains(&winner.property)- && matches!(- cascade.priority_of(winner.source, winner.important).cascade_origin(),- crate::css::cascaded_properties::CascadeOrigin::Author- | crate::css::cascaded_properties::CascadeOrigin::AuthorPresentationalHint- )- });+ let author_disables_native_appearance = !appearance_is_none(&writer)+ && winners.iter().any(|winner| {+ crate::css::style_compute::property_disables_native_appearance(winner.property)+ && matches!(+ cascade.priority_of(winner.source, winner.important).cascade_origin(),+ crate::css::cascaded_properties::CascadeOrigin::Author+ | crate::css::cascaded_properties::CascadeOrigin::AuthorPresentationalHint+ )+ });(writer, length, font, author_disables_native_appearance)};- // https://drafts.csswg.org/css-ui/#appearance-disabling-properties- // NB: Only an element whose appearance is not none can have a native appearance to disable. Leaving the flag- // clear for every other element keeps their author backgrounds and borders from splitting style groups.- let appearance_is_none = matches!(- writer.get(prop::APPEARANCE).map(RetainedStyleValueData::data),- Some(StyleValueData::Keyword { keyword }) if *keyword == crate::css::style_compute::keyword::NONE- );- writer.set_native_appearance_disabled(!appearance_is_none && author_disables_native_appearance);+ writer.set_native_appearance_disabled(author_disables_native_appearance);let required_moved = crate::css::style_compute::REQUIRED_DRIVER_INPUTS.iter().filter(|&&property| writer.moved_from_seed(property, seeded_bits))diff --git a/Libraries/LibWeb/Rust/src/css/style_compute.rs b/Libraries/LibWeb/Rust/src/css/style_compute.rsindex 53339014ffa..470c1ed76aa 100644--- a/Libraries/LibWeb/Rust/src/css/style_compute.rs+++ b/Libraries/LibWeb/Rust/src/css/style_compute.rs@@ -4061,6 +4061,25 @@ pub(crate) const PROPERTIES_DISABLING_NATIVE_APPEARANCE: &[u16] = {]};+/// One bit per longhand: whether it is among [`PROPERTIES_DISABLING_NATIVE_APPEARANCE`].+const LONGHANDS_DISABLING_NATIVE_APPEARANCE: [u64; crate::css::property_metadata::LONGHAND_WORD_COUNT] = {+ let mut words = [0; crate::css::property_metadata::LONGHAND_WORD_COUNT];+ let mut at = 0;+ while at < PROPERTIES_DISABLING_NATIVE_APPEARANCE.len() {+ let index = (PROPERTIES_DISABLING_NATIVE_APPEARANCE[at]+ - crate::css::property_metadata::FIRST_LONGHAND_PROPERTY_ID) as usize;+ words[index / 64] |= 1 << (index % 64);+ at += 1;+ }+ words+};++/// Whether `property_id` is a longhand that, declared in the Author Origin, disables native appearance.+pub(crate) fn property_disables_native_appearance(property_id: u16) -> bool {+ let index = usize::from(property_id - crate::css::property_metadata::FIRST_LONGHAND_PROPERTY_ID);+ LONGHANDS_DISABLING_NATIVE_APPEARANCE[index / 64] & (1 << (index % 64)) != 0+}+// https://drafts.csswg.org/css-ui/#appearance-disabling-properties// Certain properties, when declared in the Author Origin, will disable the native appearance of certain widgets.// Specifically, if all the declarations of the Author Origin pertaining to such a widget are cascaded and a cascaded