mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Allow TextCursor hit-testing mode select empty contenteditable
This commit is contained in:
parent
20852443d3
commit
380907cd48
Notes:
github-actions[bot]
2024-10-30 18:30:56 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/380907cd486 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2024
1 changed files with 13 additions and 0 deletions
|
@ -902,6 +902,19 @@ TraversalDecision PaintableWithLines::hit_test(CSSPixelPoint position, HitTestTy
|
|||
auto position_adjusted_by_scroll_offset = position;
|
||||
position_adjusted_by_scroll_offset.translate_by(-cumulative_offset_of_enclosing_scroll_frame());
|
||||
|
||||
// TextCursor hit testing mode should be able to place cursor in contenteditable elements even if they are empty
|
||||
auto is_editable = layout_node_with_style_and_box_metrics().dom_node() && layout_node_with_style_and_box_metrics().dom_node()->is_editable();
|
||||
if (is_editable && m_fragments.is_empty() && !has_children() && type == HitTestType::TextCursor) {
|
||||
HitTestResult const hit_test_result {
|
||||
.paintable = const_cast<PaintableWithLines&>(*this),
|
||||
.index_in_node = 0,
|
||||
.vertical_distance = 0,
|
||||
.horizontal_distance = 0,
|
||||
};
|
||||
if (callback(hit_test_result) == TraversalDecision::Break)
|
||||
return TraversalDecision::Break;
|
||||
}
|
||||
|
||||
if (!layout_node_with_style_and_box_metrics().children_are_inline() || m_fragments.is_empty()) {
|
||||
return PaintableBox::hit_test(position, type, callback);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue