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

LibWeb: Use delegating constructors in BrowsingContext

This avoids having two nearly-identical initializer lists and and an
awkward setup() function that every constructor must call.
This commit is contained in:
Andreas Kling 2021-09-08 02:07:39 +02:00
parent 9d03ea6f74
commit 57fbeff925
2 changed files with 17 additions and 22 deletions

View file

@ -18,30 +18,12 @@
namespace Web {
BrowsingContext::BrowsingContext(DOM::Element& host_element, BrowsingContext& top_level_browsing_context)
: m_page(*top_level_browsing_context.page())
BrowsingContext::BrowsingContext(Page& page, DOM::Element* host_element, BrowsingContext& top_level_browsing_context)
: m_page(page)
, m_top_level_browsing_context(top_level_browsing_context)
, m_loader(*this)
, m_event_handler({}, *this)
, m_host_element(host_element)
{
setup();
}
BrowsingContext::BrowsingContext(Page& page)
: m_page(page)
, m_top_level_browsing_context(*this)
, m_loader(*this)
, m_event_handler({}, *this)
{
setup();
}
BrowsingContext::~BrowsingContext()
{
}
void BrowsingContext::setup()
{
m_cursor_blink_timer = Core::Timer::construct(500, [this] {
if (!is_focused_context())
@ -53,6 +35,20 @@ void BrowsingContext::setup()
});
}
BrowsingContext::BrowsingContext(DOM::Element& host_element, BrowsingContext& top_level_browsing_context)
: BrowsingContext(*top_level_browsing_context.page(), &host_element, top_level_browsing_context)
{
}
BrowsingContext::BrowsingContext(Page& page)
: BrowsingContext(page, nullptr, *this)
{
}
BrowsingContext::~BrowsingContext()
{
}
void BrowsingContext::did_edit(Badge<EditEventHandler>)
{
reset_cursor_blink_cycle();