Oriol Brufau 2024-03-18 14:52:40 +01:00 committed by GitHub
parent 94c1f2c992
commit c07484fcb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 235 additions and 491 deletions

View file

@ -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 {

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -126,7 +126,6 @@ impl HTMLStyleElement {
Some(&loader),
css_error_reporter,
doc.quirks_mode(),
self.line_number as u32,
AllowImportRules::Yes,
);

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)