diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index a396bd543eee..759312fa3b79 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -435,8 +435,11 @@ impl FragmentDisplayListBuilding for Fragment { let vertical_position = model::specified(background.background_position.vertical, bounds.size.height - image_size.height); - let abs_x = virtual_origin_x + horizontal_position; - let abs_y = virtual_origin_y + vertical_position; + // Background image should be positioned on the padding box basis. + let border = style.logical_border_width().to_physical(style.writing_mode); + + let abs_x = border.left + virtual_origin_x + horizontal_position; + let abs_y = border.top + virtual_origin_y + vertical_position; // Adjust origin and size based on background-repeat match background.background_repeat { diff --git a/tests/ref/background_image_a.html b/tests/ref/background_image_a.html new file mode 100644 index 000000000000..bb7b0434d072 --- /dev/null +++ b/tests/ref/background_image_a.html @@ -0,0 +1,22 @@ + + + + + + + +
+ + + + diff --git a/tests/ref/background_image_ref.html b/tests/ref/background_image_ref.html new file mode 100644 index 000000000000..d30a489a2c3a --- /dev/null +++ b/tests/ref/background_image_ref.html @@ -0,0 +1,22 @@ + + + + + + + +
+ + +
+ + + +