CSSImportRule.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/URL.h>
  8. #include <LibWeb/CSS/CSSRule.h>
  9. #include <LibWeb/CSS/CSSStyleSheet.h>
  10. namespace Web::CSS {
  11. class CSSImportRule : public CSSRule {
  12. AK_MAKE_NONCOPYABLE(CSSImportRule);
  13. AK_MAKE_NONMOVABLE(CSSImportRule);
  14. public:
  15. static NonnullRefPtr<CSSImportRule> create(AK::URL url)
  16. {
  17. return adopt_ref(*new CSSImportRule(move(url)));
  18. }
  19. ~CSSImportRule();
  20. const AK::URL& url() const { return m_url; }
  21. bool has_import_result() const { return !m_style_sheet.is_null(); }
  22. RefPtr<CSSStyleSheet> loaded_style_sheet() { return m_style_sheet; }
  23. const RefPtr<CSSStyleSheet> loaded_style_sheet() const { return m_style_sheet; }
  24. void set_style_sheet(const RefPtr<CSSStyleSheet>& style_sheet) { m_style_sheet = style_sheet; }
  25. virtual StringView class_name() const { return "CSSImportRule"; };
  26. virtual Type type() const { return Type::Import; };
  27. private:
  28. explicit CSSImportRule(AK::URL);
  29. virtual String serialized() const override;
  30. AK::URL m_url;
  31. RefPtr<CSSStyleSheet> m_style_sheet;
  32. };
  33. template<>
  34. inline bool CSSRule::fast_is<CSSImportRule>() const { return type() == CSSRule::Type::Import; }
  35. }