CSSStyleDeclaration.cpp 937 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/CSS/CSSStyleDeclaration.h>
  7. #include <LibWeb/DOM/Element.h>
  8. namespace Web::CSS {
  9. CSSStyleDeclaration::CSSStyleDeclaration(Vector<StyleProperty>&& properties, HashMap<String, StyleProperty>&& custom_properties)
  10. : m_properties(move(properties))
  11. , m_custom_properties(move(custom_properties))
  12. {
  13. }
  14. CSSStyleDeclaration::~CSSStyleDeclaration()
  15. {
  16. }
  17. String CSSStyleDeclaration::item(size_t index) const
  18. {
  19. if (index >= m_properties.size())
  20. return {};
  21. return CSS::string_from_property_id(m_properties[index].property_id);
  22. }
  23. ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element)
  24. : CSSStyleDeclaration({}, {})
  25. , m_element(element.make_weak_ptr<DOM::Element>())
  26. {
  27. }
  28. ElementInlineCSSStyleDeclaration::~ElementInlineCSSStyleDeclaration()
  29. {
  30. }
  31. }