mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibWeb: Add AbstractImageStyleValue::natural_aspect_ratio()
This commit is contained in:
parent
bbceb155ce
commit
d2c96e213f
Notes:
sideshowbarker
2024-07-17 09:48:50 +09:00
Author: https://github.com/MacDue
Commit: d2c96e213f
Pull-request: https://github.com/SerenityOS/serenity/pull/22508
Issue: https://github.com/SerenityOS/serenity/issues/20992
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/nico
3 changed files with 17 additions and 0 deletions
|
@ -23,6 +23,15 @@ public:
|
|||
virtual Optional<CSSPixels> natural_width() const { return {}; }
|
||||
virtual Optional<CSSPixels> natural_height() const { return {}; }
|
||||
|
||||
virtual Optional<CSSPixelFraction> natural_aspect_ratio() const
|
||||
{
|
||||
auto width = natural_width();
|
||||
auto height = natural_height();
|
||||
if (width.has_value() && height.has_value())
|
||||
return *width / *height;
|
||||
return {};
|
||||
}
|
||||
|
||||
virtual void load_any_resources(DOM::Document&) {};
|
||||
virtual void resolve_for_size(Layout::NodeWithStyleAndBoxModelMetrics const&, CSSPixelSize) const {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue