mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-28 04:09:00 +00:00
LibWeb: Ensure anchor node is not null when extending selection
Previously, clicking while holding shift without having previously made any text selection would cause a crash.
This commit is contained in:
parent
354b0062fa
commit
c79041344d
Notes:
sideshowbarker
2024-07-17 09:47:09 +09:00
Author: https://github.com/tcl3
Commit: c79041344d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/61
Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 3 additions and 2 deletions
|
@ -433,8 +433,9 @@ bool EventHandler::handle_mousedown(CSSPixelPoint viewport_position, CSSPixelPoi
|
||||||
auto& realm = document->realm();
|
auto& realm = document->realm();
|
||||||
m_navigable->set_cursor_position(DOM::Position::create(realm, *paintable->dom_node(), result->index_in_node));
|
m_navigable->set_cursor_position(DOM::Position::create(realm, *paintable->dom_node(), result->index_in_node));
|
||||||
if (auto selection = document->get_selection()) {
|
if (auto selection = document->get_selection()) {
|
||||||
if (modifiers & KeyModifier::Mod_Shift) {
|
auto anchor_node = selection->anchor_node();
|
||||||
(void)selection->set_base_and_extent(*selection->anchor_node(), selection->anchor_offset(), *paintable->dom_node(), result->index_in_node);
|
if (anchor_node && modifiers & KeyModifier::Mod_Shift) {
|
||||||
|
(void)selection->set_base_and_extent(*anchor_node, selection->anchor_offset(), *paintable->dom_node(), result->index_in_node);
|
||||||
} else {
|
} else {
|
||||||
(void)selection->set_base_and_extent(*paintable->dom_node(), result->index_in_node, *paintable->dom_node(), result->index_in_node);
|
(void)selection->set_base_and_extent(*paintable->dom_node(), result->index_in_node, *paintable->dom_node(), result->index_in_node);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue