Commit Graph

139 Commits

Author SHA1 Message Date
Andreas Kling
8fd59fce9c LibWeb: Remove unnecessary hack in HTML::Window::initialize()
We don't need to force-set the realm's global object during
initialization anymore, now that intrinsics are set up elsewhere.
2022-10-20 15:31:12 +02:00
Andreas Kling
dc15cacfc3 LibWeb: Use OrderedHashMap to store pending idle callbacks
This removes the need for a separate IdleCallback object per
registration, since the handles are now used as map keys.
2022-10-20 15:16:23 +02:00
Andreas Kling
24510b0845 LibWeb: Make window.parent and window.top return WindowProxy
These functions were previously ad-hoc and returned the active
document's window. They now correctly teturn the browsing context's
WindowProxy instead.
2022-10-20 15:16:23 +02:00
Andreas Kling
a2348ebcc0 LibWeb: Make Window.getSelection() forward to Document.getSelection()
(And have document create the Selection object on demand.)
2022-10-10 21:23:03 +02:00
Andrew Kaster
2d5bee256e LibWeb: Re-implement HTML::Navigator using IDL
Get rid of the bespoke NavigatorObject class and use the modern IDL
strategies for creating platform objects to re-implement Navigator and
its associcated mixin interfaces. While we're here, implement it in a
way that brings WorkerNavigator up to spec :^)
2022-10-09 10:14:57 +02:00
Andrew Kaster
394f1b3836 LibWeb: Remove prototype and constructor helpers from Window 2022-10-01 21:05:32 +01:00
Andrew Kaster
c61a4f35dc LibWeb: Move Web prototypes and constructors to new Intrinsics object
This Intrinsics object hangs off of a new HostDefined struct that takes
the place of EnvironmentSettingsObject as the true [[HostDefined]] slot
on JS::Realm objects created by LibWeb.

This gets the intrinsics off of the GlobalObject, Window, similar to the
previous refactor of LibJS to move the intrinsics into the Realm's
[[Intrinics]] internal slot.

A side effect of this change is that we cannot fully initialize a Window
object until the [[HostDefined]] slot has been installed into the realm,
which happens with the creation of the WindowEnvironmentSettingsObject.

As such, any Window usage that has not been funned through a WindowESO
will not have any cached Web prototyped or constructors, and will not
have Window APIs available to javascript code. Currently this seems
limited to usage of Window in the CSS parser, but a subsequent commit
will clean those up to take Realm as well. However, this commit compiles
so let's cut it off here :^).
2022-10-01 21:05:32 +01:00
Linus Groh
ad04d7ac9b LibWeb: Move ExceptionOr from DOM/ to WebIDL/
This is a concept fully defined in the Web IDL spec and doesn't belong
in the DOM directory/namespace - not even DOMException, despite the name
:^)
2022-09-25 19:13:31 +01:00
Linus Groh
4f73851afc LibWeb: Move CallbackType from Bindings/ to WebIDL/
Let's stop putting generic types and AOs from the Web IDL spec into
the Bindings namespace and directory in LibWeb, and instead follow our
usual naming rules of 'directory = namespace = spec name'. The IDL
namespace is already used by LibIDL, so Web::WebIDL seems like a good
choice.
2022-09-24 19:31:39 +01:00
Linus Groh
dc44effd44 LibWeb: Move cross-origin AOs from Bindings/ to HTML/CrossOrigin/
These are from the HTML spec and therefore belong in the HTML/ directory
in LibWeb. Bindings/ has become a bit of a dumping ground, so this is a
first step towards cleaning that up.
2022-09-24 19:31:39 +01:00
Linus Groh
4270ede7c4 LibWeb: Remove WRAPPER_HACK() macro
We no longer access Bindings::FooWrapper anywhere for a Foo platform
object, so these can be removed :^)
2022-09-21 21:12:24 +01:00
Andreas Kling
ac76df3d47 LibWeb: Implement Window.frameElement 2022-09-20 14:48:07 +02:00
Andreas Kling
4ee5dfbe4b LibWeb: Flesh out a chunk of the HTML spec's frame navigation algorithms 2022-09-20 10:32:13 +02:00
networkException
e377e28fd2 LibWeb: Implement window.length 2022-09-09 17:42:30 +01:00
Andreas Kling
9567e211e7 LibWeb+WebContent: Add abstraction layer for event loop and timers
Instead of using Core::EventLoop and Core::Timer directly, LibWeb now
goes through a Web::Platform abstraction layer instead.

This will allow us to plug in Qt's event loop (and QTimer) over in
Ladybird, to avoid having to deal with multiple event loops.
2022-09-07 20:30:31 +02:00
Andreas Kling
be9d3860b9 LibWeb: Make Crypto GC-allocated 2022-09-06 00:27:09 +02:00
Andreas Kling
a9cae56f8e LibWeb: Remove unused HTML::Window::create_with_document() 2022-09-06 00:27:09 +02:00
Andreas Kling
7a9b8ced38 LibWeb: Make SubtleCrypto GC-allocated 2022-09-06 00:27:09 +02:00
Andreas Kling
2ac8e3db3a LibWeb: Make Storage GC-allocated 2022-09-06 00:27:09 +02:00
Andreas Kling
c7ac82ec33 LibWeb: Make HTML::Timer GC-allocated
These are the timers used internally by setTimeout() and setInterval().
2022-09-06 00:27:09 +02:00
Andreas Kling
8c90e08e0b LibWeb: Make CSS::Screen GC-allocated 2022-09-06 00:27:09 +02:00
Andreas Kling
8341f142ea LibWeb: Add HTML::Window::cached_web_prototype()
This is a simpler version of ensure_web_prototype<T>(). This new version
assumes that we already have a cached instance of the prototype.
2022-09-06 00:27:09 +02:00
Andreas Kling
6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00
Andreas Kling
7c3db526b0 LibWeb: Make DOM::Event and all its subclasses GC-allocated 2022-09-06 00:27:09 +02:00
Andreas Kling
8cda70c892 LibWeb: Move event listeners, handlers and callbacks to the GC heap
This patch moves the following things to being GC-allocated:
- Bindings::CallbackType
- HTML::EventHandler
- DOM::IDLEventListener
- DOM::DOMEventListener
- DOM::NodeFilter

Note that we only use PlatformObject for things that might be exposed
to web content. Anything that is only used internally inherits directly
from JS::Cell instead, making them a bit more lightweight.
2022-09-06 00:27:09 +02:00
Andreas Kling
72bacba97b LibWeb: Make CSSStyleDeclaration GC-allocated 2022-09-06 00:27:09 +02:00
Linus Groh
40a70461a0 LibWeb: Replace GlobalObject with Realm in wrapper functions
Similar to create() in LibJS, wrap() et al. are on a low enough level to
warrant passing a Realm directly instead of relying on the current realm
from the VM, as a wrapper may need to be allocated while no JS is being
executed.
2022-08-23 13:58:30 +01:00
Andreas Kling
e756b5450d LibWeb: Add a way to construct HTML::Window without a DOM::Document
This will be used to implement the rather intricate construction order
in the HTML spec.
2022-08-05 12:42:46 +02:00
Luke Wilde
3fe66bddf4 LibWeb: Implement WindowEventHandlers 2022-06-29 21:21:50 +01:00
Luke Wilde
ebf2184636 LibWeb: Only make certain <body> and <frameset> events apply to Window
Previously we forwarded all event handler attributes to Window from
these two elements, however, we are only supposed to forward blur,
error, focus, load, resize and scroll.
2022-06-29 21:21:50 +01:00
MacDue
3cfa9b63b5 LibWeb: Stop inactive requestAnimationFrame() callbacks from running
Previously requestAnimationFrame() callbacks were registered with a
static global RequestAnimationFrameDriver shared between all windows.
This led to callbacks still running after navigating away from a page
(This could be seen with the WASM GoL demo).

This commit moves the RequestAnimationFrameDriver (now
AnimationFrameCallbackDriver) to be a member of the HTML::Window
object, then uses the 'active document' parameter of
run_animation_frame_callbacks() to run only the active callbacks.
2022-05-13 00:47:16 +02:00
Simon Wanner
ea9857a423 LibWeb: Add the requestIdleCallback/cancelIdleCallback API 2022-04-02 23:52:25 +01:00
Simon Wanner
836d2ff259 LibWeb: Implement the infrastructure necessary for requestIdleCallback
This includes a bug fix for the event loop processing steps which has
not been merged yet: https://github.com/whatwg/html/pull/7768
2022-04-02 23:52:25 +01:00
Timothy Flynn
430559ea51 LibWeb: Weakly store a reference to the Window object in timer tasks
This prevents a crash when refreshing or navigating away from the Acid3
test page while it is actively running.
2022-03-24 21:37:58 +01:00
Simon Wanner
7969161f07 LibWeb: Implement window.name
Right now the only functionality supported is getting/setting via JS
and resetting when browsing cross origin.

The HTML Specification (7.11 Browsing the web) also specifies how the
name should be restored from history entries, but we don't have those
yet.
2022-03-16 21:49:54 +00:00
Paul Wratt
83eb5ac8fd LibWeb: Add window.sessionStorage 2022-03-10 10:02:51 +01:00
Sam Atkins
12561327d6 LibWeb: Use MediaFeatureIDs instead of Strings :^) 2022-03-09 23:06:30 +01:00
Linus Groh
0706f0d487 LibWeb: Move Timer from DOM directory & namespace to HTML
Timers are part of the HTML spec. :^)
https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
2022-03-08 00:30:30 +01:00
Linus Groh
1422bd45eb LibWeb: Move Window from DOM directory & namespace to HTML
The Window object is part of the HTML spec. :^)
https://html.spec.whatwg.org/multipage/window-object.html
2022-03-08 00:30:30 +01:00