LibWeb: Return true if invalid color was provided to an editing command

Both Chrome and Firefox return `true` whenever the value string provided
is an invalid color or the current color. Spec issue raised:

  https://github.com/w3c/editing/issues/476
This commit is contained in:
Jelle Raaijmakers 2025-01-23 10:47:46 +01:00 committed by Andreas Kling
commit 0c854f9afc
Notes: github-actions[bot] 2025-01-24 22:54:37 +00:00
3 changed files with 10 additions and 4 deletions

View file

@ -35,9 +35,10 @@ bool command_back_color_action(DOM::Document& document, String const& value)
resulting_value = MUST(String::formatted("#{}", resulting_value));
// 2. If value is still not a valid CSS color, or if it is currentColor, return false.
// AD-HOC: No browser does this. They always return true.
if (!Color::from_string(resulting_value).has_value()) {
// FIXME: Also return false in case of currentColor.
return false;
// FIXME: Also return true in case of currentColor.
return true;
}
}
@ -602,9 +603,10 @@ bool command_fore_color_action(DOM::Document& document, String const& value)
resulting_value = MUST(String::formatted("#{}", resulting_value));
// 2. If value is still not a valid CSS color, or if it is currentColor, return false.
// AD-HOC: No browser does this. They always return true.
if (!Color::from_string(resulting_value).has_value()) {
// FIXME: Also return false in case of currentColor.
return false;
// FIXME: Also return true in case of currentColor.
return true;
}
}