فهرست منبع

LibWeb: Fix 'background-repeat: round' calculation

Previously, this was slightly off and not doing what the spec comment
above asked for. This led to really small values for x_step and
y_step, making the `backgrounds.html' example use crazy amounts of
CPU whist painting.
MacDue 3 سال پیش
والد
کامیت
c9a70ffff5
1فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 2 2
      Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp

+ 2 - 2
Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp

@@ -154,10 +154,10 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
             // where round() is a function that returns the nearest natural number
             // where round() is a function that returns the nearest natural number
             // (integer greater than zero).
             // (integer greater than zero).
             if (layer.repeat_x == CSS::Repeat::Round) {
             if (layer.repeat_x == CSS::Repeat::Round) {
-                image_rect.set_width(background_positioning_area.width() / background_positioning_area.width() / image_rect.width());
+                image_rect.set_width(background_positioning_area.width() / roundf(background_positioning_area.width() / image_rect.width()));
             }
             }
             if (layer.repeat_y == CSS::Repeat::Round) {
             if (layer.repeat_y == CSS::Repeat::Round) {
-                image_rect.set_height(background_positioning_area.height() / background_positioning_area.height() / image_rect.height());
+                image_rect.set_height(background_positioning_area.height() / roundf(background_positioning_area.height() / image_rect.height()));
             }
             }
 
 
             // If background-repeat is round for one dimension only and if background-size is auto
             // If background-repeat is round for one dimension only and if background-size is auto