ResolvedCSSStyleDeclaration.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. GC_DECLARE_ALLOCATOR(ResolvedCSSStyleDeclaration);
  13. public:
  14. [[nodiscard]] static GC::Ref<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 Optional<StyleProperty> custom_property(FlyString const& custom_property_name) const override;
  20. virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
  21. virtual WebIDL::ExceptionOr<void> set_property(StringView property_name, StringView css_text, StringView priority) override;
  22. virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) override;
  23. virtual WebIDL::ExceptionOr<String> remove_property(StringView property_name) override;
  24. virtual String serialized() const override;
  25. virtual WebIDL::ExceptionOr<void> set_css_text(StringView) override;
  26. private:
  27. explicit ResolvedCSSStyleDeclaration(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>);
  28. virtual void visit_edges(Cell::Visitor&) override;
  29. RefPtr<CSSStyleValue const> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
  30. GC::Ref<DOM::Element> m_element;
  31. Optional<CSS::Selector::PseudoElement::Type> m_pseudo_element;
  32. };
  33. }