mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibWeb: Handle position:absolute with both left and right specified
In this case, we need to undo the right-side offsetting, since the width computation algorithm will already have stretched the width to accomodate both the side constraints.
This commit is contained in:
parent
72eb13d8e4
commit
86098505ec
Notes:
sideshowbarker
2024-07-19 05:25:11 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/86098505ecd
1 changed files with 10 additions and 2 deletions
|
@ -103,9 +103,17 @@ void LayoutBlock::layout_absolutely_positioned_descendant(LayoutBox& box)
|
|||
- box_model.offset().bottom.to_px(box)
|
||||
- box_model.border_box(box).bottom;
|
||||
|
||||
if (!box_model.offset().left.is_auto() || !box_model.margin().left.is_auto()) {
|
||||
bool has_left_side_constraints = !box_model.offset().left.is_auto() || !box_model.margin().left.is_auto();
|
||||
bool has_right_side_constraints = !box_model.offset().right.is_auto() || !box_model.margin().right.is_auto();
|
||||
|
||||
if (has_left_side_constraints && has_right_side_constraints) {
|
||||
// If both 'left' and 'right' are set, we will have stretched the width to accomodate both.
|
||||
x_offset += box_model.offset().right.to_px(box);
|
||||
}
|
||||
|
||||
if (has_left_side_constraints) {
|
||||
used_offset.set_x(x_offset + box_model.margin().left.to_px(box));
|
||||
} else if (!box_model.offset().right.is_auto() || !box_model.margin().right.is_auto()) {
|
||||
} else if (has_right_side_constraints) {
|
||||
used_offset.set_x(width() + x_offset - box.width() - box_model.margin().right.to_px(box));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue