mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-20 19:00:25 +00:00
...instead of returning the one from its associated style sheet.
This reverts 848a250b29 where I made
`CSSImportRule.media` nullable.
CSSImportRule may not have an associated style sheet, because of not
matching a supports condition, or just failing to load the URL.
Regardless of whether we do or not, the expected (non-spec) behaviour
is that we should return a MediaList always, which matches the media
queries specified on the `@import` rule.
67 lines
2.1 KiB
C++
67 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/CSS/CSSRule.h>
|
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
|
#include <LibWeb/CSS/URL.h>
|
|
#include <LibWeb/DOM/DocumentLoadEventDelayer.h>
|
|
#include <LibWeb/Export.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
class WEB_API CSSImportRule final
|
|
: public CSSRule {
|
|
WEB_PLATFORM_OBJECT(CSSImportRule, CSSRule);
|
|
GC_DECLARE_ALLOCATOR(CSSImportRule);
|
|
|
|
public:
|
|
[[nodiscard]] static GC::Ref<CSSImportRule> create(JS::Realm&, URL, GC::Ptr<DOM::Document>, Optional<FlyString> layer, RefPtr<Supports>, GC::Ref<MediaList>);
|
|
|
|
virtual ~CSSImportRule();
|
|
|
|
URL const& url() const { return m_url; }
|
|
String href() const { return m_url.url(); }
|
|
|
|
CSSStyleSheet* loaded_style_sheet() { return m_style_sheet; }
|
|
CSSStyleSheet const* loaded_style_sheet() const { return m_style_sheet; }
|
|
GC::Ref<MediaList> media() const;
|
|
CSSStyleSheet* style_sheet_for_bindings() { return m_style_sheet; }
|
|
|
|
Optional<FlyString> layer_name() const;
|
|
Optional<String> supports_text() const;
|
|
|
|
private:
|
|
CSSImportRule(JS::Realm&, URL, GC::Ptr<DOM::Document>, Optional<FlyString>, RefPtr<Supports>, GC::Ref<MediaList>);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
virtual void dump(StringBuilder&, int indent_levels) const override;
|
|
|
|
virtual void set_parent_style_sheet(CSSStyleSheet*) override;
|
|
|
|
virtual String serialized() const override;
|
|
|
|
void fetch();
|
|
void set_style_sheet(GC::Ref<CSSStyleSheet>);
|
|
|
|
URL m_url;
|
|
GC::Ptr<DOM::Document> m_document;
|
|
Optional<FlyString> m_layer;
|
|
RefPtr<Supports> m_supports;
|
|
GC::Ref<MediaList> m_media;
|
|
GC::Ptr<CSSStyleSheet> m_style_sheet;
|
|
Optional<DOM::DocumentLoadEventDelayer> m_document_load_event_delayer;
|
|
};
|
|
|
|
template<>
|
|
inline bool CSSRule::fast_is<CSSImportRule>() const { return type() == CSSRule::Type::Import; }
|
|
|
|
}
|