mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:57:44 +00:00
LibWeb: Handle when the last selected node does not contain text
If the text-for-rendering of the last selected node is empty, the select all implementation would end up setting the index to -1. This value is used directly for a substring length in the copy text implementation, thus would cause a failed assertion.
This commit is contained in:
parent
22ab512f39
commit
f7acd6aca5
1 changed files with 5 additions and 2 deletions
|
@ -305,8 +305,11 @@ void BrowsingContext::select_all()
|
|||
VERIFY(last_layout_node);
|
||||
|
||||
int last_layout_node_index_in_node = 0;
|
||||
if (is<Layout::TextNode>(*last_layout_node))
|
||||
last_layout_node_index_in_node = verify_cast<Layout::TextNode>(*last_layout_node).text_for_rendering().length() - 1;
|
||||
if (is<Layout::TextNode>(*last_layout_node)) {
|
||||
auto const& text_for_rendering = verify_cast<Layout::TextNode>(*last_layout_node).text_for_rendering();
|
||||
if (!text_for_rendering.is_empty())
|
||||
last_layout_node_index_in_node = text_for_rendering.length() - 1;
|
||||
}
|
||||
|
||||
layout_root->set_selection({ { first_layout_node, 0 }, { last_layout_node, last_layout_node_index_in_node } });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue