2020-05-18 16:42:40 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
2023-01-18 14:41:12 -03:00
|
|
|
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
2020-05-18 16:42:40 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-18 16:42:40 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-03-05 20:24:18 -03:00
|
|
|
#include <LibJS/Forward.h>
|
2021-09-28 19:54:42 -03:00
|
|
|
#include <LibJS/Runtime/Completion.h>
|
2024-03-18 00:22:27 -03:00
|
|
|
#include <LibURL/URL.h>
|
2022-09-04 11:55:50 -03:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2020-05-18 16:42:40 -03:00
|
|
|
#include <LibWeb/Forward.h>
|
2022-09-24 10:02:47 -03:00
|
|
|
#include <LibWeb/HTML/CrossOrigin/CrossOriginPropertyDescriptorMap.h>
|
2024-03-28 08:58:43 -03:00
|
|
|
#include <LibWeb/HTML/Navigable.h>
|
2020-05-18 16:42:40 -03:00
|
|
|
|
2023-01-18 14:41:12 -03:00
|
|
|
namespace Web::HTML {
|
2020-05-18 16:42:40 -03:00
|
|
|
|
2023-01-18 14:41:12 -03:00
|
|
|
class Location final : public Bindings::PlatformObject {
|
2024-05-19 17:48:52 -03:00
|
|
|
WEB_PLATFORM_OBJECT(Location, Bindings::PlatformObject);
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DECLARE_ALLOCATOR(Location);
|
2020-06-21 10:14:02 -03:00
|
|
|
|
2020-05-18 16:42:40 -03:00
|
|
|
public:
|
2023-01-18 14:41:12 -03:00
|
|
|
virtual ~Location() override;
|
|
|
|
|
|
2023-03-04 19:16:07 -03:00
|
|
|
WebIDL::ExceptionOr<String> href() const;
|
2023-03-04 19:19:14 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_href(String const&);
|
2023-01-18 14:41:12 -03:00
|
|
|
|
2023-03-04 19:16:07 -03:00
|
|
|
WebIDL::ExceptionOr<String> origin() const;
|
2023-01-18 14:41:12 -03:00
|
|
|
|
2023-03-04 19:16:07 -03:00
|
|
|
WebIDL::ExceptionOr<String> protocol() const;
|
2023-03-04 19:19:14 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_protocol(String const&);
|
2023-01-18 14:41:12 -03:00
|
|
|
|
2023-03-04 19:16:07 -03:00
|
|
|
WebIDL::ExceptionOr<String> host() const;
|
2023-03-04 19:19:14 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_host(String const&);
|
2023-01-18 14:41:12 -03:00
|
|
|
|
2023-03-04 19:16:07 -03:00
|
|
|
WebIDL::ExceptionOr<String> hostname() const;
|
2023-03-04 19:19:14 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_hostname(String const&);
|
2023-01-18 14:41:12 -03:00
|
|
|
|
2023-03-04 19:16:07 -03:00
|
|
|
WebIDL::ExceptionOr<String> port() const;
|
2023-03-04 19:19:14 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_port(String const&);
|
2023-01-18 14:41:12 -03:00
|
|
|
|
2023-03-04 19:16:07 -03:00
|
|
|
WebIDL::ExceptionOr<String> pathname() const;
|
2023-03-04 19:19:14 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_pathname(String const&);
|
2023-01-18 14:41:12 -03:00
|
|
|
|
2023-03-04 19:16:07 -03:00
|
|
|
WebIDL::ExceptionOr<String> search() const;
|
2023-03-04 19:19:14 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_search(String const&);
|
2023-01-18 14:41:12 -03:00
|
|
|
|
2023-03-04 19:16:07 -03:00
|
|
|
WebIDL::ExceptionOr<String> hash() const;
|
2025-04-23 02:00:56 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_hash(StringView);
|
2023-01-18 14:41:12 -03:00
|
|
|
|
2023-08-22 13:49:28 -03:00
|
|
|
WebIDL::ExceptionOr<void> replace(String const& url);
|
2023-01-18 14:41:12 -03:00
|
|
|
void reload() const;
|
2023-08-22 13:33:20 -03:00
|
|
|
WebIDL::ExceptionOr<void> assign(String const& url);
|
2020-05-18 16:42:40 -03:00
|
|
|
|
2022-03-05 20:24:18 -03:00
|
|
|
virtual JS::ThrowCompletionOr<JS::Object*> internal_get_prototype_of() const override;
|
2021-09-28 19:54:42 -03:00
|
|
|
virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype) override;
|
2021-09-28 20:02:05 -03:00
|
|
|
virtual JS::ThrowCompletionOr<bool> internal_is_extensible() const override;
|
2021-09-28 20:13:41 -03:00
|
|
|
virtual JS::ThrowCompletionOr<bool> internal_prevent_extensions() override;
|
2022-03-05 20:24:18 -03:00
|
|
|
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const&) const override;
|
2024-11-01 17:03:18 -03:00
|
|
|
virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyKey const&, JS::PropertyDescriptor const&, Optional<JS::PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
2024-05-02 06:13:08 -03:00
|
|
|
virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver, JS::CacheablePropertyMetadata*, PropertyLookupPhase) const override;
|
2025-05-04 11:00:13 -03:00
|
|
|
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata*, PropertyLookupPhase) override;
|
2022-03-05 20:24:18 -03:00
|
|
|
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override;
|
2025-05-16 00:14:12 -03:00
|
|
|
virtual JS::ThrowCompletionOr<GC::RootVector<JS::Value>> internal_own_property_keys() const override;
|
2021-09-12 10:54:17 -03:00
|
|
|
|
2022-09-24 10:02:47 -03:00
|
|
|
HTML::CrossOriginPropertyDescriptorMap const& cross_origin_property_descriptor_map() const { return m_cross_origin_property_descriptor_map; }
|
|
|
|
|
HTML::CrossOriginPropertyDescriptorMap& cross_origin_property_descriptor_map() { return m_cross_origin_property_descriptor_map; }
|
2022-03-05 17:31:31 -03:00
|
|
|
|
2020-05-18 16:42:40 -03:00
|
|
|
private:
|
2023-01-18 14:41:12 -03:00
|
|
|
explicit Location(JS::Realm&);
|
2022-09-04 11:55:50 -03:00
|
|
|
|
2025-04-18 05:31:28 -03:00
|
|
|
virtual bool is_html_location() const override { return true; }
|
|
|
|
|
|
2023-08-07 03:41:28 -03:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-09-04 11:55:50 -03:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<DOM::Document> relevant_document() const;
|
2024-03-18 00:22:27 -03:00
|
|
|
URL::URL url() const;
|
2024-03-28 08:58:43 -03:00
|
|
|
WebIDL::ExceptionOr<void> navigate(URL::URL, Bindings::NavigationHistoryBehavior = Bindings::NavigationHistoryBehavior::Auto);
|
2022-03-04 20:15:36 -03:00
|
|
|
|
2022-03-05 17:31:31 -03:00
|
|
|
// [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap
|
2022-09-24 10:02:47 -03:00
|
|
|
HTML::CrossOriginPropertyDescriptorMap m_cross_origin_property_descriptor_map;
|
2022-03-05 20:24:18 -03:00
|
|
|
|
|
|
|
|
// [[DefaultProperties]], https://html.spec.whatwg.org/multipage/history.html#defaultproperties
|
2025-05-16 00:14:12 -03:00
|
|
|
Vector<JS::Value> m_default_properties;
|
2020-05-18 16:42:40 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
2025-04-18 05:31:28 -03:00
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
inline bool JS::Object::fast_is<Web::HTML::Location>() const { return is_html_location(); }
|