StyleSheetList.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/CSS/StyleSheetList.h>
  7. namespace Web::CSS {
  8. void StyleSheetList::add_sheet(NonnullRefPtr<CSSStyleSheet> sheet)
  9. {
  10. VERIFY(!m_sheets.contains_slow(sheet));
  11. m_sheets.append(move(sheet));
  12. }
  13. void StyleSheetList::remove_sheet(CSSStyleSheet& sheet)
  14. {
  15. m_sheets.remove_first_matching([&](auto& entry) { return &*entry == &sheet; });
  16. }
  17. StyleSheetList::StyleSheetList(DOM::Document& document)
  18. : m_document(document)
  19. {
  20. }
  21. // https://www.w3.org/TR/cssom/#ref-for-dfn-supported-property-indices%E2%91%A1
  22. bool StyleSheetList::is_supported_property_index(u32 index) const
  23. {
  24. // The object’s supported property indices are the numbers in the range zero to one less than the number of CSS style sheets represented by the collection.
  25. // If there are no such CSS style sheets, then there are no supported property indices.
  26. if (m_sheets.is_empty())
  27. return false;
  28. return index < m_sheets.size();
  29. }
  30. }