mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
LibWeb: Cache intrinsic sizes across layout runs
This change moves intrinsic sizes cache from LayoutState, which is local to current layout run, to layout nodes, so it could be reused between layout runs. This optimization is possible because we can guarantee that these measurements will remain unchanged unless the style of the element or any of its descendants changes. For now, invalidation is implemented simply by resetting cache on whole ancestors chain once we figured that element needs layout update. The case when layout is invalidated by DOM's structural changes is covered by layout tree invalidation that drops intrinsic sizes cache along with layout nodes. I measured improvement on couple websites: - Mail list on GMail 28ms -> 6ms - GitHub large code page 47ms -> 36ms - Discord chat history 15ms -> 8ms (Time does not include `commit()`)
This commit is contained in:
parent
180a58b3d2
commit
12c6ac78e2
Notes:
github-actions[bot]
2025-03-08 10:46:30 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 12c6ac78e2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3851
13 changed files with 108 additions and 102 deletions
|
@ -2100,7 +2100,7 @@ void finalize_a_cross_document_navigation(GC::Ref<Navigable> navigable, HistoryH
|
|||
// AD-HOC: If we're inside a navigable container, let's trigger a relayout in the container document.
|
||||
// This allows size negotiation between the containing document and SVG documents to happen.
|
||||
if (auto container = navigable->container()) {
|
||||
container->document().set_needs_layout(DOM::SetNeedsLayoutReason::FinalizeACrossDocumentNavigation);
|
||||
container->set_needs_layout_update(DOM::SetNeedsLayoutReason::FinalizeACrossDocumentNavigation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2223,7 +2223,7 @@ void Navigable::set_viewport_size(CSSPixelSize size)
|
|||
if (auto document = active_document()) {
|
||||
// NOTE: Resizing the viewport changes the reference value for viewport-relative CSS lengths.
|
||||
document->invalidate_style(DOM::StyleInvalidationReason::NavigableSetViewportSize);
|
||||
document->set_needs_layout(DOM::SetNeedsLayoutReason::NavigableSetViewportSize);
|
||||
document->set_needs_layout_update(DOM::SetNeedsLayoutReason::NavigableSetViewportSize);
|
||||
}
|
||||
|
||||
if (auto document = active_document()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue