StyleSheet.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 DeprecatedString type() const = 0;
  17. DOM::Element* owner_node() { return m_owner_node; }
  18. void set_owner_node(DOM::Element*);
  19. DeprecatedString href() const { return m_location; }
  20. DeprecatedString location() const { return m_location; }
  21. void set_location(DeprecatedString location) { m_location = move(location); }
  22. DeprecatedString title() const { return m_title; }
  23. void set_title(DeprecatedString title) { m_title = move(title); }
  24. void set_type(DeprecatedString type) { m_type_string = move(type); }
  25. MediaList* media() const
  26. {
  27. return m_media;
  28. }
  29. void set_media(DeprecatedString media)
  30. {
  31. m_media->set_media_text(media);
  32. }
  33. bool is_alternate() const { return m_alternate; }
  34. void set_alternate(bool alternate) { m_alternate = alternate; }
  35. void set_origin_clean(bool origin_clean) { m_origin_clean = origin_clean; }
  36. bool disabled() const { return m_disabled; }
  37. void set_disabled(bool disabled) { m_disabled = disabled; }
  38. CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet; }
  39. void set_parent_css_style_sheet(CSSStyleSheet*);
  40. protected:
  41. explicit StyleSheet(JS::Realm&, MediaList& media);
  42. virtual void visit_edges(Cell::Visitor&) override;
  43. JS::NonnullGCPtr<MediaList> m_media;
  44. private:
  45. JS::GCPtr<DOM::Element> m_owner_node;
  46. JS::GCPtr<CSSStyleSheet> m_parent_style_sheet;
  47. DeprecatedString m_location;
  48. DeprecatedString m_title;
  49. DeprecatedString m_type_string;
  50. bool m_disabled { false };
  51. bool m_alternate { false };
  52. bool m_origin_clean { true };
  53. };
  54. }