summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Militzer <emil.militzer@posteo.de>2023-04-28 11:44:21 +0200
committerAndreas Kling <kling@serenityos.org>2023-04-28 18:12:02 +0200
commita8d08357c9e9eaa6f23a0179a26b8bf0cf52fc02 (patch)
tree8bc5c6eb0399ab082537f4b7b4df0252b640f4c4
parent62bc8590ad1dbbc256da6915f7eb502f1db10f6e (diff)
downloadserenity-a8d08357c9e9eaa6f23a0179a26b8bf0cf52fc02.zip
LibWeb: Compute inset for relative positioned inline-block
-rw-r--r--Tests/LibWeb/Layout/expected/block-and-inline/inline-box-positioned-with-top-left.txt16
-rw-r--r--Tests/LibWeb/Layout/input/block-and-inline/inline-box-positioned-with-top-left.html14
-rw-r--r--Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp1
3 files changed, 31 insertions, 0 deletions
diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-positioned-with-top-left.txt b/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-positioned-with-top-left.txt
new file mode 100644
index 0000000000..7a188b3bdc
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-positioned-with-top-left.txt
@@ -0,0 +1,16 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+ BlockContainer <html> at (0,0) content-size 800x36 children: not-inline
+ BlockContainer <body> at (8,8) content-size 784x20 children: inline
+ line 0 width: 352.34375, height: 20, bottom: 20, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 14, rect: [8,8 112.421875x17.46875]
+ "text text text"
+ frag 1 from BlockContainer start: 0, length: 0, rect: [120,8 110.375x20]
+ frag 2 from TextNode start: 0, length: 16, rect: [231,8 129.546875x17.46875]
+ "more inline text"
+ TextNode <#text>
+ BlockContainer <span.displaced_text> at (150,48) content-size 110.375x20 positioned inline-block children: inline
+ line 0 width: 110.375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 14, rect: [150,48 110.375x17.46875]
+ "displaced text"
+ TextNode <#text>
+ TextNode <#text>
diff --git a/Tests/LibWeb/Layout/input/block-and-inline/inline-box-positioned-with-top-left.html b/Tests/LibWeb/Layout/input/block-and-inline/inline-box-positioned-with-top-left.html
new file mode 100644
index 0000000000..34f2ab89c8
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/block-and-inline/inline-box-positioned-with-top-left.html
@@ -0,0 +1,14 @@
+<style>
+ body {
+ font-family: 'SerenitySans';
+ }
+
+ .displaced_text {
+ height: 20px;
+ top: 40px;
+ left: 30px;
+ display: inline-block;
+ position: relative;
+ }
+
+</style>text text text<span class="displaced_text">displaced text</span>more inline text
diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
index 0e379bbbc5..0490d4db8a 100644
--- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
@@ -256,6 +256,7 @@ void InlineFormattingContext::generate_line_boxes(LayoutMode layout_mode)
break;
case InlineLevelIterator::Item::Type::Element: {
auto& box = verify_cast<Layout::Box>(*item.node);
+ compute_inset(box);
line_builder.break_if_needed(item.border_box_width());
line_builder.append_box(box, item.border_start + item.padding_start, item.padding_end + item.border_end, item.margin_start, item.margin_end);
break;