Serenity Operating System
at master 84 lines 3.5 kB view raw
1/* 2 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> 3 * Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org> 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#pragma once 9 10#include <AK/URL.h> 11#include <LibJS/Forward.h> 12#include <LibJS/Runtime/Completion.h> 13#include <LibWeb/Bindings/PlatformObject.h> 14#include <LibWeb/Forward.h> 15#include <LibWeb/HTML/CrossOrigin/CrossOriginPropertyDescriptorMap.h> 16 17namespace Web::HTML { 18 19class Location final : public Bindings::PlatformObject { 20 JS_OBJECT(Location, Bindings::PlatformObject); 21 22public: 23 virtual ~Location() override; 24 25 WebIDL::ExceptionOr<String> href() const; 26 WebIDL::ExceptionOr<void> set_href(String const&); 27 28 WebIDL::ExceptionOr<String> origin() const; 29 30 WebIDL::ExceptionOr<String> protocol() const; 31 WebIDL::ExceptionOr<void> set_protocol(String const&); 32 33 WebIDL::ExceptionOr<String> host() const; 34 WebIDL::ExceptionOr<void> set_host(String const&); 35 36 WebIDL::ExceptionOr<String> hostname() const; 37 WebIDL::ExceptionOr<void> set_hostname(String const&); 38 39 WebIDL::ExceptionOr<String> port() const; 40 WebIDL::ExceptionOr<void> set_port(String const&); 41 42 WebIDL::ExceptionOr<String> pathname() const; 43 WebIDL::ExceptionOr<void> set_pathname(String const&); 44 45 WebIDL::ExceptionOr<String> search() const; 46 WebIDL::ExceptionOr<void> set_search(String const&); 47 48 WebIDL::ExceptionOr<String> hash() const; 49 WebIDL::ExceptionOr<void> set_hash(String const&); 50 51 void replace(String const& url) const; 52 void reload() const; 53 54 virtual JS::ThrowCompletionOr<JS::Object*> internal_get_prototype_of() const override; 55 virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype) override; 56 virtual JS::ThrowCompletionOr<bool> internal_is_extensible() const override; 57 virtual JS::ThrowCompletionOr<bool> internal_prevent_extensions() override; 58 virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const&) const override; 59 virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyKey const&, JS::PropertyDescriptor const&) override; 60 virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver) const override; 61 virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override; 62 virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override; 63 virtual JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> internal_own_property_keys() const override; 64 65 HTML::CrossOriginPropertyDescriptorMap const& cross_origin_property_descriptor_map() const { return m_cross_origin_property_descriptor_map; } 66 HTML::CrossOriginPropertyDescriptorMap& cross_origin_property_descriptor_map() { return m_cross_origin_property_descriptor_map; } 67 68private: 69 explicit Location(JS::Realm&); 70 71 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; 72 virtual void visit_edges(Cell::Visitor&) override; 73 74 JS::GCPtr<DOM::Document> relevant_document() const; 75 AK::URL url() const; 76 77 // [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap 78 HTML::CrossOriginPropertyDescriptorMap m_cross_origin_property_descriptor_map; 79 80 // [[DefaultProperties]], https://html.spec.whatwg.org/multipage/history.html#defaultproperties 81 Vector<JS::Value> m_default_properties; 82}; 83 84}