mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 08:42:43 +00:00 
			
		
		
		
	 07b950d8a6
			
		
	
	
		07b950d8a6
		
	
	
	
	
		
			
			Hopefully no one else will forget to call set_prototype with the cached prototype they just retrieved from a realm and spend a long time wondering why their object has no properties...
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/TypeCasts.h>
 | |
| #include <LibJS/Heap/GCPtr.h>
 | |
| #include <LibJS/Runtime/Realm.h>
 | |
| #include <LibWeb/Forward.h>
 | |
| 
 | |
| namespace Web::Bindings {
 | |
| 
 | |
| struct HostDefined : public JS::Realm::HostDefined {
 | |
|     HostDefined(JS::GCPtr<HTML::EnvironmentSettingsObject> eso, JS::NonnullGCPtr<Intrinsics> intrinsics)
 | |
|         : environment_settings_object(eso)
 | |
|         , intrinsics(intrinsics)
 | |
|     {
 | |
|     }
 | |
|     virtual ~HostDefined() override = default;
 | |
|     virtual void visit_edges(JS::Cell::Visitor& visitor) override;
 | |
| 
 | |
|     // NOTE: Only the root execution environment in the main thread VM ever sets this to nullptr
 | |
|     JS::GCPtr<HTML::EnvironmentSettingsObject> environment_settings_object;
 | |
|     JS::NonnullGCPtr<Intrinsics> intrinsics;
 | |
| };
 | |
| 
 | |
| [[nodiscard]] inline HTML::EnvironmentSettingsObject& host_defined_environment_settings_object(JS::Realm& realm)
 | |
| {
 | |
|     return *verify_cast<HostDefined>(realm.host_defined())->environment_settings_object;
 | |
| }
 | |
| 
 | |
| }
 |