CSSImportRule.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. namespace Web::CSS {
  10. class CSSImportRule : public CSSRule {
  11. AK_MAKE_NONCOPYABLE(CSSImportRule);
  12. AK_MAKE_NONMOVABLE(CSSImportRule);
  13. public:
  14. static NonnullRefPtr<CSSImportRule> create(URL url)
  15. {
  16. return adopt_ref(*new CSSImportRule(move(url)));
  17. }
  18. ~CSSImportRule();
  19. const URL& url() const { return m_url; }
  20. bool has_import_result() const { return !m_style_sheet.is_null(); }
  21. RefPtr<CSSStyleSheet> loaded_style_sheet() { return m_style_sheet; }
  22. const RefPtr<CSSStyleSheet> loaded_style_sheet() const { return m_style_sheet; }
  23. void set_style_sheet(const RefPtr<CSSStyleSheet>& style_sheet) { m_style_sheet = style_sheet; }
  24. virtual StringView class_name() const { return "CSSImportRule"; };
  25. virtual Type type() const { return Type::Import; };
  26. private:
  27. explicit CSSImportRule(URL);
  28. URL m_url;
  29. RefPtr<CSSStyleSheet> m_style_sheet;
  30. };
  31. template<>
  32. inline bool CSSRule::fast_is<CSSImportRule>() const { return type() == CSSRule::Type::Import; }
  33. }