StyleSheet.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <LibWeb/Bindings/PlatformObject.h>
  9. #include <LibWeb/CSS/MediaList.h>
  10. #include <LibWeb/Forward.h>
  11. namespace Web::CSS {
  12. class StyleSheet : public Bindings::PlatformObject {
  13. WEB_PLATFORM_OBJECT(StyleSheet, Bindings::PlatformObject);
  14. public:
  15. virtual ~StyleSheet() = default;
  16. virtual String type() const = 0;
  17. DOM::Element* owner_node() { return m_owner_node; }
  18. void set_owner_node(DOM::Element*);
  19. Optional<String> href() const { return m_location; }
  20. Optional<String> location() const { return m_location; }
  21. void set_location(Optional<String> location) { m_location = move(location); }
  22. String title() const { return m_title; }
  23. Optional<String> title_for_bindings() const;
  24. void set_title(String title) { m_title = move(title); }
  25. void set_type(String type) { m_type_string = move(type); }
  26. MediaList* media() const
  27. {
  28. return m_media;
  29. }
  30. void set_media(String media)
  31. {
  32. m_media->set_media_text(media);
  33. }
  34. bool is_alternate() const { return m_alternate; }
  35. void set_alternate(bool alternate) { m_alternate = alternate; }
  36. void set_origin_clean(bool origin_clean) { m_origin_clean = origin_clean; }
  37. bool disabled() const { return m_disabled; }
  38. void set_disabled(bool disabled) { m_disabled = disabled; }
  39. CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet; }
  40. void set_parent_css_style_sheet(CSSStyleSheet*);
  41. protected:
  42. explicit StyleSheet(JS::Realm&, MediaList& media);
  43. virtual void visit_edges(Cell::Visitor&) override;
  44. JS::NonnullGCPtr<MediaList> m_media;
  45. private:
  46. JS::GCPtr<DOM::Element> m_owner_node;
  47. JS::GCPtr<CSSStyleSheet> m_parent_style_sheet;
  48. Optional<String> m_location;
  49. String m_title;
  50. String m_type_string;
  51. bool m_disabled { false };
  52. bool m_alternate { false };
  53. bool m_origin_clean { true };
  54. };
  55. }