mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-21 09:41:53 +00: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
Notes:
github-actions[bot]
2025-01-24 22:54:43 +00:00
Author: https://github.com/gmta
Commit: 2b7ff194f8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3352
1 changed files with 6 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue