mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibWeb: Remove implicit conversion from float and double to CSSPixels
In general it is not safe to convert any arbitrary floating-point value to CSSPixels. CSSPixels has a resolution of 0.015625, which for small values (e.g. scale factors between 0 and 1), can produce bad results if converted to CSSPixels then scaled back up. In the worst case values can underflow to zero and produce incorrect results.
This commit is contained in:
committed by
Alexander Kalenik
parent
0f9c088302
commit
360c0eb509
@@ -38,10 +38,10 @@ HTML::HTMLVideoElement const& VideoBox::dom_node() const
|
||||
void VideoBox::prepare_for_replaced_layout()
|
||||
{
|
||||
auto width = static_cast<float>(dom_node().video_width());
|
||||
set_natural_width(width);
|
||||
set_natural_width(CSSPixels(width));
|
||||
|
||||
auto height = static_cast<float>(dom_node().video_height());
|
||||
set_natural_height(height);
|
||||
set_natural_height(CSSPixels(height));
|
||||
|
||||
if (width != 0 && height != 0)
|
||||
set_natural_aspect_ratio(width / height);
|
||||
|
||||
Reference in New Issue
Block a user