mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
script: Use atom comparison in more places, especially for attributes.
75% improvement in style recalc for Guardians of the Galaxy.
This commit is contained in:
parent
61642d64b5
commit
874db26104
32 changed files with 300 additions and 147 deletions
|
@ -223,8 +223,7 @@ impl StyleSharingCandidate {
|
|||
style: style,
|
||||
parent_style: parent_style,
|
||||
local_name: element.get_local_name().clone(),
|
||||
class: element.get_attr(&Null, "class")
|
||||
.map(|string| string.to_string()),
|
||||
class: element.get_attr(&Null, &satom!("class")).map(|string| string.to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -232,7 +231,7 @@ impl StyleSharingCandidate {
|
|||
if *element.get_local_name() != self.local_name {
|
||||
return false
|
||||
}
|
||||
match (&self.class, element.get_attr(&Null, "class")) {
|
||||
match (&self.class, element.get_attr(&Null, &satom!("class"))) {
|
||||
(&None, Some(_)) | (&Some(_), None) => return false,
|
||||
(&Some(ref this_class), Some(element_class)) if element_class != this_class.as_slice() => {
|
||||
return false
|
||||
|
@ -454,7 +453,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
|||
}
|
||||
let ok = {
|
||||
let element = self.as_element();
|
||||
element.style_attribute().is_none() && element.get_attr(&Null, "id").is_none()
|
||||
element.style_attribute().is_none() && element.get_attr(&Null, &satom!("id")).is_none()
|
||||
};
|
||||
if !ok {
|
||||
return CannotShare(false)
|
||||
|
@ -501,7 +500,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
|||
|
||||
// TODO: case-sensitivity depends on the document type and quirks mode
|
||||
element
|
||||
.get_attr(&Null, "class")
|
||||
.get_attr(&Null, &satom!("class"))
|
||||
.map(|attr| {
|
||||
for c in attr.split(style::SELECTOR_WHITESPACE) {
|
||||
bf.insert(&c);
|
||||
|
@ -520,7 +519,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
|||
|
||||
// TODO: case-sensitivity depends on the document type and quirks mode
|
||||
element
|
||||
.get_attr(&Null, "class")
|
||||
.get_attr(&Null, &satom!("class"))
|
||||
.map(|attr| {
|
||||
for c in attr.split(style::SELECTOR_WHITESPACE) {
|
||||
bf.remove(&c);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue