Commit graph

40 commits

Author SHA1 Message Date
Andreas Kling
573955be7f LibWeb: Basic support for location.replace(url)
This is not entirely to spec, but gets the basic job done.
2021-10-03 23:36:56 +02:00
Andreas Kling
9f886d499a LibWeb: Remove unnecessary this capture in RequestAnimationFrameDriver 2021-10-03 18:12:36 +02:00
Andreas Kling
81ef2b646e LibWeb: Let HTML::EventLoop drive animation frame callbacks 2021-10-03 16:42:34 +02:00
Andreas Kling
97ea277f8f LibWeb: Pass the correct timestamp to requestAnimationFrame callbacks
The timestamp needs to be consistent with the "current high resolution
time" as reflected by window.performance.now
2021-10-03 13:36:40 +02:00
Andreas Kling
5cf439cce0 LibWeb: Run setTimeout() and setInterval() callbacks as HTML tasks
We now invoke DOM timer callbacks via HTML tasks. This brings callback
sequencing closer to the spec, although there are still many
imperfections in this area.
2021-10-03 13:36:40 +02:00
Idan Horowitz
1c4404c46a LibWeb: Add the missing PageTransitionEvent IDL constructor 2021-10-01 20:14:45 +02:00
Sam Atkins
f1af136925 LibWeb: Make MediaQueryList store MediaQueries instead of a String 2021-10-01 20:03:03 +02:00
Nico Weber
6c9bc18a79 Userland: Fix typos 2021-10-01 01:18:52 +01:00
Idan Horowitz
2c6c9b73c8 LibWeb: Add the Web::Crypto namespace, built-in, and getRandomValues
Since we don't support IDL typedefs or unions yet, the responsibility
of verifying the type of the argument is temporarily moved from the
generated Wrapper to the implementation.
2021-09-30 20:02:09 +02:00
Andreas Kling
63d971d33b LibWeb: Support window.screen{X,Y,Left,Top}
Some sites query these properties for whatever reason, so let's support
them. (But let's always pretend the screen coordinates are (0, 0))
2021-09-29 00:22:46 +02:00
Andreas Kling
7410736b0f LibWeb: Support window.devicePixelRatio
This always returns 1 for now. I've added a FIXME about returning 2 in
HiDPI mode.
2021-09-27 16:52:22 +02:00
Andreas Kling
a248ec63e3 LibWeb: Implement window.queueMicrotask(callback)
This API allows authors to schedule a serialized JS callback that will
get invoked at the next spec-allowed opportunity.
2021-09-26 14:39:14 +02:00
Andreas Kling
831fdcaabc LibWeb: Add the PageTransitionEvent interface and fire "pageshow" events
We now fire "pageshow" events at the appropriate time during document
loading (done by the parser.)

Note that there are no corresponding "pagehide" events yet.
2021-09-26 12:47:51 +02:00
Andreas Kling
2c0987c93b LibWeb: Move window.scroll{X,Y} from wrapper into DOM::Window
The less we do in WindowObject, the easier it will be to eventually
auto-generate the entire thing.
2021-09-25 18:47:19 +02:00
Andreas Kling
3d36e4d944 LibWeb: Rename "Computed" CSSStyleDeclaration => "Resolved"
The original name was based on the window.getComputedStyle() API.
However, "Computed" in "getComputedStyle" is actually a misnomer that
the platform is stuck with due to backwards compatibility.

What getComputedStyle() returns is actually a mix of computed and used
values. The spec calls it the "resolved" values. So let's call this
declaration subclass "ResolvedCSSStyleDeclaration" to match.
2021-09-24 15:01:49 +02:00
Andreas Kling
7632cce5e5 LibWeb: Make requestAnimationFrame() work in multi-process mode
Since we don't have a direct connection to WindowServer, this is slighly
more naive implementation than what we were doing for single-process
mode.

Basically, there's a global RequestAnimationFrameDriver object that
has a 16ms single-shot timer. Whenever someone registers for a RAF
callback, we start the timer (if needed).

This is not ideal, but it's better than nothing. :^)
2021-09-13 02:03:06 +02:00
Idan Horowitz
4629f2e4ad LibWeb: Add the Web::URL namespace and move URLEncoder to it
This namespace will be used for all interfaces defined in the URL
specification, like URL and URLSearchParams.

This has the unfortunate side-effect of requiring us to use the fully
qualified AK::URL name whenever we want to refer to the AK class, so
this commit also fixes all such references.
2021-09-13 01:43:10 +02:00
Andreas Kling
8b27bc078c LibWeb: Add ComputedCSSSstyleDeclaration and support 2 properties :^)
getComputedStyle(element) now returns a ComputedCSSStyleDeclaration
object, which is a live view of the computed style of a given element.

This works by ComputedCSSStyleDeclaration being a wrapper around an
element pointer. When you ask it for a CSS property, it gets the latest
computed style values from the element and returns them as a
CSS::StyleProperty object.

This first cut adds support for computed 'color' and 'display'.

In case the element doesn't have a corresponding node in the layout
tree, we fall back to using specified style instead. This is achieved by
performing an on-the-fly style resolution for the individual element and
then grabbing the requested property from that resolved style.
2021-09-12 20:44:50 +02:00
Andreas Kling
0bcab60463 LibWeb: Make CSSStyleDeclaration an abstract class
This patch moves the CSS property+value storage down to a new subclass
of CSSStyleDeclaration called PropertyOwningCSSStyleDeclaration.

The JavaScript wrapper for CSSStyleDeclaration now calls virtual
functions on the C++ object.

This is preparation for supporting computed style CSSStyleDeclaration
objects which won't have internal property storage, but rather an
internal element pointer. :^)
2021-09-12 20:44:50 +02:00
Linus Groh
51da5d03da LibWeb: Implement window.matchMedia() 2021-09-12 18:25:45 +02:00
Andreas Kling
d69133e4ac LibWeb: Stub out a dummy window.getComputedStyle()
This just returns an empty CSSStyleDeclaration for now. The real thing
needs to be a live object that provides a view onto the computed style
of a given element. This is far from that, but it's something. :^)
2021-09-11 00:36:37 +02:00
Andreas Kling
90cdeebfb3 LibWeb: Rename DOM::Window::document() => associated_document()
Match the spec nomenclature.
2021-09-09 21:25:10 +02:00
Andreas Kling
8f72729f0e LibWeb: Convert DOM::Window to east-const style 2021-09-09 21:25:10 +02:00
Andreas Kling
d392349b6e LibWeb: Add DOM::Window::page()
This helps us to get from a Window to the containing Page, without
clients having to go through Document.
2021-09-09 21:25:10 +02:00
Andreas Kling
e91edcaa28 LibWeb: Rename InitialContainingBlockBox => InitialContainingBlock
The "Box" suffix added nothing here.
2021-09-08 11:27:46 +02:00
Andreas Kling
dfa9dcca98 LibWeb+Browser: Remove unnecessary InProcessWebView.h includes 2021-08-24 16:37:28 +02:00
Andreas Kling
ba9d5c4d54 LibJS: Rename Function => FunctionObject 2021-06-27 22:36:04 +02:00
Andreas Kling
4190fd2199 LibWeb: Rename Web::Frame to Web::BrowsingContext
Our "frame" concept very closely matches what the web specs call a
"browsing context", so let's rename it to that. :^)

The "main frame" becomes the "top-level browsing context",
and "sub-frames" are now "nested browsing contexts".
2021-05-30 12:39:53 +02:00
Linus Groh
08373090ae LibJS: Add VM::on_call_stack_emptied callback
Instead of having to run queued promise jobs in LibWeb in various
places, this allows us to consolidate that into one function - this is
very close to how the spec describes it as well ("at some future point
in time, when there is no running execution context and the execution
context stack is empty, the implementation must [...]").

Eventually this will also be used to log unhandled exceptions, and
possibly other actions that require JS execution to have ended.
2021-04-24 20:11:04 +02:00
Andreas Kling
b91c49364d AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Linus Groh
340e1f4b28 LibWeb: Implement the Screen interface
https://drafts.csswg.org/cssom-view/#the-screen-interface
2021-04-04 00:37:54 +02:00
Linus Groh
ade3adcc7a LibWeb: Run queued promise jobs after callbacks
We now run queued promise jobs after calling event handler, timer, and
requestAnimationFrame() callbacks - this is a bit ad-hoc, but I don't
want to switch LibWeb to use an event loop right now - this works just
fine, too.
We might want to revisit this at a later point and do tasks and
microtasks properly.
2021-04-02 10:47:40 +02:00
Linus Groh
056ffa4abb LibWeb: Call requestAnimationFrame() callback with undefined this value
We were leaking an empty value via the callback's this value:

    requestAnimationFrame(function () {
        this; // <-- empty value
    });
2021-03-26 22:59:47 +01:00
Andreas Kling
906cccbf7f LibWeb: Add Window.innerWidth and Window.innerHeight 2021-03-16 17:22:59 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Linus Groh
5e07c27e25 LibWeb: Implement Window.prompt() 2021-02-20 12:19:46 +01:00
Andreas Kling
abf7c02acb LibWeb: Move window.confirm() to using a PageClient callback
This allows us to move the GUI::MessageBox out of DOM::Window and up to
the widget layer.
2021-02-10 09:13:30 +01:00
Andreas Kling
0639e77898 LibWeb: Make the Window object "inherit" from EventTarget :^)
Since Web::Bindings::WindowObject inherits from JS::GlobalObject, it
cannot also inherit from Web::Bindings::EventTargetWrapper.

However, that's not actually necessary. Instead, we simply set the
Window object's prototype to the EventTargetPrototype, and add a little
extra branch in the impl_from() function that turns the JS "this" value
into a DOM::EventTarget*.

With this, you can now call window.addEventListener()! Very cool :^)

Fixes #4758.
2021-01-18 12:18:29 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Renamed from Libraries/LibWeb/DOM/Window.cpp (Browse further)