mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 03:09:08 +00:00
LibHTML: Add a Frame class and use it for document layout width
Each HtmlView now has a main_frame(), which represents the main frame of the web page. Frame inherits from TreeNode<Frame>, which will allow us to someday implement a Frame tree (to support the <frame> element.)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <LibHTML/DOM/Element.h>
|
||||
#include <LibHTML/DOM/HTMLAnchorElement.h>
|
||||
#include <LibHTML/Dump.h>
|
||||
#include <LibHTML/Frame.h>
|
||||
#include <LibHTML/HtmlView.h>
|
||||
#include <LibHTML/Layout/LayoutNode.h>
|
||||
#include <LibHTML/RenderingContext.h>
|
||||
@@ -11,6 +12,7 @@
|
||||
|
||||
HtmlView::HtmlView(GWidget* parent)
|
||||
: GScrollableWidget(parent)
|
||||
, m_main_frame(Frame::create())
|
||||
{
|
||||
set_frame_shape(FrameShape::Container);
|
||||
set_frame_shadow(FrameShadow::Sunken);
|
||||
@@ -19,12 +21,18 @@ HtmlView::HtmlView(GWidget* parent)
|
||||
set_background_color(Color::White);
|
||||
}
|
||||
|
||||
HtmlView::~HtmlView()
|
||||
{
|
||||
}
|
||||
|
||||
void HtmlView::set_document(Document* document)
|
||||
{
|
||||
if (document == m_document)
|
||||
return;
|
||||
m_document = document;
|
||||
|
||||
main_frame().set_document(document);
|
||||
|
||||
if (document == nullptr)
|
||||
m_layout_root = nullptr;
|
||||
else
|
||||
@@ -46,7 +54,7 @@ void HtmlView::layout_and_sync_size()
|
||||
if (!m_layout_root)
|
||||
return;
|
||||
|
||||
m_layout_root->style().size().set_width(available_size().width());
|
||||
main_frame().set_size(available_size());
|
||||
m_layout_root->layout();
|
||||
set_content_size(m_layout_root->rect().size());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user