2019-06-29 21:42:07 +02:00
|
|
|
#include <AK/Function.h>
|
|
|
|
|
#include <LibHTML/CSS/StyleResolver.h>
|
|
|
|
|
#include <LibHTML/DOM/Element.h>
|
|
|
|
|
#include <LibHTML/Dump.h>
|
2019-06-16 21:35:03 +02:00
|
|
|
#include <LibHTML/Frame.h>
|
2019-06-29 21:42:07 +02:00
|
|
|
#include <LibHTML/Layout/LayoutBlock.h>
|
2019-07-01 07:27:17 +02:00
|
|
|
#include <LibHTML/Layout/LayoutDocument.h>
|
2019-06-29 21:42:07 +02:00
|
|
|
#include <LibHTML/Layout/LayoutInline.h>
|
|
|
|
|
#include <stdio.h>
|
2019-06-16 21:35:03 +02:00
|
|
|
|
|
|
|
|
Frame::Frame()
|
|
|
|
|
: m_size(800, 600)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Frame::~Frame()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Frame::set_document(Document* document)
|
|
|
|
|
{
|
|
|
|
|
m_document = document;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 07:24:15 +02:00
|
|
|
void Frame::layout()
|
|
|
|
|
{
|
|
|
|
|
if (!m_document)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-09-25 12:17:29 +03:00
|
|
|
auto layout_root = m_document->create_layout_tree(m_document->style_resolver(), nullptr);
|
2019-06-29 21:42:07 +02:00
|
|
|
|
|
|
|
|
layout_root->style().size().set_width(m_size.width());
|
2019-06-16 21:35:03 +02:00
|
|
|
|
2019-06-29 21:42:07 +02:00
|
|
|
printf("\033[33;1mLayout tree before layout:\033[0m\n");
|
|
|
|
|
dump_tree(*layout_root);
|
2019-06-16 21:35:03 +02:00
|
|
|
|
2019-06-29 21:42:07 +02:00
|
|
|
layout_root->layout();
|
2019-06-16 21:35:03 +02:00
|
|
|
|
2019-06-29 21:42:07 +02:00
|
|
|
printf("\033[33;1mLayout tree after layout:\033[0m\n");
|
|
|
|
|
dump_tree(*layout_root);
|
2019-06-16 21:35:03 +02:00
|
|
|
}
|