mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb/CSS: Allow CSSImportRule's document to be null on construction
It's possible to parse an `@import` rule that isn't attached to a document. We only actually need it to have one when fetching the linked style sheet, and that should only happen when the CSSImportRule is attached to a document. So, we can just accept a null pointer when constructing it. We relied on that Document to get the Realm, so pass that in as a separate parameter.
This commit is contained in:
parent
a8ab4d64c4
commit
1abc628cd8
Notes:
github-actions[bot]
2025-04-09 17:47:38 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/1abc628cd8c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4285 Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 8 additions and 9 deletions
|
@ -23,17 +23,16 @@ namespace Web::CSS {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(CSSImportRule);
|
||||
|
||||
GC::Ref<CSSImportRule> CSSImportRule::create(::URL::URL url, DOM::Document& document, RefPtr<Supports> supports, Vector<NonnullRefPtr<MediaQuery>> media_query_list)
|
||||
GC::Ref<CSSImportRule> CSSImportRule::create(JS::Realm& realm, ::URL::URL url, GC::Ptr<DOM::Document> document, RefPtr<Supports> supports, Vector<NonnullRefPtr<MediaQuery>> media_query_list)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return realm.create<CSSImportRule>(move(url), document, supports, move(media_query_list));
|
||||
return realm.create<CSSImportRule>(realm, move(url), document, move(supports), move(media_query_list));
|
||||
}
|
||||
|
||||
CSSImportRule::CSSImportRule(::URL::URL url, DOM::Document& document, RefPtr<Supports> supports, Vector<NonnullRefPtr<MediaQuery>> media_query_list)
|
||||
: CSSRule(document.realm(), Type::Import)
|
||||
CSSImportRule::CSSImportRule(JS::Realm& realm, ::URL::URL url, GC::Ptr<DOM::Document> document, RefPtr<Supports> supports, Vector<NonnullRefPtr<MediaQuery>> media_query_list)
|
||||
: CSSRule(realm, Type::Import)
|
||||
, m_url(move(url))
|
||||
, m_document(document)
|
||||
, m_supports(supports)
|
||||
, m_supports(move(supports))
|
||||
, m_media_query_list(move(media_query_list))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class CSSImportRule final
|
|||
GC_DECLARE_ALLOCATOR(CSSImportRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<CSSImportRule> create(::URL::URL, DOM::Document&, RefPtr<Supports>, Vector<NonnullRefPtr<MediaQuery>>);
|
||||
[[nodiscard]] static GC::Ref<CSSImportRule> create(JS::Realm&, ::URL::URL, GC::Ptr<DOM::Document>, RefPtr<Supports>, Vector<NonnullRefPtr<MediaQuery>>);
|
||||
|
||||
virtual ~CSSImportRule() = default;
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
Optional<String> supports_text() const;
|
||||
|
||||
private:
|
||||
CSSImportRule(::URL::URL, DOM::Document&, RefPtr<Supports>, Vector<NonnullRefPtr<MediaQuery>>);
|
||||
CSSImportRule(JS::Realm&, ::URL::URL, GC::Ptr<DOM::Document>, RefPtr<Supports>, Vector<NonnullRefPtr<MediaQuery>>);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
|
|
@ -198,7 +198,7 @@ GC::Ptr<CSSImportRule> Parser::convert_to_import_rule(AtRule const& rule)
|
|||
return {};
|
||||
}
|
||||
|
||||
return CSSImportRule::create(resolved_url.release_value(), const_cast<DOM::Document&>(*document()), supports, move(media_query_list));
|
||||
return CSSImportRule::create(realm(), resolved_url.release_value(), const_cast<DOM::Document*>(m_document.ptr()), supports, move(media_query_list));
|
||||
}
|
||||
|
||||
Optional<FlyString> Parser::parse_layer_name(TokenStream<ComponentValue>& tokens, AllowBlankLayerName allow_blank_layer_name)
|
||||
|
|
Loading…
Add table
Reference in a new issue