mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 02:59:45 +00:00
LibWeb: Only invalidate shadow root when style sheet inside changes
We don't have to invalidate style for the entire document when a style sheet changes inside of a shadow root. To make this possible, StyleSheetList now keeps track of which Document-or-ShadowRoot it corresponds to, instead of just tracking the containing Document. This avoids a lot of style recomputation on pages with lots of shadow DOM content (like GitHub).
This commit is contained in:
parent
e71ed67069
commit
4bc3055c0f
Notes:
github-actions[bot]
2024-08-20 14:11:28 +00:00
Author: https://github.com/awesomekling
Commit: 4bc3055c0f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1139
Reviewed-by: https://github.com/AtkinsSJ
5 changed files with 37 additions and 25 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2020-2024, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -17,7 +17,7 @@ class StyleSheetList final : public Bindings::PlatformObject {
|
|||
JS_DECLARE_ALLOCATOR(StyleSheetList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<StyleSheetList> create(DOM::Document&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<StyleSheetList> create(JS::NonnullGCPtr<DOM::Node> document_or_shadow_root);
|
||||
|
||||
void add_a_css_style_sheet(CSS::CSSStyleSheet&);
|
||||
void remove_a_css_style_sheet(CSS::CSSStyleSheet&);
|
||||
|
@ -37,11 +37,14 @@ public:
|
|||
|
||||
virtual Optional<JS::Value> item_value(size_t index) const override;
|
||||
|
||||
DOM::Document& document() { return m_document; }
|
||||
DOM::Document const& document() const { return m_document; }
|
||||
[[nodiscard]] DOM::Document& document();
|
||||
[[nodiscard]] DOM::Document const& document() const;
|
||||
|
||||
[[nodiscard]] DOM::Node& document_or_shadow_root() { return m_document_or_shadow_root; }
|
||||
[[nodiscard]] DOM::Node const& document_or_shadow_root() const { return m_document_or_shadow_root; }
|
||||
|
||||
private:
|
||||
explicit StyleSheetList(DOM::Document&);
|
||||
explicit StyleSheetList(JS::NonnullGCPtr<DOM::Node> document_or_shadow_root);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -49,7 +52,7 @@ private:
|
|||
void add_sheet(CSSStyleSheet&);
|
||||
void remove_sheet(CSSStyleSheet&);
|
||||
|
||||
JS::NonnullGCPtr<DOM::Document> m_document;
|
||||
JS::NonnullGCPtr<DOM::Node> m_document_or_shadow_root;
|
||||
Vector<JS::NonnullGCPtr<CSSStyleSheet>> m_sheets;
|
||||
|
||||
// https://www.w3.org/TR/cssom/#preferred-css-style-sheet-set-name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue