mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 09:52:31 +00:00
LibWeb/Editing: Handle no active range in queryCommandState
Fixes a crash when this is invoked if no range is active for the document.
This commit is contained in:
parent
7c7fec5e00
commit
556acd82ee
Notes:
github-actions[bot]
2025-05-26 21:37:43 +00:00
Author: https://github.com/shannonbooth
Commit: 556acd82ee
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4875
Reviewed-by: https://github.com/gmta ✅
3 changed files with 5 additions and 1 deletions
|
@ -329,6 +329,9 @@ WebIDL::ExceptionOr<bool> Document::query_command_state(FlyString const& command
|
||||||
if (inline_values.is_empty())
|
if (inline_values.is_empty())
|
||||||
return false;
|
return false;
|
||||||
auto range = Editing::active_range(*this);
|
auto range = Editing::active_range(*this);
|
||||||
|
if (!range)
|
||||||
|
return false;
|
||||||
|
|
||||||
Vector<GC::Ref<Node>> formattable_nodes;
|
Vector<GC::Ref<Node>> formattable_nodes;
|
||||||
Editing::for_each_node_effectively_contained_in_range(range, [&](GC::Ref<Node> descendant) {
|
Editing::for_each_node_effectively_contained_in_range(range, [&](GC::Ref<Node> descendant) {
|
||||||
if (Editing::is_formattable_node(descendant))
|
if (Editing::is_formattable_node(descendant))
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
strikeThrough active?: false
|
||||||
strikeThrough active?: true
|
strikeThrough active?: true
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
const range = document.createRange();
|
const range = document.createRange();
|
||||||
const selection = window.getSelection();
|
const selection = window.getSelection();
|
||||||
|
|
||||||
// println(`strikeThrough active?: ${document.queryCommandState("strikeThrough")}`);
|
println(`strikeThrough active?: ${document.queryCommandState("strikeThrough")}`);
|
||||||
range.selectNodeContents(target);
|
range.selectNodeContents(target);
|
||||||
selection.removeAllRanges();
|
selection.removeAllRanges();
|
||||||
selection.addRange(range);
|
selection.addRange(range);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue