ResolvedCSSStyleDeclaration.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2021-2023, Andreas Kling <andreas@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/CSS/CSSStyleDeclaration.h>
  8. #include <LibWeb/CSS/Selector.h>
  9. namespace Web::CSS {
  10. class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration {
  11. WEB_PLATFORM_OBJECT(ResolvedCSSStyleDeclaration, CSSStyleDeclaration);
  12. JS_DECLARE_ALLOCATOR(ResolvedCSSStyleDeclaration);
  13. public:
  14. [[nodiscard]] static JS::NonnullGCPtr<ResolvedCSSStyleDeclaration> create(DOM::Element&, Optional<Selector::PseudoElement::Type> = {});
  15. virtual ~ResolvedCSSStyleDeclaration() override = default;
  16. virtual size_t length() const override;
  17. virtual String item(size_t index) const override;
  18. virtual Optional<StyleProperty> property(PropertyID) const override;
  19. virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
  20. virtual WebIDL::ExceptionOr<void> set_property(StringView property_name, StringView css_text, StringView priority) override;
  21. virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) override;
  22. virtual WebIDL::ExceptionOr<String> remove_property(StringView property_name) override;
  23. virtual String serialized() const override;
  24. virtual WebIDL::ExceptionOr<void> set_css_text(StringView) override;
  25. private:
  26. explicit ResolvedCSSStyleDeclaration(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>);
  27. virtual void visit_edges(Cell::Visitor&) override;
  28. RefPtr<CSSStyleValue const> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
  29. JS::NonnullGCPtr<DOM::Element> m_element;
  30. Optional<CSS::Selector::PseudoElement::Type> m_pseudo_element;
  31. };
  32. }