mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +00:00
LibWeb: Store "text for rendering" in TextPaintable
Instead of TextPaintable fragments being an offset+length view into the layout node, they are now a view into the paintable instead. This removes an awkward time window where we'd have bogus state in text fragments after layout invalidation but before relayout. It also makes the code slightly nicer in general, since there's less mixing of layout and painting concepts.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <LibWeb/Page/EventHandler.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
#include <LibWeb/Painting/TextPaintable.h>
|
||||
#include <LibWeb/UIEvents/EventNames.h>
|
||||
#include <LibWeb/UIEvents/KeyboardEvent.h>
|
||||
#include <LibWeb/UIEvents/MouseEvent.h>
|
||||
@@ -611,16 +612,15 @@ bool EventHandler::handle_doubleclick(CSSPixelPoint position, CSSPixelPoint scre
|
||||
|
||||
if (button == GUI::MouseButton::Primary) {
|
||||
if (auto result = paint_root()->hit_test(position, Painting::HitTestType::TextCursor); result.has_value()) {
|
||||
auto hit_paintable = result->paintable;
|
||||
if (!hit_paintable->dom_node())
|
||||
if (!result->paintable->dom_node())
|
||||
return true;
|
||||
|
||||
auto const& hit_layout_node = hit_paintable->layout_node();
|
||||
if (!hit_layout_node.is_text_node())
|
||||
if (!is<Painting::TextPaintable>(*result->paintable))
|
||||
return true;
|
||||
auto& hit_paintable = static_cast<Painting::TextPaintable const&>(*result->paintable);
|
||||
|
||||
auto& hit_dom_node = verify_cast<DOM::Text>(*hit_paintable->dom_node());
|
||||
auto const& text_for_rendering = verify_cast<Layout::TextNode>(hit_layout_node).text_for_rendering();
|
||||
auto& hit_dom_node = const_cast<DOM::Text&>(verify_cast<DOM::Text>(*hit_paintable.dom_node()));
|
||||
auto const& text_for_rendering = hit_paintable.text_for_rendering();
|
||||
|
||||
int first_word_break_before = [&] {
|
||||
// Start from one before the index position to prevent selecting only spaces between words, caused by the addition below.
|
||||
|
||||
Reference in New Issue
Block a user