2021-02-21 18:36:34 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-21 18:36:34 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/URL.h>
|
|
|
|
#include <LibWeb/CSS/CSSRule.h>
|
2021-09-30 22:57:35 +02:00
|
|
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
2021-02-21 18:36:34 +02:00
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
class CSSImportRule : public CSSRule {
|
|
|
|
AK_MAKE_NONCOPYABLE(CSSImportRule);
|
|
|
|
AK_MAKE_NONMOVABLE(CSSImportRule);
|
|
|
|
|
|
|
|
public:
|
2021-09-13 00:33:23 +03:00
|
|
|
static NonnullRefPtr<CSSImportRule> create(AK::URL url)
|
2021-02-21 18:36:34 +02:00
|
|
|
{
|
2021-04-23 16:46:57 +02:00
|
|
|
return adopt_ref(*new CSSImportRule(move(url)));
|
2021-02-21 18:36:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
~CSSImportRule();
|
|
|
|
|
2021-09-13 00:33:23 +03:00
|
|
|
const AK::URL& url() const { return m_url; }
|
2021-02-21 18:36:34 +02:00
|
|
|
|
2021-02-21 18:44:17 +02:00
|
|
|
bool has_import_result() const { return !m_style_sheet.is_null(); }
|
2021-03-07 16:14:04 +01:00
|
|
|
RefPtr<CSSStyleSheet> loaded_style_sheet() { return m_style_sheet; }
|
|
|
|
const RefPtr<CSSStyleSheet> loaded_style_sheet() const { return m_style_sheet; }
|
2021-04-03 11:55:37 +02:00
|
|
|
void set_style_sheet(const RefPtr<CSSStyleSheet>& style_sheet) { m_style_sheet = style_sheet; }
|
2021-02-21 18:44:17 +02:00
|
|
|
|
2021-02-21 18:36:34 +02:00
|
|
|
virtual StringView class_name() const { return "CSSImportRule"; };
|
|
|
|
virtual Type type() const { return Type::Import; };
|
|
|
|
|
|
|
|
private:
|
2021-09-13 00:33:23 +03:00
|
|
|
explicit CSSImportRule(AK::URL);
|
2021-02-21 18:36:34 +02:00
|
|
|
|
2021-10-01 19:57:45 +02:00
|
|
|
virtual String serialized() const override;
|
|
|
|
|
2021-09-13 00:33:23 +03:00
|
|
|
AK::URL m_url;
|
2021-03-07 16:14:04 +01:00
|
|
|
RefPtr<CSSStyleSheet> m_style_sheet;
|
2021-02-21 18:36:34 +02:00
|
|
|
};
|
|
|
|
|
2021-03-18 21:50:52 +01:00
|
|
|
template<>
|
|
|
|
inline bool CSSRule::fast_is<CSSImportRule>() const { return type() == CSSRule::Type::Import; }
|
|
|
|
|
2021-02-21 18:36:34 +02:00
|
|
|
}
|