1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:57:34 +00:00

LibWeb/HTML: Move WindowOrWorkerGlobalScope code into a mixin class

This will allow us to easily share the implementations of these methods
between Window and WorkerGlobalScope. The mixin class mirrors what I
already did for the Fetch API's Body mixin in 5ad62833.
This commit is contained in:
Linus Groh 2023-03-05 23:58:47 +00:00
parent b118cc782e
commit 1a6b61b0cc
5 changed files with 125 additions and 81 deletions

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Forward.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
class WindowOrWorkerGlobalScopeMixin {
public:
virtual ~WindowOrWorkerGlobalScopeMixin();
virtual Bindings::PlatformObject& this_impl() = 0;
virtual Bindings::PlatformObject const& this_impl() const = 0;
// JS API functions
WebIDL::ExceptionOr<String> origin() const;
bool is_secure_context() const;
bool cross_origin_isolated() const;
WebIDL::ExceptionOr<String> btoa(String const& data) const;
WebIDL::ExceptionOr<String> atob(String const& data) const;
};
}