mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +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
|
@ -50,26 +50,6 @@ enum class QuirksMode {
|
|||
Yes
|
||||
};
|
||||
|
||||
#define ENUMERATE_SET_NEEDS_LAYOUT_REASONS(X) \
|
||||
X(CharacterDataReplaceData) \
|
||||
X(FinalizeACrossDocumentNavigation) \
|
||||
X(HTMLImageElementReactToChangesInTheEnvironment) \
|
||||
X(HTMLImageElementUpdateTheImageData) \
|
||||
X(HTMLVideoElementSetVideoTrack) \
|
||||
X(KeyframeEffect) \
|
||||
X(LayoutTreeUpdate) \
|
||||
X(NavigableSetViewportSize) \
|
||||
X(SVGImageElementFetchTheDocument) \
|
||||
X(StyleChange)
|
||||
|
||||
enum class SetNeedsLayoutReason {
|
||||
#define ENUMERATE_SET_NEEDS_LAYOUT_REASON(e) e,
|
||||
ENUMERATE_SET_NEEDS_LAYOUT_REASONS(ENUMERATE_SET_NEEDS_LAYOUT_REASON)
|
||||
#undef ENUMERATE_SET_NEEDS_LAYOUT_REASON
|
||||
};
|
||||
|
||||
[[nodiscard]] StringView to_string(SetNeedsLayoutReason);
|
||||
|
||||
#define ENUMERATE_INVALIDATE_LAYOUT_TREE_REASONS(X) \
|
||||
X(DocumentAddAnElementToTheTopLayer) \
|
||||
X(DocumentRequestAnElementToBeRemovedFromTheTopLayer) \
|
||||
|
@ -358,8 +338,6 @@ public:
|
|||
void update_paint_and_hit_testing_properties_if_needed();
|
||||
void update_animated_style_if_needed();
|
||||
|
||||
void set_needs_layout(SetNeedsLayoutReason);
|
||||
|
||||
void invalidate_layout_tree(InvalidateLayoutTreeReason);
|
||||
void invalidate_stacking_context_tree();
|
||||
|
||||
|
@ -1076,8 +1054,6 @@ private:
|
|||
// Used by evaluate_media_queries_and_report_changes().
|
||||
Vector<WeakPtr<CSS::MediaQueryList>> m_media_query_lists;
|
||||
|
||||
bool m_needs_layout { false };
|
||||
|
||||
bool m_needs_full_style_update { false };
|
||||
bool m_needs_full_layout_tree_update { false };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue