StyleSheet.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/Forward.h>
  10. namespace Web::CSS {
  11. class StyleSheet : public Bindings::PlatformObject {
  12. JS_OBJECT(StyleSheet, Bindings::PlatformObject);
  13. public:
  14. StyleSheet& impl() { return *this; }
  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. String href() const { return m_location; }
  20. String location() const { return m_location; }
  21. void set_location(String location) { m_location = move(location); }
  22. String title() const { return m_title; }
  23. void set_title(String title) { m_title = move(title); }
  24. void set_type(String type) { m_type_string = move(type); }
  25. void set_media(String media) { m_media_string = move(media); }
  26. bool is_alternate() const { return m_alternate; }
  27. void set_alternate(bool alternate) { m_alternate = alternate; }
  28. void set_origin_clean(bool origin_clean) { m_origin_clean = origin_clean; }
  29. bool disabled() const { return m_disabled; }
  30. void set_disabled(bool disabled) { m_disabled = disabled; }
  31. CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet; }
  32. void set_parent_css_style_sheet(CSSStyleSheet*);
  33. protected:
  34. explicit StyleSheet(Bindings::WindowObject&);
  35. virtual void visit_edges(Cell::Visitor&) override;
  36. private:
  37. WeakPtr<DOM::Element> m_owner_node;
  38. CSSStyleSheet* m_parent_style_sheet { nullptr };
  39. String m_location;
  40. String m_title;
  41. String m_type_string;
  42. String m_media_string;
  43. bool m_disabled { false };
  44. bool m_alternate { false };
  45. bool m_origin_clean { true };
  46. };
  47. }
  48. namespace Web::Bindings {
  49. inline JS::Object* wrap(JS::Realm&, Web::CSS::StyleSheet& object) { return &object; }
  50. using StyleSheetWrapper = Web::CSS::StyleSheet;
  51. }