summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-10-05 22:30:53 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-06 17:14:22 +0200
commit0264ae23bc3e2a03ce82cf2a5c4b80142862ba82 (patch)
tree32726e9be0f3caaee86cce80f4b17398a0eb1563 /Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
parent228a32effcb214a0baed56d3d007587a495fa96e (diff)
downloadserenity-0264ae23bc3e2a03ce82cf2a5c4b80142862ba82.zip
LibWeb: Make CSS layout lazier
Instead of doing layout synchronously whenever something changes, we now use a basic event loop timer to defer and coalesce relayouts. If you did something that requires a relayout of the page, make sure to call Document::set_needs_layout() and it will get coalesced with all the other layout updates. There's lots of room for improvement here, but this already makes many web pages significantly snappier. :^) Also, note that this exposes a number of layout bugs where we have been relying on multiple relayouts to calculate the correct dimensions for things. Now that we only do a single layout in many cases, these kind of problems are much more noticeable. That should also make them easier to figure out and fix. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
index 14e79b1a87..4d6c32adb1 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
@@ -21,7 +21,7 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, QualifiedName qualif
, m_image_loader(*this)
{
m_image_loader.on_load = [this] {
- this->document().update_layout();
+ this->document().schedule_style_update();
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
dispatch_event(DOM::Event::create(EventNames::load));
});
@@ -29,7 +29,7 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, QualifiedName qualif
m_image_loader.on_fail = [this] {
dbgln("HTMLImageElement: Resource did fail: {}", src());
- this->document().update_layout();
+ this->document().schedule_style_update();
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
dispatch_event(DOM::Event::create(EventNames::error));
});