LibWeb: Use as_if in Editing API where useful

This arguably improves readability in a couple of places. No functional
changes.
This commit is contained in:
Jelle Raaijmakers 2025-01-21 16:56:38 +01:00 committed by Tim Ledbetter
commit 2cee6aeba3
Notes: github-actions[bot] 2025-01-21 17:51:18 +00:00
2 changed files with 18 additions and 21 deletions

View file

@ -146,8 +146,8 @@ bool Document::query_command_enabled(FlyString const& command)
// NOTE: Commands can define additional conditions for being enabled, and currently the only condition mentioned in
// the spec is that certain commands must not be enabled if the editing host is in the plaintext-only state.
if (is<HTML::HTMLElement>(start_node_editing_host.ptr())
&& static_cast<HTML::HTMLElement&>(*start_node_editing_host).content_editable_state() == HTML::ContentEditableState::PlaintextOnly
if (auto const* html_element = as_if<HTML::HTMLElement>(start_node_editing_host.ptr()); html_element
&& html_element->content_editable_state() == HTML::ContentEditableState::PlaintextOnly
&& command.is_one_of(
Editing::CommandNames::backColor,
Editing::CommandNames::bold,