mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:12:43 +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:
		
							parent
							
								
									9d03ea6f74
								
							
						
					
					
						commit
						57fbeff925
					
				
					 2 changed files with 17 additions and 22 deletions
				
			
		|  | @ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling