mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 08:48:57 +00:00
LibWeb: Remove text storage from TextPaintable
Instead of copying the layout node's text, retrieve the text from the layout node directly.
This commit is contained in:
parent
e6474778c6
commit
d1076c1e6e
Notes:
github-actions[bot]
2025-09-12 19:35:17 +00:00
Author: https://github.com/gmta
Commit: d1076c1e6e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6169
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/trflynn89
5 changed files with 8 additions and 13 deletions
|
@ -555,7 +555,7 @@ Optional<TextNode::Chunk> TextNode::ChunkIterator::try_commit_chunk(size_t start
|
|||
|
||||
GC::Ptr<Painting::Paintable> TextNode::create_paintable() const
|
||||
{
|
||||
return Painting::TextPaintable::create(*this, text_for_rendering());
|
||||
return Painting::TextPaintable::create(*this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -986,7 +986,7 @@ EventResult EventHandler::handle_doubleclick(CSSPixelPoint viewport_position, CS
|
|||
next_boundary = hit_dom_node.length_in_utf16_code_units();
|
||||
} else {
|
||||
auto& segmenter = word_segmenter();
|
||||
segmenter.set_segmented_text(hit_paintable.text_for_rendering());
|
||||
segmenter.set_segmented_text(hit_paintable.layout_node().text_for_rendering());
|
||||
|
||||
previous_boundary = segmenter.previous_boundary(result->index_in_node, Unicode::Segmenter::Inclusive::Yes).value_or(0);
|
||||
next_boundary = segmenter.next_boundary(result->index_in_node).value_or(hit_dom_node.length());
|
||||
|
|
|
@ -208,7 +208,7 @@ Utf16View PaintableFragment::text() const
|
|||
{
|
||||
if (!is<TextPaintable>(paintable()))
|
||||
return {};
|
||||
return static_cast<TextPaintable const&>(paintable()).text_for_rendering().substring_view(m_start_offset, m_length_in_code_units);
|
||||
return as<TextPaintable>(paintable()).layout_node().text_for_rendering().substring_view(m_start_offset, m_length_in_code_units);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,14 +14,13 @@ namespace Web::Painting {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(TextPaintable);
|
||||
|
||||
GC::Ref<TextPaintable> TextPaintable::create(Layout::TextNode const& layout_node, Utf16String text_for_rendering)
|
||||
GC::Ref<TextPaintable> TextPaintable::create(Layout::TextNode const& layout_node)
|
||||
{
|
||||
return layout_node.heap().allocate<TextPaintable>(layout_node, move(text_for_rendering));
|
||||
return layout_node.heap().allocate<TextPaintable>(layout_node);
|
||||
}
|
||||
|
||||
TextPaintable::TextPaintable(Layout::TextNode const& layout_node, Utf16String text_for_rendering)
|
||||
TextPaintable::TextPaintable(Layout::TextNode const& layout_node)
|
||||
: Paintable(layout_node)
|
||||
, m_text_for_rendering(move(text_for_rendering))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class TextPaintable final : public Paintable {
|
|||
GC_DECLARE_ALLOCATOR(TextPaintable);
|
||||
|
||||
public:
|
||||
static GC::Ref<TextPaintable> create(Layout::TextNode const&, Utf16String text_for_rendering);
|
||||
static GC::Ref<TextPaintable> create(Layout::TextNode const&);
|
||||
|
||||
Layout::TextNode const& layout_node() const { return static_cast<Layout::TextNode const&>(Paintable::layout_node()); }
|
||||
|
||||
|
@ -25,14 +25,10 @@ public:
|
|||
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;
|
||||
TextPaintable(Layout::TextNode const&);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue