mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-19 16:59:47 +00:00
LibWeb: Hide audio element when controls is not set
When an audio element has no controls attribute, it should not render at all and take up no space.
This commit is contained in:
parent
8f11dfc08a
commit
8632ce5cdd
Notes:
github-actions[bot]
2025-01-04 11:48:09 +00:00
Author: https://github.com/Psychpsyo
Commit: 8632ce5cdd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3135
Reviewed-by: https://github.com/AtkinsSJ ✅
5 changed files with 45 additions and 5 deletions
|
@ -34,4 +34,21 @@ GC::Ptr<Painting::Paintable> AudioBox::create_paintable() const
|
|||
return Painting::AudioPaintable::create(*this);
|
||||
}
|
||||
|
||||
bool AudioBox::should_paint() const
|
||||
{
|
||||
auto const& audio_element = dom_node();
|
||||
return audio_element.has_attribute(HTML::AttributeNames::controls) || audio_element.is_scripting_disabled();
|
||||
}
|
||||
|
||||
void AudioBox::prepare_for_replaced_layout()
|
||||
{
|
||||
if (should_paint()) {
|
||||
set_natural_width(300);
|
||||
set_natural_height(40);
|
||||
} else {
|
||||
set_natural_width(0);
|
||||
set_natural_height(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue