1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:47:34 +00:00

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
3 changed files with 21 additions and 1 deletions

View file

@ -29,6 +29,8 @@ public:
auto const& image_loader() const { return m_image_loader; }
void dom_node_did_update_alt_text(Badge<HTML::HTMLImageElement>);
private:
// ^BrowsingContext::ViewportClient
virtual void browsing_context_did_set_viewport_rect(Gfx::IntRect const&) final;
@ -37,6 +39,8 @@ private:
int preferred_height() const;
ImageLoader const& m_image_loader;
Optional<float> m_cached_alt_text_width;
};
}