1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

LibHTML: Add a LayoutStyle object (computed style for a LayoutNode.)

This commit is contained in:
Andreas Kling 2019-06-16 13:44:09 +02:00
parent fec098b5cd
commit e3d3e431dc
4 changed files with 59 additions and 0 deletions

View file

@ -2,6 +2,7 @@
#include <AK/Retained.h>
#include <AK/Vector.h>
#include <LibHTML/Layout/LayoutStyle.h>
#include <SharedGraphics/Rect.h>
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;
};

View file

@ -0,0 +1,9 @@
#include <LibHTML/Layout/LayoutStyle.h>
LayoutStyle::LayoutStyle()
{
}
LayoutStyle::~LayoutStyle()
{
}

View file

@ -0,0 +1,44 @@
#pragma once
#include <SharedGraphics/Color.h>
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 };
};

View file

@ -12,6 +12,7 @@ LIBHTML_OBJS = \
Layout/LayoutBlock.o \
Layout/LayoutInline.o \
Layout/LayoutDocument.o \
Layout/LayoutStyle.o \
Dump.o
TEST_OBJS = test.o