StyleSheetList.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/NonnullRefPtrVector.h>
  8. #include <AK/RefCounted.h>
  9. #include <LibWeb/Bindings/Wrappable.h>
  10. #include <LibWeb/CSS/CSSStyleSheet.h>
  11. #include <LibWeb/Forward.h>
  12. namespace Web::CSS {
  13. class StyleSheetList
  14. : public RefCounted<StyleSheetList>
  15. , public Bindings::Wrappable {
  16. public:
  17. using WrapperType = Bindings::StyleSheetListWrapper;
  18. static NonnullRefPtr<StyleSheetList> create(DOM::Document& document)
  19. {
  20. return adopt_ref(*new StyleSheetList(document));
  21. }
  22. void add_sheet(NonnullRefPtr<CSSStyleSheet>);
  23. void remove_sheet(CSSStyleSheet&);
  24. const NonnullRefPtrVector<CSSStyleSheet>& sheets() const { return m_sheets; }
  25. RefPtr<CSSStyleSheet> item(size_t index) const
  26. {
  27. if (index >= m_sheets.size())
  28. return {};
  29. return m_sheets[index];
  30. }
  31. size_t length() const { return m_sheets.size(); }
  32. bool is_supported_property_index(u32) const;
  33. private:
  34. explicit StyleSheetList(DOM::Document&);
  35. DOM::Document& m_document;
  36. NonnullRefPtrVector<CSSStyleSheet> m_sheets;
  37. };
  38. }
  39. namespace Web::Bindings {
  40. StyleSheetListWrapper* wrap(JS::GlobalObject&, CSS::StyleSheetList&);
  41. }