mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-05 00:56:39 +00:00
LibWeb: Add DOM tree version counter
This patch adds a u64 version counter to DOM::Document that increments whenever the tree structure changes (via node insertion or removal), or an element attribute is changed somehow. This will be used as a crude invalidation mechanism for HTMLCollection to cache its elements.
This commit is contained in:
parent
cf7c933312
commit
cf60f52a78
Notes:
sideshowbarker
2024-07-16 22:16:50 +09:00
Author: https://github.com/awesomekling
Commit: cf60f52a78
Pull-request: https://github.com/SerenityOS/serenity/pull/23640
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/tcl3
Reviewed-by: https://github.com/trflynn89
3 changed files with 15 additions and 0 deletions
|
@ -97,6 +97,11 @@ public:
|
|||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> construct_impl(JS::Realm&);
|
||||
virtual ~Document() override;
|
||||
|
||||
// AD-HOC: This number increments whenever a node is added or removed from the document, or an element attribute changes.
|
||||
// It can be used as a crude invalidation mechanism for caches that depend on the DOM structure.
|
||||
u64 dom_tree_version() const { return m_dom_tree_version; }
|
||||
void bump_dom_tree_version() { ++m_dom_tree_version; }
|
||||
|
||||
WebIDL::ExceptionOr<void> populate_with_html_head_and_body();
|
||||
|
||||
JS::GCPtr<Selection::Selection> get_selection() const;
|
||||
|
@ -846,6 +851,8 @@ private:
|
|||
mutable JS::GCPtr<WebIDL::ObservableArray> m_adopted_style_sheets;
|
||||
|
||||
Vector<JS::NonnullGCPtr<DOM::ShadowRoot>> m_shadow_roots;
|
||||
|
||||
u64 m_dom_tree_version { 0 };
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue