TextPaintable.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Painting/PaintableBox.h>
  8. namespace Web::Painting {
  9. class TextPaintable final : public Paintable {
  10. JS_CELL(TextPaintable, Paintable);
  11. public:
  12. static JS::NonnullGCPtr<TextPaintable> create(Layout::TextNode const&, String const& text_for_rendering);
  13. Layout::TextNode const& layout_node() const { return static_cast<Layout::TextNode const&>(Paintable::layout_node()); }
  14. virtual bool wants_mouse_events() const override;
  15. virtual DOM::Node* mouse_event_target() const override;
  16. virtual DispatchEventOfSameName handle_mousedown(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
  17. virtual DispatchEventOfSameName handle_mouseup(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
  18. virtual DispatchEventOfSameName handle_mousemove(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
  19. void set_text_decoration_thickness(CSSPixels thickness) { m_text_decoration_thickness = thickness; }
  20. CSSPixels text_decoration_thickness() const { return m_text_decoration_thickness; }
  21. String const& text_for_rendering() const { return m_text_for_rendering; }
  22. private:
  23. virtual bool is_text_paintable() const override { return true; }
  24. TextPaintable(Layout::TextNode const&, String const& text_for_rendering);
  25. String m_text_for_rendering;
  26. CSSPixels m_text_decoration_thickness { 0 };
  27. };
  28. }