layout: When there is no restyle damage, do not re-layout (#37048)

When the computed restyle damage is empty, do not do a layout. Instead,
just rebuild the display list. In the future, even that can be omitted,
but that requires changes to the compositor.

These kind of relayouts commonly happen when the cursor is moving around
the page and no style rules cause changes to :hover.

Testing: This is covered existing WPT tests and should only have
performance
impacts. Unfortunately there are currently no performance tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Martin Robinson 2025-05-21 17:52:11 +02:00 committed by GitHub
parent 859a0ffbd5
commit 856ffa6ecb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 47 additions and 9 deletions

View file

@ -9,6 +9,9 @@ use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::color::AbsoluteColor;
use style::context::QuirksMode;
use super::attr::Attr;
use super::element::AttributeMutation;
use super::node::NodeDamage;
use crate::dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods;
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use crate::dom::bindings::inheritance::Castable;
@ -174,6 +177,19 @@ impl VirtualMethods for HTMLTableCellElement {
Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods)
}
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation, can_gc: CanGc) {
if let Some(super_type) = self.super_type() {
super_type.attribute_mutated(attr, mutation, can_gc);
}
if matches!(*attr.local_name(), local_name!("colspan")) {
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
}
if matches!(*attr.local_name(), local_name!("rowspan")) {
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
}
}
fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue {
match *local_name {
local_name!("colspan") => {