diff --git a/Tests/LibWeb/Text/expected/selection-extend-across-siblings.txt b/Tests/LibWeb/Text/expected/selection-extend-across-siblings.txt new file mode 100644 index 00000000000..7ef22e9a431 --- /dev/null +++ b/Tests/LibWeb/Text/expected/selection-extend-across-siblings.txt @@ -0,0 +1 @@ +PASS diff --git a/Tests/LibWeb/Text/expected/selection-extend-backwards.txt b/Tests/LibWeb/Text/expected/selection-extend-backwards.txt new file mode 100644 index 00000000000..7ef22e9a431 --- /dev/null +++ b/Tests/LibWeb/Text/expected/selection-extend-backwards.txt @@ -0,0 +1 @@ +PASS diff --git a/Tests/LibWeb/Text/input/selection-extend-across-siblings.html b/Tests/LibWeb/Text/input/selection-extend-across-siblings.html new file mode 100644 index 00000000000..dc61ee321b3 --- /dev/null +++ b/Tests/LibWeb/Text/input/selection-extend-across-siblings.html @@ -0,0 +1,22 @@ + +

Well hello

+

friends

+ + diff --git a/Tests/LibWeb/Text/input/selection-extend-backwards.html b/Tests/LibWeb/Text/input/selection-extend-backwards.html new file mode 100644 index 00000000000..02722e311a0 --- /dev/null +++ b/Tests/LibWeb/Text/input/selection-extend-backwards.html @@ -0,0 +1,21 @@ + +

Uno

+ + diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp index d910b2e1b11..2223a4789aa 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.cpp +++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp @@ -290,7 +290,7 @@ WebIDL::ExceptionOr Selection::extend(JS::NonnullGCPtr node, un TRY(new_range->set_end(new_focus_node, new_focus_offset)); } // 6. Otherwise, if oldAnchor is before or equal to newFocus, set the start newRange's start to oldAnchor, then set its end to newFocus. - else if (old_anchor_node.is_before(new_focus_node) || &old_anchor_node == new_focus_node.ptr()) { + else if (position_of_boundary_point_relative_to_other_boundary_point(old_anchor_node, old_anchor_offset, new_focus_node, new_focus_offset) != DOM::RelativeBoundaryPointPosition::After) { TRY(new_range->set_start(old_anchor_node, old_anchor_offset)); TRY(new_range->set_end(new_focus_node, new_focus_offset)); } @@ -304,7 +304,7 @@ WebIDL::ExceptionOr Selection::extend(JS::NonnullGCPtr node, un set_range(new_range); // 9. If newFocus is before oldAnchor, set this's direction to backwards. Otherwise, set it to forwards. - if (new_focus_node->is_before(old_anchor_node)) { + if (position_of_boundary_point_relative_to_other_boundary_point(new_focus_node, new_focus_offset, old_anchor_node, old_anchor_offset) == DOM::RelativeBoundaryPointPosition::Before) { m_direction = Direction::Backwards; } else { m_direction = Direction::Forwards;