diff --git a/Libraries/LibWeb/Painting/PaintableBox.cpp b/Libraries/LibWeb/Painting/PaintableBox.cpp index 02d78643a9c7..693e1647f505 100644 --- a/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -924,16 +924,12 @@ 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()); - // NOTE: This CSSPixels -> Float -> CSSPixels conversion is because we can't AffineTransform::map() a CSSPixelPoint. - Gfx::FloatPoint offset_position { - (position_adjusted_by_scroll_offset.x() - transform_origin().x()).to_float(), - (position_adjusted_by_scroll_offset.y() - transform_origin().y()).to_float() - }; - auto transformed_position_adjusted_by_scroll_offset = combined_css_transform().inverse().value_or({}).map(offset_position).to_type() + transform_origin(); - // 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) { + if (m_fragments.is_empty() + && !has_children() + && type == HitTestType::TextCursor + && layout_node_with_style_and_box_metrics().dom_node() + && layout_node_with_style_and_box_metrics().dom_node()->is_editable()) { HitTestResult const hit_test_result { .paintable = const_cast(*this), .index_in_node = 0, @@ -948,6 +944,13 @@ TraversalDecision PaintableWithLines::hit_test(CSSPixelPoint position, HitTestTy return PaintableBox::hit_test(position, type, callback); } + // NOTE: This CSSPixels -> Float -> CSSPixels conversion is because we can't AffineTransform::map() a CSSPixelPoint. + Gfx::FloatPoint offset_position { + (position_adjusted_by_scroll_offset.x() - transform_origin().x()).to_float(), + (position_adjusted_by_scroll_offset.y() - transform_origin().y()).to_float() + }; + auto transformed_position_adjusted_by_scroll_offset = combined_css_transform().inverse().value_or({}).map(offset_position).to_type() + transform_origin(); + if (hit_test_scrollbars(transformed_position_adjusted_by_scroll_offset, callback) == TraversalDecision::Break) return TraversalDecision::Break;