mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:02:43 +00:00 
			
		
		
		
	 b75b7f0c0d
			
		
	
	
		b75b7f0c0d
		
	
	
	
	
		
			
			Callers that are already in a fallible context will now TRY to allocate cells. Callers in infallible contexts get a FIXME.
		
			
				
	
	
		
			52 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/DOM/Document.h>
 | |
| #include <LibWeb/DOM/Event.h>
 | |
| #include <LibWeb/DOM/EventDispatcher.h>
 | |
| #include <LibWeb/HTML/Window.h>
 | |
| #include <LibWeb/HighResolutionTime/Performance.h>
 | |
| #include <LibWeb/NavigationTiming/PerformanceTiming.h>
 | |
| 
 | |
| namespace Web::HighResolutionTime {
 | |
| 
 | |
| Performance::Performance(HTML::Window& window)
 | |
|     : DOM::EventTarget(window.realm())
 | |
|     , m_window(window)
 | |
| {
 | |
|     m_timer.start();
 | |
| }
 | |
| 
 | |
| Performance::~Performance() = default;
 | |
| 
 | |
| JS::ThrowCompletionOr<void> Performance::initialize(JS::Realm& realm)
 | |
| {
 | |
|     MUST_OR_THROW_OOM(Base::initialize(realm));
 | |
|     set_prototype(&Bindings::ensure_web_prototype<Bindings::PerformancePrototype>(realm, "Performance"));
 | |
| 
 | |
|     return {};
 | |
| }
 | |
| 
 | |
| void Performance::visit_edges(Cell::Visitor& visitor)
 | |
| {
 | |
|     Base::visit_edges(visitor);
 | |
|     visitor.visit(m_window.ptr());
 | |
|     visitor.visit(m_timing.ptr());
 | |
| }
 | |
| 
 | |
| JS::GCPtr<NavigationTiming::PerformanceTiming> Performance::timing()
 | |
| {
 | |
|     if (!m_timing)
 | |
|         m_timing = heap().allocate<NavigationTiming::PerformanceTiming>(realm(), *m_window).release_allocated_value_but_fixme_should_propagate_errors();
 | |
|     return m_timing;
 | |
| }
 | |
| 
 | |
| double Performance::time_origin() const
 | |
| {
 | |
|     return static_cast<double>(m_timer.origin_time().to_milliseconds());
 | |
| }
 | |
| 
 | |
| }
 |