diff --git a/Libraries/LibHTML/CSS/Default.css b/Libraries/LibHTML/CSS/Default.css index 0a81854f6a..02aaaadd01 100644 --- a/Libraries/LibHTML/CSS/Default.css +++ b/Libraries/LibHTML/CSS/Default.css @@ -109,3 +109,15 @@ hr { blink { display: inline; } + +table { + display: table; +} + +tr { + display: table-row; +} + +td { + display: table-cell; +} diff --git a/Libraries/LibHTML/DOM/Element.cpp b/Libraries/LibHTML/DOM/Element.cpp index f648467421..4ad220860f 100644 --- a/Libraries/LibHTML/DOM/Element.cpp +++ b/Libraries/LibHTML/DOM/Element.cpp @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include Element::Element(Document& document, const String& tag_name) : ParentNode(document, NodeType::ELEMENT_NODE) @@ -84,6 +87,12 @@ RefPtr Element::create_layout_node(const StyleProperties* parent_sty return adopt(*new LayoutInline(*this, move(style))); if (display == "list-item") return adopt(*new LayoutListItem(*this, move(style))); + if (display == "table") + return adopt(*new LayoutTable(*this, move(style))); + if (display == "table-row") + return adopt(*new LayoutTableRow(*this, move(style))); + if (display == "table-cell") + return adopt(*new LayoutTableCell(*this, move(style))); ASSERT_NOT_REACHED(); } diff --git a/Libraries/LibHTML/Layout/LayoutTable.cpp b/Libraries/LibHTML/Layout/LayoutTable.cpp new file mode 100644 index 0000000000..b2f48c622d --- /dev/null +++ b/Libraries/LibHTML/Layout/LayoutTable.cpp @@ -0,0 +1,16 @@ +#include +#include + +LayoutTable::LayoutTable(const Element& element, NonnullRefPtr style) + : LayoutBlock(&element, move(style)) +{ +} + +LayoutTable::~LayoutTable() +{ +} + +void LayoutTable::layout() +{ + LayoutBlock::layout(); +} diff --git a/Libraries/LibHTML/Layout/LayoutTable.h b/Libraries/LibHTML/Layout/LayoutTable.h new file mode 100644 index 0000000000..db7d55655e --- /dev/null +++ b/Libraries/LibHTML/Layout/LayoutTable.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +class LayoutTable final : public LayoutBlock { +public: + LayoutTable(const Element&, NonnullRefPtr); + virtual ~LayoutTable() override; + + virtual void layout() override; + +private: + virtual const char* class_name() const override { return "LayoutTable"; } +}; diff --git a/Libraries/LibHTML/Layout/LayoutTableCell.cpp b/Libraries/LibHTML/Layout/LayoutTableCell.cpp new file mode 100644 index 0000000000..ad4b655077 --- /dev/null +++ b/Libraries/LibHTML/Layout/LayoutTableCell.cpp @@ -0,0 +1,11 @@ +#include +#include + +LayoutTableCell::LayoutTableCell(const Element& element, NonnullRefPtr style) + : LayoutBlock(&element, move(style)) +{ +} + +LayoutTableCell::~LayoutTableCell() +{ +} diff --git a/Libraries/LibHTML/Layout/LayoutTableCell.h b/Libraries/LibHTML/Layout/LayoutTableCell.h new file mode 100644 index 0000000000..0616a987a8 --- /dev/null +++ b/Libraries/LibHTML/Layout/LayoutTableCell.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +class LayoutTableCell final : public LayoutBlock { +public: + LayoutTableCell(const Element&, NonnullRefPtr); + virtual ~LayoutTableCell() override; + +private: + virtual const char* class_name() const override { return "LayoutTableCell"; } +}; diff --git a/Libraries/LibHTML/Layout/LayoutTableRow.cpp b/Libraries/LibHTML/Layout/LayoutTableRow.cpp new file mode 100644 index 0000000000..6fc7c755c5 --- /dev/null +++ b/Libraries/LibHTML/Layout/LayoutTableRow.cpp @@ -0,0 +1,16 @@ +#include +#include + +LayoutTableRow::LayoutTableRow(const Element& element, NonnullRefPtr style) + : LayoutBox(&element, move(style)) +{ +} + +LayoutTableRow::~LayoutTableRow() +{ +} + +void LayoutTableRow::layout() +{ + LayoutBox::layout(); +} diff --git a/Libraries/LibHTML/Layout/LayoutTableRow.h b/Libraries/LibHTML/Layout/LayoutTableRow.h new file mode 100644 index 0000000000..d29cead338 --- /dev/null +++ b/Libraries/LibHTML/Layout/LayoutTableRow.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +class LayoutTableRow final : public LayoutBox { +public: + LayoutTableRow(const Element&, NonnullRefPtr); + virtual ~LayoutTableRow() override; + + virtual void layout() override; + +private: + virtual const char* class_name() const override { return "LayoutTableRow"; } +}; diff --git a/Libraries/LibHTML/Makefile.shared b/Libraries/LibHTML/Makefile.shared index bbacce889e..48d8a87bab 100644 --- a/Libraries/LibHTML/Makefile.shared +++ b/Libraries/LibHTML/Makefile.shared @@ -44,6 +44,9 @@ LIBHTML_OBJS = \ Layout/LayoutListItem.o \ Layout/LayoutListItemMarker.o \ Layout/LayoutBreak.o \ + Layout/LayoutTable.o \ + Layout/LayoutTableRow.o \ + Layout/LayoutTableCell.o \ Layout/BoxModelMetrics.o \ Layout/LineBox.o \ Layout/LineBoxFragment.o \