From 9822db5d3cc680087042316184a937e0741cc9f8 Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Fri, 26 May 2023 22:55:23 +0200 Subject: [PATCH] Further changes required by Servo --- components/script/layout_dom/element.rs | 11 +++++++++++ components/style/bloom.rs | 6 +++--- components/style/dom.rs | 3 +-- components/style/selector_map.rs | 3 +++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/components/script/layout_dom/element.rs b/components/script/layout_dom/element.rs index adbeba7e39d..ebd54df0c31 100644 --- a/components/script/layout_dom/element.rs +++ b/components/script/layout_dom/element.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::dom::attr::AttrHelpersForLayout; use crate::dom::bindings::inheritance::{ CharacterDataTypeId, DocumentFragmentTypeId, ElementTypeId, }; @@ -264,6 +265,16 @@ impl<'dom, LayoutDataType: LayoutDataTrait> style::dom::TElement } } + #[inline(always)] + fn each_attr_name(&self, mut callback: F) + where + F: FnMut(&style::LocalName), + { + for attr in self.element.attrs() { + callback(style::values::GenericAtomIdent::cast(attr.local_name())) + } + } + fn has_dirty_descendants(&self) -> bool { unsafe { self.as_node() diff --git a/components/style/bloom.rs b/components/style/bloom.rs index 87fd0cba5c2..dc722b7bdba 100644 --- a/components/style/bloom.rs +++ b/components/style/bloom.rs @@ -8,6 +8,7 @@ #![deny(missing_docs)] use crate::dom::{SendElement, TElement}; +use crate::LocalName; use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use owning_ref::OwningHandle; use selectors::bloom::BloomFilter; @@ -107,9 +108,8 @@ impl PushedElement { /// We do this for attributes that are very common but not commonly used in /// selectors. #[inline] -#[cfg(feature = "gecko")] -pub fn is_attr_name_excluded_from_filter(atom: &crate::Atom) -> bool { - *atom == atom!("class") || *atom == atom!("id") || *atom == atom!("style") +pub fn is_attr_name_excluded_from_filter(name: &LocalName) -> bool { + return *name == local_name!("class") || *name == local_name!("id") || *name == local_name!("style") } fn each_relevant_element_hash(element: E, mut f: F) diff --git a/components/style/dom.rs b/components/style/dom.rs index c85ff1edaff..308006efd11 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -520,10 +520,9 @@ pub trait TElement: } /// Internal iterator for the attribute names of this element. - #[cfg(feature = "gecko")] fn each_attr_name(&self, callback: F) where - F: FnMut(&AtomIdent); + F: FnMut(&LocalName); /// Internal iterator for the part names that this element exports for a /// given part name. diff --git a/components/style/selector_map.rs b/components/style/selector_map.rs index 48ab5cdbe66..d3dc48e36e4 100644 --- a/components/style/selector_map.rs +++ b/components/style/selector_map.rs @@ -137,7 +137,10 @@ impl SelectorMap { local_name_hash: HashMap::default(), namespace_hash: HashMap::default(), other: SmallVec::new(), + #[cfg(feature = "gecko")] bucket_attributes: static_prefs::pref!("layout.css.bucket-attribute-names.enabled"), + #[cfg(feature = "servo")] + bucket_attributes: false, count: 0, } }