LibWeb/HTML: Port Window.history to IDL
This commit is contained in:
parent
eccc0d90de
commit
c42496187b
Notes:
sideshowbarker
2024-07-17 10:08:28 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/c42496187b Pull-request: https://github.com/SerenityOS/serenity/pull/17752 Reviewed-by: https://github.com/awesomekling
6 changed files with 17 additions and 9 deletions
|
@ -2068,6 +2068,11 @@ JS::NonnullGCPtr<HTML::History> Document::history()
|
|||
return *m_history;
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<HTML::History> Document::history() const
|
||||
{
|
||||
return const_cast<Document*>(this)->history();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/origin.html#dom-document-domain
|
||||
DeprecatedString Document::domain() const
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -337,6 +338,7 @@ public:
|
|||
bool is_active() const;
|
||||
|
||||
JS::NonnullGCPtr<HTML::History> history();
|
||||
JS::NonnullGCPtr<HTML::History> history() const;
|
||||
|
||||
HTML::Location* location();
|
||||
|
||||
|
|
|
@ -249,6 +249,7 @@ class ErrorEvent;
|
|||
class EventHandler;
|
||||
class EventLoop;
|
||||
class FormDataEvent;
|
||||
class History;
|
||||
class HTMLAnchorElement;
|
||||
class HTMLAreaElement;
|
||||
class HTMLAudioElement;
|
||||
|
|
|
@ -1076,7 +1076,6 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
|
|||
define_native_accessor(realm, "top", top_getter, nullptr, JS::Attribute::Enumerable);
|
||||
define_native_accessor(realm, "parent", parent_getter, {}, JS::Attribute::Enumerable);
|
||||
define_native_accessor(realm, "frameElement", frame_element_getter, {}, JS::Attribute::Enumerable);
|
||||
define_native_accessor(realm, "history", history_getter, {}, JS::Attribute::Enumerable);
|
||||
define_native_accessor(realm, "performance", performance_getter, performance_setter, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_native_accessor(realm, "crypto", crypto_getter, {}, JS::Attribute::Enumerable);
|
||||
define_native_accessor(realm, "screen", screen_getter, screen_setter, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
|
@ -1232,6 +1231,13 @@ JS::NonnullGCPtr<Location> Window::location() const
|
|||
return *m_location;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-history
|
||||
JS::NonnullGCPtr<History> Window::history() const
|
||||
{
|
||||
// The history getter steps are to return this's associated Document's history object.
|
||||
return associated_document().history();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames
|
||||
JS::NonnullGCPtr<WindowProxy> Window::frames() const
|
||||
{
|
||||
|
@ -1825,12 +1831,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::scroll_by)
|
|||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::history_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
return impl->associated_document().history();
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::screen_left_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
|
|
@ -143,6 +143,7 @@ public:
|
|||
String name() const;
|
||||
void set_name(String const&);
|
||||
JS::NonnullGCPtr<Location> location() const;
|
||||
JS::NonnullGCPtr<History> history() const;
|
||||
|
||||
JS::NonnullGCPtr<WindowProxy> frames() const;
|
||||
|
||||
|
@ -226,8 +227,6 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(performance_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(performance_setter);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(history_getter);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(screen_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(screen_setter);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ interface Window : EventTarget {
|
|||
[LegacyUnforgeable] readonly attribute Document document;
|
||||
attribute DOMString name;
|
||||
[PutForwards=href, LegacyUnforgeable] readonly attribute Location location;
|
||||
readonly attribute History history;
|
||||
|
||||
// other browsing contexts
|
||||
[Replaceable] readonly attribute WindowProxy frames;
|
||||
|
|
Loading…
Add table
Reference in a new issue