mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
LibWeb: Start implementing proper layout of replaced elements
LayoutReplaced now has intrinsic width, height and ratio. Only some of the values may be present. The layout algorithm takes the various configurations into account per the CSS specification. This is still pretty immature but at least we're moving forward. :^)
This commit is contained in:
parent
7fcf61be35
commit
4d5ecf6e32
10 changed files with 215 additions and 22 deletions
|
@ -31,6 +31,7 @@
|
|||
#include <LibWeb/Layout/LayoutInline.h>
|
||||
#include <LibWeb/Layout/LayoutReplaced.h>
|
||||
#include <LibWeb/Layout/LayoutText.h>
|
||||
#include <LibWeb/Layout/LayoutWidget.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace Web {
|
||||
|
@ -83,12 +84,14 @@ void LayoutBlock::layout_block_children(LayoutMode layout_mode)
|
|||
return;
|
||||
auto& child_block = static_cast<LayoutBlock&>(child);
|
||||
child_block.layout(layout_mode);
|
||||
content_height = child_block.rect().bottom() + child_block.box_model().full_margin().bottom - rect().top();
|
||||
|
||||
if (!child_block.is_absolutely_positioned())
|
||||
content_height = child_block.rect().bottom() + child_block.box_model().full_margin().bottom - rect().top();
|
||||
});
|
||||
if (layout_mode != LayoutMode::Default) {
|
||||
float max_width = 0;
|
||||
for_each_child([&](auto& child) {
|
||||
if (child.is_box())
|
||||
if (child.is_box() && !child.is_absolutely_positioned())
|
||||
max_width = max(max_width, to<LayoutBox>(child).width());
|
||||
});
|
||||
rect().set_width(max_width);
|
||||
|
@ -164,6 +167,10 @@ void LayoutBlock::layout_inline_children(LayoutMode layout_mode)
|
|||
|
||||
for (size_t i = 0; i < line_box.fragments().size(); ++i) {
|
||||
auto& fragment = line_box.fragments()[i];
|
||||
|
||||
if (fragment.layout_node().is_absolutely_positioned())
|
||||
continue;
|
||||
|
||||
// Vertically align everyone's bottom to the line.
|
||||
// FIXME: Support other kinds of vertical alignment.
|
||||
fragment.rect().set_x(roundf(x_offset + fragment.rect().x()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue