LibWeb: Cache width of "alt" text in ImageBox

We were constantly measuring and re-measuring the "alt" attribute text
of ImageBox layout nodes, even when the alt text didn't change. By
caching this, we avoid a *lot* of repeated text measurement work.
This commit is contained in:
Andreas Kling 2022-09-07 16:46:05 +02:00
parent 514fa83708
commit faf9746244
Notes: sideshowbarker 2024-07-17 23:00:03 +09:00
3 changed files with 21 additions and 1 deletions

View file

@ -78,6 +78,11 @@ void HTMLImageElement::parse_attribute(FlyString const& name, String const& valu
if (name == HTML::AttributeNames::src && !value.is_empty())
m_image_loader.load(document().parse_url(value));
if (name == HTML::AttributeNames::alt) {
if (layout_node())
verify_cast<Layout::ImageBox>(*layout_node()).dom_node_did_update_alt_text({});
}
}
RefPtr<Layout::Node> HTMLImageElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)