mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03: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:
parent
9d03ea6f74
commit
57fbeff925
Notes:
sideshowbarker
2024-07-18 04:27:29 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/57fbeff9256
@ -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();
|
||||
|
@ -91,13 +91,12 @@ public:
|
||||
HashMap<URL, size_t> const& frame_nesting_levels() const { return m_frame_nesting_levels; }
|
||||
|
||||
private:
|
||||
explicit BrowsingContext(Page&, DOM::Element* host_element, BrowsingContext& top_level_browsing_context);
|
||||
explicit BrowsingContext(DOM::Element& host_element, BrowsingContext& top_level_browsing_context);
|
||||
explicit BrowsingContext(Page&);
|
||||
|
||||
void reset_cursor_blink_cycle();
|
||||
|
||||
void setup();
|
||||
|
||||
WeakPtr<Page> m_page;
|
||||
BrowsingContext& m_top_level_browsing_context;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user