diff --git a/LibHTML/Layout/LayoutNode.h b/LibHTML/Layout/LayoutNode.h index 0e47154992..76d56043e4 100644 --- a/LibHTML/Layout/LayoutNode.h +++ b/LibHTML/Layout/LayoutNode.h @@ -2,6 +2,7 @@ #include #include +#include #include class Node; @@ -17,6 +18,9 @@ public: const Rect& rect() const { return m_rect; } void set_rect(const Rect& rect) { m_rect = rect; } + LayoutStyle& style() { return m_style; } + const LayoutStyle& style() const { return m_style; } + bool is_anonymous() const { return !m_node; } const Node* node() const { return m_node; } @@ -55,5 +59,6 @@ private: LayoutNode* m_last_child { nullptr }; LayoutNode* m_next_sibling { nullptr }; LayoutNode* m_previous_sibling { nullptr }; + LayoutStyle m_style; Rect m_rect; }; diff --git a/LibHTML/Layout/LayoutStyle.cpp b/LibHTML/Layout/LayoutStyle.cpp new file mode 100644 index 0000000000..13b0c94b00 --- /dev/null +++ b/LibHTML/Layout/LayoutStyle.cpp @@ -0,0 +1,9 @@ +#include + +LayoutStyle::LayoutStyle() +{ +} + +LayoutStyle::~LayoutStyle() +{ +} diff --git a/LibHTML/Layout/LayoutStyle.h b/LibHTML/Layout/LayoutStyle.h new file mode 100644 index 0000000000..fd92e75d3e --- /dev/null +++ b/LibHTML/Layout/LayoutStyle.h @@ -0,0 +1,44 @@ +#pragma once + +#include + +struct Box { + int top { 0 }; + int right { 0 }; + int bottom { 0 }; + int left { 0 }; +}; + +enum FontStyle { + Normal, + Bold, +}; + +class LayoutStyle { +public: + LayoutStyle(); + ~LayoutStyle(); + + Color text_color() const { return m_text_color; } + Color background_color() const { return m_background_color; } + + Box& offset() { return m_offset; } + Box& margin() { return m_margin; } + Box& padding() { return m_padding; } + + const Box& offset() const { return m_offset; } + const Box& margin() const { return m_margin; } + const Box& padding() const { return m_padding; } + + FontStyle font_style() const { return m_font_style; } + +private: + Color m_text_color; + Color m_background_color; + + Box m_offset; + Box m_margin; + Box m_padding; + + FontStyle m_font_style { FontStyle::Normal }; +}; diff --git a/LibHTML/Makefile b/LibHTML/Makefile index 1ff51e33a0..05996e29cc 100644 --- a/LibHTML/Makefile +++ b/LibHTML/Makefile @@ -12,6 +12,7 @@ LIBHTML_OBJS = \ Layout/LayoutBlock.o \ Layout/LayoutInline.o \ Layout/LayoutDocument.o \ + Layout/LayoutStyle.o \ Dump.o TEST_OBJS = test.o