Ver código fonte

LibWeb: Fill out implementation of current_principal_settings_object

In terms of the 'current principal realm' definition.

No functional impact, as we still need to implement current principal
realm once the surrounding infrastructure is in place. But it is one
less place which needs to be updated when that is all in place :^)
Shannon Booth 8 meses atrás
pai
commit
0c2400641e

+ 12 - 4
Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp

@@ -300,14 +300,22 @@ JS::Object& incumbent_global_object()
     return incumbent_settings_object().global_object();
 }
 
-// https://html.spec.whatwg.org/multipage/webappapis.html#current-settings-object
-EnvironmentSettingsObject& current_principal_settings_object()
+// https://whatpr.org/html/9893/webappapis.html#current-principal-realm
+JS::Realm& current_principal_realm()
 {
+    // FIXME: The current principal realm is the principal realm of the current realm.
     auto& event_loop = HTML::main_thread_event_loop();
     auto& vm = event_loop.vm();
 
-    // Then, the current settings object is the environment settings object of the current Realm Record.
-    return Bindings::host_defined_environment_settings_object(*vm.current_realm());
+    return *vm.current_realm();
+}
+
+// https://html.spec.whatwg.org/multipage/webappapis.html#current-settings-object
+// https://whatpr.org/html/9893/webappapis.html#current-principal-settings-object
+EnvironmentSettingsObject& current_principal_settings_object()
+{
+    // Then, the current principal settings object is the environment settings object of the current principal realm.
+    return Bindings::host_defined_environment_settings_object(current_principal_realm());
 }
 
 // https://html.spec.whatwg.org/multipage/webappapis.html#current-global-object

+ 3 - 0
Userland/Libraries/LibWeb/HTML/Scripting/Environments.h

@@ -142,7 +142,10 @@ private:
 EnvironmentSettingsObject& incumbent_settings_object();
 JS::Realm& incumbent_realm();
 JS::Object& incumbent_global_object();
+
+JS::Realm& current_principal_realm();
 EnvironmentSettingsObject& current_principal_settings_object();
+
 JS::Object& current_global_object();
 JS::Realm& relevant_realm(JS::Object const&);
 EnvironmentSettingsObject& relevant_settings_object(JS::Object const&);