summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAliaksandr Kalenik <kalenik.aliaksandr@gmail.com>2023-01-16 13:13:31 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-17 10:18:33 +0100
commit276a77f02dc5302fd496da034a6860b8753c7b4b (patch)
tree0a9da0de99d2c67333bf33a05662e49c6497647f /Userland/Libraries
parent87b18f9304370149f3c3b1c12cd851f69d81e0d4 (diff)
downloadserenity-276a77f02dc5302fd496da034a6860b8753c7b4b.zip
LibWeb: Support display inline-table
Add support for inline-table display type with corrresponding changes in tree builder to generate inline anonymous wrapper around inline table boxes.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/TableBox.h7
-rw-r--r--Userland/Libraries/LibWeb/Layout/TableCellBox.h2
-rw-r--r--Userland/Libraries/LibWeb/Layout/TableRowBox.h2
-rw-r--r--Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp7
5 files changed, 15 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
index ceda1f492e..0cfcf08547 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
@@ -555,6 +555,8 @@ CSS::Display StyleProperties::display() const
return CSS::Display::from_short(CSS::Display::Short::ListItem);
case CSS::ValueID::Table:
return CSS::Display::from_short(CSS::Display::Short::Table);
+ case CSS::ValueID::InlineTable:
+ return CSS::Display::from_short(CSS::Display::Short::InlineTable);
case CSS::ValueID::TableRow:
return CSS::Display { CSS::Display::Internal::TableRow };
case CSS::ValueID::TableCell:
diff --git a/Userland/Libraries/LibWeb/Layout/TableBox.h b/Userland/Libraries/LibWeb/Layout/TableBox.h
index 888c1d594f..caa33b5ce3 100644
--- a/Userland/Libraries/LibWeb/Layout/TableBox.h
+++ b/Userland/Libraries/LibWeb/Layout/TableBox.h
@@ -18,7 +18,12 @@ public:
TableBox(DOM::Document&, DOM::Element*, CSS::ComputedValues);
virtual ~TableBox() override;
- static CSS::Display static_display() { return CSS::Display::from_short(CSS::Display::Short::Table); }
+ static CSS::Display static_display(bool inline_outside)
+ {
+ if (inline_outside)
+ return CSS::Display::from_short(CSS::Display::Short::InlineTable);
+ return CSS::Display::from_short(CSS::Display::Short::Table);
+ }
};
}
diff --git a/Userland/Libraries/LibWeb/Layout/TableCellBox.h b/Userland/Libraries/LibWeb/Layout/TableCellBox.h
index 88768a0ede..b0b9297230 100644
--- a/Userland/Libraries/LibWeb/Layout/TableCellBox.h
+++ b/Userland/Libraries/LibWeb/Layout/TableCellBox.h
@@ -21,7 +21,7 @@ public:
size_t colspan() const;
size_t rowspan() const;
- static CSS::Display static_display() { return CSS::Display { CSS::Display::Internal::TableCell }; }
+ static CSS::Display static_display(bool) { return CSS::Display { CSS::Display::Internal::TableCell }; }
};
}
diff --git a/Userland/Libraries/LibWeb/Layout/TableRowBox.h b/Userland/Libraries/LibWeb/Layout/TableRowBox.h
index 26c7f6de7d..015a9c58fe 100644
--- a/Userland/Libraries/LibWeb/Layout/TableRowBox.h
+++ b/Userland/Libraries/LibWeb/Layout/TableRowBox.h
@@ -18,7 +18,7 @@ public:
TableRowBox(DOM::Document&, DOM::Element*, CSS::ComputedValues);
virtual ~TableRowBox() override;
- static CSS::Display static_display() { return CSS::Display { CSS::Display::Internal::TableRow }; }
+ static CSS::Display static_display(bool) { return CSS::Display { CSS::Display::Internal::TableRow }; }
};
}
diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
index bb581bbcd3..7a01fb4803 100644
--- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
@@ -501,7 +501,7 @@ static void wrap_in_anonymous(Vector<JS::Handle<Node>>& sequence, Node* nearest_
VERIFY(!sequence.is_empty());
auto& parent = *sequence.first()->parent();
auto computed_values = parent.computed_values().clone_inherited_values();
- static_cast<CSS::MutableComputedValues&>(computed_values).set_display(WrapperBoxType::static_display());
+ static_cast<CSS::MutableComputedValues&>(computed_values).set_display(WrapperBoxType::static_display(parent.display().is_inline_outside()));
auto wrapper = parent.heap().template allocate_without_realm<WrapperBoxType>(parent.document(), nullptr, move(computed_values));
for (auto& child : sequence) {
parent.remove_child(*child);
@@ -591,7 +591,10 @@ void TreeBuilder::generate_missing_parents(NodeWithStyle& root)
// all other values of non-inheritable properties are used on the table box and not the table wrapper box.
// (Where the table element's values are not used on the table and table wrapper boxes, the initial values are used instead.)
auto& mutable_wrapper_computed_values = static_cast<CSS::MutableComputedValues&>(wrapper_computed_values);
- mutable_wrapper_computed_values.set_display(CSS::Display(CSS::Display::Outside::Block, CSS::Display::Inside::FlowRoot));
+ if (table_box->display().is_inline_outside())
+ mutable_wrapper_computed_values.set_display(CSS::Display::from_short(CSS::Display::Short::InlineBlock));
+ else
+ mutable_wrapper_computed_values.set_display(CSS::Display::from_short(CSS::Display::Short::FlowRoot));
mutable_wrapper_computed_values.set_position(table_box->computed_values().position());
mutable_wrapper_computed_values.set_inset(table_box->computed_values().inset());
mutable_wrapper_computed_values.set_float(table_box->computed_values().float_());