diff options
author | Oriol Brufau <obrufau@igalia.com> | 2024-03-18 14:52:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-18 13:52:40 +0000 |
commit | c07484fcb605a9ab0a3f9fba4cb4ddd24d89cb87 (patch) | |
tree | 3328bfaa0552bee8f6d7833b8e07a06b2b5ebedc /components/script/dom | |
parent | 94c1f2c99229fde82e09ae5d8e06792ea9d90787 (diff) | |
download | servo-c07484fcb605a9ab0a3f9fba4cb4ddd24d89cb87.tar.gz servo-c07484fcb605a9ab0a3f9fba4cb4ddd24d89cb87.zip |
Update Stylo to 2023-09-01 (#31609)
* Update Stylo to 2023-09-01
* Fixup for https://phabricator.services.mozilla.com/D184929
* Fixup for https://phabricator.services.mozilla.com/D184526
* Fixup for https://phabricator.services.mozilla.com/D184525
* Fixup for https://phabricator.services.mozilla.com/D185154
* Fixup for https://phabricator.services.mozilla.com/D184685
* Fixup for https://phabricator.services.mozilla.com/D185916
* Fixup for https://phabricator.services.mozilla.com/D185492
* Fixup for https://phabricator.services.mozilla.com/D186626
* Update test expectations
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/element.rs | 29 | ||||
-rw-r--r-- | components/script/dom/htmlbodyelement.rs | 10 | ||||
-rw-r--r-- | components/script/dom/htmlfontelement.rs | 6 | ||||
-rw-r--r-- | components/script/dom/htmlhrelement.rs | 6 | ||||
-rw-r--r-- | components/script/dom/htmlstyleelement.rs | 1 | ||||
-rw-r--r-- | components/script/dom/htmltablecellelement.rs | 6 | ||||
-rw-r--r-- | components/script/dom/htmltableelement.rs | 6 | ||||
-rw-r--r-- | components/script/dom/htmltablerowelement.rs | 6 | ||||
-rw-r--r-- | components/script/dom/htmltablesectionelement.rs | 6 | ||||
-rw-r--r-- | components/script/dom/node.rs | 6 |
10 files changed, 55 insertions, 27 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index da0ad78d91e..9ddde5d0d86 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -30,6 +30,7 @@ use net_traits::request::CorsSettings; use net_traits::ReferrerPolicy; use script_layout_interface::message::ReflowGoal; use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; +use selectors::bloom::{BloomFilter, BLOOM_HASH_MASK}; use selectors::matching::{ElementSelectorFlags, MatchingContext}; use selectors::sink::Push; use selectors::Element as SelectorsElement; @@ -3393,6 +3394,34 @@ impl<'a> SelectorsElement for DomRoot<Element> { } } } + + fn add_element_unique_hashes(&self, filter: &mut BloomFilter) -> bool { + let mut f = |hash| filter.insert_hash(hash & BLOOM_HASH_MASK); + + // We can't use style::bloom::each_relevant_element_hash(*self, f) + // since DomRoot<Element> doesn't have the TElement trait. + f(Element::local_name(self).get_hash()); + f(Element::namespace(self).get_hash()); + + if let Some(ref id) = *self.id_attribute.borrow() { + f(id.get_hash()); + } + + if let Some(attr) = self.get_attribute(&ns!(), &local_name!("class")) { + for class in attr.value().as_tokens() { + f(AtomIdent::cast(class).get_hash()); + } + } + + for attr in self.attrs.borrow().iter() { + let name = style::values::GenericAtomIdent::cast(attr.local_name()); + if !style::bloom::is_attr_name_excluded_from_filter(name) { + f(name.get_hash()); + } + } + + true + } } impl Element { diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 0ecd130914f..64f482f054c 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -2,7 +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 cssparser::RGBA; +use cssparser::RgbaLegacy; use dom_struct::dom_struct; use embedder_traits::EmbedderMsg; use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; @@ -100,20 +100,20 @@ impl HTMLBodyElementMethods for HTMLBodyElement { } pub trait HTMLBodyElementLayoutHelpers { - fn get_background_color(self) -> Option<RGBA>; - fn get_color(self) -> Option<RGBA>; + fn get_background_color(self) -> Option<RgbaLegacy>; + fn get_color(self) -> Option<RgbaLegacy>; fn get_background(self) -> Option<ServoUrl>; } impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> { - fn get_background_color(self) -> Option<RGBA> { + fn get_background_color(self) -> Option<RgbaLegacy> { self.upcast::<Element>() .get_attr_for_layout(&ns!(), &local_name!("bgcolor")) .and_then(AttrValue::as_color) .cloned() } - fn get_color(self) -> Option<RGBA> { + fn get_color(self) -> Option<RgbaLegacy> { self.upcast::<Element>() .get_attr_for_layout(&ns!(), &local_name!("text")) .and_then(AttrValue::as_color) diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index fb1fa3f53a9..9bdd32bb5c4 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -2,7 +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 cssparser::RGBA; +use cssparser::RgbaLegacy; use dom_struct::dom_struct; use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; use js::rust::HandleObject; @@ -105,13 +105,13 @@ impl VirtualMethods for HTMLFontElement { } pub trait HTMLFontElementLayoutHelpers { - fn get_color(self) -> Option<RGBA>; + fn get_color(self) -> Option<RgbaLegacy>; fn get_face(self) -> Option<Atom>; fn get_size(self) -> Option<u32>; } impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> { - fn get_color(self) -> Option<RGBA> { + fn get_color(self) -> Option<RgbaLegacy> { self.upcast::<Element>() .get_attr_for_layout(&ns!(), &local_name!("color")) .and_then(AttrValue::as_color) diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index f28a592000b..1a63747aa57 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -2,7 +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 cssparser::RGBA; +use cssparser::RgbaLegacy; use dom_struct::dom_struct; use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; use js::rust::HandleObject; @@ -70,12 +70,12 @@ impl HTMLHRElementMethods for HTMLHRElement { } pub trait HTMLHRLayoutHelpers { - fn get_color(self) -> Option<RGBA>; + fn get_color(self) -> Option<RgbaLegacy>; fn get_width(self) -> LengthOrPercentageOrAuto; } impl HTMLHRLayoutHelpers for LayoutDom<'_, HTMLHRElement> { - fn get_color(self) -> Option<RGBA> { + fn get_color(self) -> Option<RgbaLegacy> { self.upcast::<Element>() .get_attr_for_layout(&ns!(), &local_name!("color")) .and_then(AttrValue::as_color) diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index a42355167e9..c298db7398e 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -126,7 +126,6 @@ impl HTMLStyleElement { Some(&loader), css_error_reporter, doc.quirks_mode(), - self.line_number as u32, AllowImportRules::Yes, ); diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index c2cb14afb34..2b4406feb95 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -2,7 +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 cssparser::RGBA; +use cssparser::RgbaLegacy; use dom_struct::dom_struct; use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; use js::rust::HandleObject; @@ -106,7 +106,7 @@ impl HTMLTableCellElementMethods for HTMLTableCellElement { } pub trait HTMLTableCellElementLayoutHelpers<'dom> { - fn get_background_color(self) -> Option<RGBA>; + fn get_background_color(self) -> Option<RgbaLegacy>; fn get_colspan(self) -> Option<u32>; fn get_rowspan(self) -> Option<u32>; fn get_table(self) -> Option<LayoutDom<'dom, HTMLTableElement>>; @@ -114,7 +114,7 @@ pub trait HTMLTableCellElementLayoutHelpers<'dom> { } impl<'dom> HTMLTableCellElementLayoutHelpers<'dom> for LayoutDom<'dom, HTMLTableCellElement> { - fn get_background_color(self) -> Option<RGBA> { + fn get_background_color(self) -> Option<RgbaLegacy> { self.upcast::<Element>() .get_attr_for_layout(&ns!(), &local_name!("bgcolor")) .and_then(AttrValue::as_color) diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index 4c50349cf70..93c40a5e930 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -4,7 +4,7 @@ use std::cell::Cell; -use cssparser::RGBA; +use cssparser::RgbaLegacy; use dom_struct::dom_struct; use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; use js::rust::HandleObject; @@ -425,7 +425,7 @@ impl HTMLTableElementMethods for HTMLTableElement { } pub trait HTMLTableElementLayoutHelpers { - fn get_background_color(self) -> Option<RGBA>; + fn get_background_color(self) -> Option<RgbaLegacy>; fn get_border(self) -> Option<u32>; fn get_cellpadding(self) -> Option<u32>; fn get_cellspacing(self) -> Option<u32>; @@ -433,7 +433,7 @@ pub trait HTMLTableElementLayoutHelpers { } impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> { - fn get_background_color(self) -> Option<RGBA> { + fn get_background_color(self) -> Option<RgbaLegacy> { self.upcast::<Element>() .get_attr_for_layout(&ns!(), &local_name!("bgcolor")) .and_then(AttrValue::as_color) diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index a5fe4e2fec6..c400ac8011a 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -2,7 +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 cssparser::RGBA; +use cssparser::RgbaLegacy; use dom_struct::dom_struct; use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; use js::rust::HandleObject; @@ -153,11 +153,11 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement { } pub trait HTMLTableRowElementLayoutHelpers { - fn get_background_color(self) -> Option<RGBA>; + fn get_background_color(self) -> Option<RgbaLegacy>; } impl HTMLTableRowElementLayoutHelpers for LayoutDom<'_, HTMLTableRowElement> { - fn get_background_color(self) -> Option<RGBA> { + fn get_background_color(self) -> Option<RgbaLegacy> { self.upcast::<Element>() .get_attr_for_layout(&ns!(), &local_name!("bgcolor")) .and_then(AttrValue::as_color) diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index 9daf6393154..6dd042a0187 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -2,7 +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 cssparser::RGBA; +use cssparser::RgbaLegacy; use dom_struct::dom_struct; use html5ever::{local_name, namespace_url, ns, LocalName, Prefix}; use js::rust::HandleObject; @@ -91,11 +91,11 @@ impl HTMLTableSectionElementMethods for HTMLTableSectionElement { } pub trait HTMLTableSectionElementLayoutHelpers { - fn get_background_color(self) -> Option<RGBA>; + fn get_background_color(self) -> Option<RgbaLegacy>; } impl HTMLTableSectionElementLayoutHelpers for LayoutDom<'_, HTMLTableSectionElement> { - fn get_background_color(self) -> Option<RGBA> { + fn get_background_color(self) -> Option<RgbaLegacy> { self.upcast::<Element>() .get_attr_for_layout(&ns!(), &local_name!("bgcolor")) .and_then(AttrValue::as_color) diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 9e6f4feeee9..ee1e563ef1d 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -31,7 +31,7 @@ use script_layout_interface::{ }; use script_traits::{DocumentActivity, UntrustedNodeAddress}; use selectors::matching::{ - matches_selector_list, IgnoreNthChildForInvalidation, MatchingContext, MatchingMode, + matches_selector_list, MatchingContext, MatchingForInvalidation, MatchingMode, NeedsSelectorFlags, }; use selectors::parser::SelectorList; @@ -481,7 +481,7 @@ impl<'a> Iterator for QuerySelectorIterator { &mut nth_index_cache, node.owner_doc().quirks_mode(), NeedsSelectorFlags::No, - IgnoreNthChildForInvalidation::No, + MatchingForInvalidation::No, ); if let Some(element) = DomRoot::downcast(node) { if matches_selector_list(selectors, &element, &mut ctx) { @@ -978,7 +978,7 @@ impl Node { &mut nth_index_cache, doc.quirks_mode(), NeedsSelectorFlags::No, - IgnoreNthChildForInvalidation::No, + MatchingForInvalidation::No, ); Ok(self .traverse_preorder(ShadowIncluding::No) |