mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:18:11 +00:00
LibWeb: Don't invalidate style for entire document on attribute change
We now only invalidate the style of the context element and all of its descendants. It's still very aggressive, but much less than before. Note that this will need to become a lot smarter once we implement the CSS :has() selector.
This commit is contained in:
parent
5530040b3c
commit
ccd72a2add
2 changed files with 15 additions and 8 deletions
|
@ -123,8 +123,7 @@ WebIDL::ExceptionOr<void> Element::set_attribute(FlyString const& name, String c
|
|||
|
||||
parse_attribute(attribute->local_name(), value);
|
||||
|
||||
// FIXME: Invalidate less.
|
||||
document().invalidate_style();
|
||||
invalidate_style_after_attribute_change(name);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -191,8 +190,7 @@ void Element::remove_attribute(FlyString const& name)
|
|||
|
||||
did_remove_attribute(name);
|
||||
|
||||
// FIXME: Invalidate less.
|
||||
document().invalidate_style();
|
||||
invalidate_style_after_attribute_change(name);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-hasattribute
|
||||
|
@ -225,8 +223,7 @@ WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optio
|
|||
|
||||
parse_attribute(new_attribute->local_name(), "");
|
||||
|
||||
// FIXME: Invalidate less.
|
||||
document().invalidate_style();
|
||||
invalidate_style_after_attribute_change(name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -241,8 +238,7 @@ WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optio
|
|||
|
||||
did_remove_attribute(name);
|
||||
|
||||
// FIXME: Invalidate less.
|
||||
document().invalidate_style();
|
||||
invalidate_style_after_attribute_change(name);
|
||||
}
|
||||
|
||||
// 6. Return true.
|
||||
|
@ -980,4 +976,13 @@ void Element::scroll_into_view(Optional<Variant<bool, ScrollIntoViewOptions>> ar
|
|||
// FIXME: 8. Optionally perform some other action that brings the element to the user’s attention.
|
||||
}
|
||||
|
||||
void Element::invalidate_style_after_attribute_change(FlyString const& attribute_name)
|
||||
{
|
||||
// FIXME: Only invalidate if the attribute can actually affect style.
|
||||
(void)attribute_name;
|
||||
|
||||
// FIXME: This will need to become smarter when we implement the :has() selector.
|
||||
invalidate_style();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue