mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01:00
LibWeb: Only record overrides for editing commands that require it
I forgot to implement the "If a command preserves overrides" part of the spec.
This commit is contained in:
parent
486bce8dad
commit
2b7ff194f8
|
|
@ -75,18 +75,20 @@ WebIDL::ExceptionOr<bool> Document::exec_command(FlyString const& command, [[may
|
|||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#preserves-overrides
|
||||
// If a command preserves overrides, then before taking its action, the user agent must record current overrides.
|
||||
auto overrides = Editing::record_current_overrides(*this);
|
||||
|
||||
// 5. Take the action for command, passing value to the instructions as an argument.
|
||||
auto optional_command = Editing::find_command_definition(command);
|
||||
VERIFY(optional_command.has_value());
|
||||
auto const& command_definition = optional_command.release_value();
|
||||
Vector<Editing::RecordedOverride> overrides;
|
||||
if (command_definition.preserves_overrides)
|
||||
overrides = Editing::record_current_overrides(*this);
|
||||
|
||||
// 5. Take the action for command, passing value to the instructions as an argument.
|
||||
auto command_result = command_definition.action(*this, value);
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#preserves-overrides
|
||||
// After taking the action, if the active range is collapsed, it must restore states and values from the recorded
|
||||
// list.
|
||||
if (m_selection && m_selection->is_collapsed())
|
||||
if (!overrides.is_empty() && m_selection && m_selection->is_collapsed())
|
||||
Editing::restore_states_and_values(*this, overrides);
|
||||
|
||||
// 6. If the previous step returned false, return false.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user