mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
LibWeb: Don't attempt to set selection if control has no selectable text
This commit is contained in:
parent
8d6f36f8d6
commit
2c8fb49578
Notes:
github-actions[bot]
2024-09-09 09:05:03 +00:00
Author: https://github.com/tcl3
Commit: 2c8fb49578
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1337
4 changed files with 18 additions and 0 deletions
|
@ -0,0 +1 @@
|
||||||
|
PASS (didn't crash)
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const inputElement = document.createElement("input");
|
||||||
|
inputElement.type = "color";
|
||||||
|
inputElement.value = "#000000";
|
||||||
|
inputElement.select();
|
||||||
|
println("PASS (didn't crash)");
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -2365,6 +2365,9 @@ HTMLInputElement::ValueAttributeMode HTMLInputElement::value_attribute_mode() co
|
||||||
|
|
||||||
void HTMLInputElement::selection_was_changed(size_t selection_start, size_t selection_end)
|
void HTMLInputElement::selection_was_changed(size_t selection_start, size_t selection_end)
|
||||||
{
|
{
|
||||||
|
if (!m_text_node)
|
||||||
|
return;
|
||||||
|
|
||||||
document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, selection_end));
|
document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, selection_end));
|
||||||
|
|
||||||
if (auto selection = document().get_selection())
|
if (auto selection = document().get_selection())
|
||||||
|
|
|
@ -463,6 +463,9 @@ void HTMLTextAreaElement::queue_firing_input_event()
|
||||||
|
|
||||||
void HTMLTextAreaElement::selection_was_changed(size_t selection_start, size_t selection_end)
|
void HTMLTextAreaElement::selection_was_changed(size_t selection_start, size_t selection_end)
|
||||||
{
|
{
|
||||||
|
if (!m_text_node)
|
||||||
|
return;
|
||||||
|
|
||||||
document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, selection_end));
|
document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, selection_end));
|
||||||
|
|
||||||
if (auto selection = document().get_selection())
|
if (auto selection = document().get_selection())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue