2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2021-09-15 08:19:42 -03:00
|
|
|
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
2020-01-18 05:38:21 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2021-02-10 04:25:35 -03:00
|
|
|
#include <LibGfx/Painter.h>
|
2020-03-07 06:32:51 -03:00
|
|
|
#include <LibWeb/DOM/Document.h>
|
2021-05-13 10:39:30 -03:00
|
|
|
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
2021-10-06 15:02:41 -03:00
|
|
|
#include <LibWeb/Layout/BlockContainer.h>
|
2020-11-22 11:53:01 -03:00
|
|
|
#include <LibWeb/Layout/Box.h>
|
2021-09-15 08:19:42 -03:00
|
|
|
#include <LibWeb/Layout/FormattingContext.h>
|
2022-03-10 19:13:37 -03:00
|
|
|
#include <LibWeb/Painting/PaintableBox.h>
|
2019-10-15 11:48:38 -03:00
|
|
|
|
2020-11-22 11:53:01 -03:00
|
|
|
namespace Web::Layout {
|
2020-03-07 06:27:02 -03:00
|
|
|
|
2022-03-09 19:53:41 -03:00
|
|
|
Box::Box(DOM::Document& document, DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style)
|
|
|
|
|
: NodeWithStyleAndBoxModelMetrics(document, node, move(style))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Box::Box(DOM::Document& document, DOM::Node* node, CSS::ComputedValues computed_values)
|
|
|
|
|
: NodeWithStyleAndBoxModelMetrics(document, node, move(computed_values))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Box::~Box()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-22 11:53:01 -03:00
|
|
|
void Box::set_needs_display()
|
2019-10-15 11:48:38 -03:00
|
|
|
{
|
2022-04-11 18:58:41 -03:00
|
|
|
if (paint_box())
|
2022-03-10 11:50:16 -03:00
|
|
|
browsing_context().set_needs_display(enclosing_int_rect(paint_box()->absolute_rect()));
|
2019-10-15 11:48:38 -03:00
|
|
|
}
|
2019-10-19 06:49:46 -03:00
|
|
|
|
2020-11-22 11:53:01 -03:00
|
|
|
bool Box::is_body() const
|
2019-10-19 06:49:46 -03:00
|
|
|
{
|
2020-11-22 10:46:36 -03:00
|
|
|
return dom_node() && dom_node() == document().body();
|
2019-10-19 06:49:46 -03:00
|
|
|
}
|
2020-03-07 06:27:02 -03:00
|
|
|
|
2022-03-10 18:38:08 -03:00
|
|
|
RefPtr<Painting::Paintable> Box::create_paintable() const
|
2021-10-28 12:08:42 -03:00
|
|
|
{
|
2022-03-10 11:50:57 -03:00
|
|
|
return Painting::PaintableBox::create(*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Painting::PaintableBox const* Box::paint_box() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<Painting::PaintableBox const*>(Node::paintable());
|
2021-10-28 12:08:42 -03:00
|
|
|
}
|
|
|
|
|
|
2020-03-07 06:27:02 -03:00
|
|
|
}
|