mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Use correct boundaries in Selection::collapse_to_start/end()
We were using the anchor_node() as the boundary point node when collapsing a selection, but the spec tells us to use the start and end boundary point nodes.
This commit is contained in:
parent
eb11c35640
commit
2052792663
Notes:
github-actions[bot]
2024-12-21 18:18:09 +00:00
Author: https://github.com/gmta
Commit: 2052792663
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2991
3 changed files with 35 additions and 4 deletions
|
@ -239,8 +239,8 @@ WebIDL::ExceptionOr<void> Selection::collapse_to_start()
|
|||
auto new_range = DOM::Range::create(*m_document);
|
||||
|
||||
// 3. Set the start both its start and end to the start of this's range
|
||||
TRY(new_range->set_start(*anchor_node(), m_range->start_offset()));
|
||||
TRY(new_range->set_end(*anchor_node(), m_range->start_offset()));
|
||||
TRY(new_range->set_start(*m_range->start_container(), m_range->start_offset()));
|
||||
TRY(new_range->set_end(*m_range->start_container(), m_range->start_offset()));
|
||||
|
||||
// 4. Then set this's range to the newly-created range.
|
||||
set_range(new_range);
|
||||
|
@ -259,8 +259,8 @@ WebIDL::ExceptionOr<void> Selection::collapse_to_end()
|
|||
auto new_range = DOM::Range::create(*m_document);
|
||||
|
||||
// 3. Set the start both its start and end to the start of this's range
|
||||
TRY(new_range->set_start(*anchor_node(), m_range->end_offset()));
|
||||
TRY(new_range->set_end(*anchor_node(), m_range->end_offset()));
|
||||
TRY(new_range->set_start(*m_range->end_container(), m_range->end_offset()));
|
||||
TRY(new_range->set_end(*m_range->end_container(), m_range->end_offset()));
|
||||
|
||||
// 4. Then set this's range to the newly-created range.
|
||||
set_range(new_range);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue