StyleSheet.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/RefCounted.h>
  9. #include <LibWeb/Bindings/Wrappable.h>
  10. #include <LibWeb/Forward.h>
  11. namespace Web::CSS {
  12. class StyleSheet
  13. : public RefCounted<StyleSheet>
  14. , public Bindings::Wrappable {
  15. public:
  16. using WrapperType = Bindings::StyleSheetWrapper;
  17. virtual ~StyleSheet() = default;
  18. virtual String type() const = 0;
  19. DOM::Element* owner_node() { return m_owner_node; }
  20. void set_owner_node(DOM::Element*);
  21. String href() const { return m_location; }
  22. String location() const { return m_location; }
  23. void set_location(String location) { m_location = move(location); }
  24. String title() const { return m_title; }
  25. void set_title(String title) { m_title = move(title); }
  26. void set_type(String type) { m_type_string = move(type); }
  27. void set_media(String media) { m_media_string = move(media); }
  28. bool is_alternate() const { return m_alternate; }
  29. void set_alternate(bool alternate) { m_alternate = alternate; }
  30. void set_origin_clean(bool origin_clean) { m_origin_clean = origin_clean; }
  31. bool disabled() const { return m_disabled; }
  32. void set_disabled(bool disabled) { m_disabled = disabled; }
  33. CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet; }
  34. void set_parent_css_style_sheet(CSSStyleSheet*);
  35. protected:
  36. StyleSheet() = default;
  37. private:
  38. WeakPtr<DOM::Element> m_owner_node;
  39. WeakPtr<CSSStyleSheet> m_parent_style_sheet;
  40. String m_location;
  41. String m_title;
  42. String m_type_string;
  43. String m_media_string;
  44. bool m_disabled { false };
  45. bool m_alternate { false };
  46. bool m_origin_clean { true };
  47. };
  48. }