LibWeb: Implement document.execCommand("delete")

To facilitate the implementation of "delete" and all associated
algorithms, split off this piece of `Document` into a separate
directory.

This sets up the infrastructure for arbitrary commands to be supported.
This commit is contained in:
Jelle Raaijmakers 2024-11-27 11:57:12 +01:00 committed by Andreas Kling
commit 7bb865052a
Notes: github-actions[bot] 2024-11-30 16:37:23 +00:00
12 changed files with 2227 additions and 48 deletions

View file

@ -5077,48 +5077,6 @@ JS::Value Document::named_item_value(FlyString const& name) const
});
}
// https://w3c.github.io/editing/docs/execCommand/#execcommand()
bool Document::exec_command(String const& command, bool show_ui, String const& value)
{
dbgln("FIXME: document.execCommand(\"{}\", {}, \"{}\")", command, show_ui, value);
return false;
}
// https://w3c.github.io/editing/docs/execCommand/#querycommandenabled()
bool Document::query_command_enabled(String const& command)
{
dbgln("FIXME: document.queryCommandEnabled(\"{}\")", command);
return false;
}
// https://w3c.github.io/editing/docs/execCommand/#querycommandindeterm()
bool Document::query_command_indeterm(String const& command)
{
dbgln("FIXME: document.queryCommandIndeterm(\"{}\")", command);
return false;
}
// https://w3c.github.io/editing/docs/execCommand/#querycommandstate()
bool Document::query_command_state(String const& command)
{
dbgln("FIXME: document.queryCommandState(\"{}\")", command);
return false;
}
// https://w3c.github.io/editing/docs/execCommand/#querycommandsupported()
bool Document::query_command_supported(String const& command)
{
dbgln("FIXME: document.queryCommandSupported(\"{}\")", command);
return false;
}
// https://w3c.github.io/editing/docs/execCommand/#querycommandvalue()
String Document::query_command_value(String const& command)
{
dbgln("FIXME: document.queryCommandValue(\"{}\")", command);
return String {};
}
// https://drafts.csswg.org/resize-observer-1/#calculate-depth-for-node
static size_t calculate_depth_for_node(Node const& node)
{

View file

@ -569,12 +569,12 @@ public:
void set_previous_document_unload_timing(DocumentUnloadTimingInfo const& previous_document_unload_timing) { m_previous_document_unload_timing = previous_document_unload_timing; }
// https://w3c.github.io/editing/docs/execCommand/
bool exec_command(String const& command, bool show_ui, String const& value);
bool query_command_enabled(String const& command);
bool query_command_indeterm(String const& command);
bool query_command_state(String const& command);
bool query_command_supported(String const& command);
String query_command_value(String const& command);
bool exec_command(FlyString const& command, bool show_ui, String const& value);
bool query_command_enabled(FlyString const& command);
bool query_command_indeterm(FlyString const& command);
bool query_command_state(FlyString const& command);
bool query_command_supported(FlyString const& command);
String query_command_value(FlyString const& command);
// https://w3c.github.io/selection-api/#dfn-has-scheduled-selectionchange-event
bool has_scheduled_selectionchange_event() const { return m_has_scheduled_selectionchange_event; }

View file

@ -143,6 +143,7 @@ interface Document : Node {
readonly attribute Element? scrollingElement;
// https://w3c.github.io/editing/docs/execCommand/
// FIXME: [CEReactions] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional (TrustedHTML or DOMString) value = "");
[CEReactions] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = "");
boolean queryCommandEnabled(DOMString commandId);
boolean queryCommandIndeterm(DOMString commandId);