ladybird/Libraries/LibWeb/Painting/TextPaintable.h
Timothy Flynn 97548f48de LibWeb: Port rendered text to UTF-16
This migrates TextNode::text_for_rendering() to Utf16String and deals
with the fallout. As a consequence, this effectively reverts commit
3df83dade8.

The layout test expecation file updates are because we now express text
lengths and offsets in UTF-16 code units.

The selection-over-multiple-code-units expectation file update actually
represents a correctness fix. Our result now matches Firefox.
2025-07-25 18:16:22 +02:00

38 lines
1.3 KiB
C++

/*
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Painting/PaintableBox.h>
namespace Web::Painting {
class TextPaintable final : public Paintable {
GC_CELL(TextPaintable, Paintable);
GC_DECLARE_ALLOCATOR(TextPaintable);
public:
static GC::Ref<TextPaintable> create(Layout::TextNode const&, Utf16String text_for_rendering);
Layout::TextNode const& layout_node() const { return static_cast<Layout::TextNode const&>(Paintable::layout_node()); }
virtual bool wants_mouse_events() const override;
virtual DispatchEventOfSameName handle_mousedown(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
virtual DispatchEventOfSameName handle_mouseup(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
virtual DispatchEventOfSameName handle_mousemove(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
Utf16String const& text_for_rendering() const { return m_text_for_rendering; }
private:
virtual bool is_text_paintable() const override { return true; }
TextPaintable(Layout::TextNode const&, Utf16String text_for_rendering);
Utf16String m_text_for_rendering;
};
}